adding in some needed packages

This commit is contained in:
reisenlol 2026-01-02 01:31:54 -08:00
parent 9e739f5dc8
commit aba5310742
No known key found for this signature in database
1012 changed files with 494191 additions and 1 deletions

View file

@ -0,0 +1,89 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM && DNP_NewInputSystem
using UnityEngine.InputSystem;
#endif
namespace DamageNumbersPro.Demo
{
public class DNP_2DDemo : MonoBehaviour
{
float nextShotTime;
void Start()
{
nextShotTime = 0;
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
void Update()
{
HandleShooting();
}
void HandleShooting()
{
if (DNP_InputHandler.GetLeftClick())
{
Shoot();
nextShotTime = Time.time + 0.3f;
}
else if (DNP_InputHandler.GetRightHeld() && Time.time > nextShotTime)
{
Shoot();
nextShotTime = Time.time + 0.06f;
}
}
void Shoot()
{
Vector2 mousePosition = Vector2.zero;
#if ENABLE_INPUT_SYSTEM && DNP_NewInputSystem
if (Mouse.current != null) {
mousePosition = Mouse.current.position.ReadValue();
}
#else
mousePosition = Input.mousePosition;
#endif
//Raycast.
Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePosition);
worldPosition.z = -5;
RaycastHit hit;
Physics.Raycast(worldPosition, Vector3.forward, out hit, 10f);
//Select Damage Number:
DNP_PrefabSettings settings = DNP_DemoManager.instance.GetSettings();
DamageNumber prefab = DNP_DemoManager.instance.GetCurrent();
//Number:
float number = 1 + Mathf.Pow(Random.value, 2.2f) * settings.numberRange;
if (prefab.digitSettings.decimals == 0)
{
number = Mathf.Floor(number);
}
//Create Damage Number:
DamageNumber newDamageNumber = prefab.Spawn(worldPosition, number);
if (hit.collider != null)
{
DNP_Target dnpTarget = hit.collider.GetComponent<DNP_Target>();
if(dnpTarget != null)
{
dnpTarget.Hit();
}
newDamageNumber.SetFollowedTarget(hit.collider.transform);
}
//Apply Demo Settings:
settings.Apply(newDamageNumber);
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: eab9f4b5737a76b4bb016fc5cbd3332c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_2DDemo.cs
uploadId: 731065

View file

@ -0,0 +1,222 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DamageNumbersPro.Demo
{
public class DNP_Camera : MonoBehaviour
{
//Instance:
public static DNP_Camera instance;
//Shooting:
GameObject cubeHighlight;
float nextShotTime;
float nextRaycastTime;
float lookTime;
//Movement:
Vector3 velocity;
void Awake()
{
instance = this;
cubeHighlight = GameObject.Find("Special").transform.Find("Prefabs/Other/Cube Highlight").gameObject;
}
void Update()
{
HandleMovement();
HandleShooting();
//Escape:
if(DNP_InputHandler.GetEscape())
{
ShowMouse();
Invoke("ShowMouse", 0.1f);
Invoke("ShowMouse", 0.2f);
Invoke("ShowMouse", 0.25f);
Invoke("ShowMouse", 0.3f);
CancelInvoke("HideMouse");
}
}
void ShowMouse()
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
void HideMouse()
{
if(DNP_InputHandler.GetLeftHeld())
{
Invoke("HideMouse", 0.1f);
}
else
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
}
void LateUpdate()
{
HandleLooking();
}
//Functions:
void HandleShooting()
{
if(DNP_InputHandler.GetLeftClick())
{
Shoot();
nextShotTime = Time.time + 0.3f;
} else if(DNP_InputHandler.GetRightHeld() && Time.time > nextShotTime)
{
Shoot();
nextShotTime = Time.time + 0.06f;
}
//Detection:
if (Time.time > nextRaycastTime)
{
nextRaycastTime = Time.time + 0.11f;
RaycastHit raycast;
if (Physics.Raycast(transform.position, transform.forward, out raycast, 100))
{
DNP_Crosshair.targetEnemy = raycast.collider.gameObject.layer == 1;
}
}
}
void Shoot()
{
if (Cursor.visible)
{
if(!IsInvoking("HideMouse"))
{
Invoke("HideMouse", 0.1f);
lookTime = Time.time + 0.3f;
}
return;
}
RaycastHit raycast;
if(Physics.Raycast(transform.position, transform.forward, out raycast, 100))
{
//Create Damage Number:
DNP_PrefabSettings settings = DNP_DemoManager.instance.GetSettings();
DamageNumber prefab = DNP_DemoManager.instance.GetCurrent();
float number = 1 + Mathf.Pow(Random.value, 2.2f) * settings.numberRange;
if(prefab.digitSettings.decimals == 0)
{
number = Mathf.Floor(number);
}
DamageNumber newDamageNumber = prefab.Spawn(raycast.point, number);
//Apply Demo Settings:
settings.Apply(newDamageNumber);
//Create Cube:
if (raycast.collider.gameObject.layer != 1)
{
Vector3 cubePosition = raycast.point - raycast.normal * 0.1f;
cubePosition.x = Mathf.FloorToInt(cubePosition.x) + 0.5f;
cubePosition.y = Mathf.FloorToInt(cubePosition.y) + 0.5f;
cubePosition.z = Mathf.FloorToInt(cubePosition.z) + 0.5f;
GameObject newCube = Instantiate<GameObject>(cubeHighlight);
newCube.transform.position = cubePosition;
newCube.SetActive(true);
DNP_Crosshair.instance.HitWall();
}
else
{
DNP_Target target = raycast.collider.GetComponent<DNP_Target>();
DNP_Crosshair.instance.HitTarget();
if (target != null)
{
if(newDamageNumber.spamGroup != "")
{
newDamageNumber.spamGroup += target.GetInstanceID();
}
newDamageNumber.enableFollowing = true;
newDamageNumber.followedTarget = target.transform;
target.Hit();
}
}
}
}
void HandleLooking()
{
if (Time.time < lookTime || Cursor.visible) return;
Vector2 mouseDelta = DNP_InputHandler.GetMouseDelta();
Vector3 eulerAngles = transform.eulerAngles;
eulerAngles.y += mouseDelta.x;
eulerAngles.x -= mouseDelta.y;
if (eulerAngles.x > 180)
{
eulerAngles.x -= 360;
}
eulerAngles.x = Mathf.Clamp(eulerAngles.x, -80f, 80f);
transform.eulerAngles = eulerAngles;
}
void HandleMovement()
{
Vector3 desiredDirection = Vector3.zero;
if (DNP_InputHandler.GetRight())
{
desiredDirection.x += 1;
}
if (DNP_InputHandler.GetLeft())
{
desiredDirection.x += -1;
}
if (DNP_InputHandler.GetForward())
{
desiredDirection.z += 1;
}
if (DNP_InputHandler.GetBack())
{
desiredDirection.z += -1;
}
if (DNP_InputHandler.GetUp())
{
desiredDirection.y += 1;
}
if (DNP_InputHandler.GetDown())
{
desiredDirection.y += -1;
}
if(desiredDirection.magnitude > 0.1f)
{
desiredDirection.Normalize();
}
velocity = Vector3.Lerp(velocity, (desiredDirection.z * transform.forward + desiredDirection.x * transform.right + desiredDirection.y * Vector3.up) * 7f, Time.deltaTime * 6f);
Vector3 position = transform.position;
Vector3 clampedPosition = new Vector3(Mathf.Clamp(position.x, -4f, 4f), Mathf.Clamp(position.y, 1f, 6f), Mathf.Clamp(position.z, -12f, 4f));
position = Vector3.Lerp(position, clampedPosition, Time.deltaTime * 15f) + velocity * Time.deltaTime;
//Apply:
transform.position = position;
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b25e2895a97944f4897ddd974ca8f465
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_Camera.cs
uploadId: 731065

View file

@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace DamageNumbersPro.Demo
{
public class DNP_Crosshair : MonoBehaviour
{
public static DNP_Crosshair instance;
public static bool targetEnemy;
public Color defaultColor = new Color(1, 1, 1, 0.6f);
public float defaultScale = 1f;
public Color enemyColor = new Color(1, 0.2f, 0.2f, 0.8f);
public float enemyScale = 1.15f;
Image image;
void Awake()
{
instance = this;
image = GetComponent<Image>();
}
void FixedUpdate()
{
if(Cursor.visible)
{
image.color = Color.Lerp(image.color, new Color(1,1,1,0), Time.fixedDeltaTime * 7f);
}
else if(targetEnemy)
{
image.color = Color.Lerp(image.color, enemyColor, Time.fixedDeltaTime * 7f);
float scale = Mathf.Lerp(transform.localScale.x, enemyScale, Time.fixedDeltaTime * 7f);
transform.localScale = new Vector3(scale, scale, 1);
}
else
{
image.color = Color.Lerp(image.color, defaultColor, Time.fixedDeltaTime * 7f);
float scale = Mathf.Lerp(transform.localScale.x, defaultScale, Time.fixedDeltaTime * 7f);
transform.localScale = new Vector3(scale, scale, 1);
}
}
public void HitTarget()
{
transform.localScale = new Vector3(1.7f, 1.7f, 1f);
image.color = Color.red;
}
public void HitWall()
{
transform.localScale = new Vector3(1.5f, 1.5f, 1f);
image.color = Color.white;
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f3fe9ffdc40969146b47bee23b033d94
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_Crosshair.cs
uploadId: 731065

View file

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DamageNumbersPro.Demo
{
public class DNP_CubeHighlight : MonoBehaviour
{
public string propertyName = "_Color";
public AnimationCurve propertyCurve;
public float destructionDelay = 0.2f;
Material mat;
int propertyID;
float startTime;
void Start()
{
startTime = Time.time;
propertyID = Shader.PropertyToID(propertyName);
MeshRenderer mr = GetComponent<MeshRenderer>();
mat = mr.material;
Destroy(gameObject, destructionDelay);
}
void FixedUpdate()
{
mat.SetColor(propertyID, new Color(1, 0, 0, propertyCurve.Evaluate(Time.time - startTime)));
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f8b4ebfc07248ee4fb72292fb0c53b02
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_CubeHighlight.cs
uploadId: 731065

View file

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DamageNumbersPro.Demo
{
public class DNP_CubeSpawner : MonoBehaviour
{
public float delay = 0.2f;
public GameObject cube;
void Start()
{
InvokeRepeating("SpawnCube", 0, delay);
}
void SpawnCube()
{
GameObject newCube = Instantiate<GameObject>(cube);
newCube.SetActive(true);
newCube.transform.SetParent(transform, true);
newCube.transform.localScale = Vector3.one;
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 665e15db3ef8c1c42a20aa835e671939
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_CubeSpawner.cs
uploadId: 731065

View file

@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DamageNumbersPro.Demo
{
public class DNP_CursorHint : MonoBehaviour
{
CanvasGroup cg;
void Start()
{
cg = GetComponent<CanvasGroup>();
}
void FixedUpdate()
{
if(Cursor.visible)
{
cg.alpha = Mathf.Max(cg.alpha - Time.deltaTime * 2f, 0);
}else
{
cg.alpha = Mathf.Min(cg.alpha + Time.deltaTime * 2f, 1);
}
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 51531b842be014949b85a0ba46c9a5b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_CursorHint.cs
uploadId: 731065

View file

@ -0,0 +1,170 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace DamageNumbersPro.Demo
{
public class DNP_DemoManager : MonoBehaviour
{
public static DNP_DemoManager instance;
Text currentPrefabText;
Text currentIndexText;
DamageNumber[] prefabs;
int currentIndex;
DNP_PrefabSettings currentSettings;
CanvasGroup fade;
bool fadeOut;
string loadScene;
void Awake()
{
//Reference Single Instance:
instance = this;
//Get All Prefabs:
Transform parent = GameObject.Find("Special").transform.Find("Prefabs/Damage Numbers");
prefabs = new DamageNumber[parent.childCount];
for(int n = 0; n < parent.childCount; n++)
{
prefabs[n] = parent.GetChild(n).GetComponent<DamageNumber>();
}
parent.gameObject.SetActive(false);
//Text Components:
Transform guiParent = GameObject.Find("Special").transform.Find("GUI");
currentPrefabText = guiParent.Find("Background/Current").GetComponent<Text>();
currentIndexText = guiParent.Find("Background/Index").GetComponent<Text>();
Transform fadeTransform = transform.Find("GUI/Fade");
if (fadeTransform != null)
{
fade = fadeTransform.GetComponent<CanvasGroup>();
}
//Reset Index:
currentIndex = 0;
UpdateCurrent();
#if !UNITY_EDITOR && UNITY_WEBGL
WebGLInput.captureAllKeyboardInput = true;
#endif
}
void Start()
{
if(fade != null)
{
fade.alpha = 1f;
}
}
void Update()
{
float scroll = DNP_InputHandler.GetMouseScroll();
if (scroll != 0 && (!Cursor.visible || DNP_Camera.instance == null))
{
if(scroll > 0.001f)
{
currentIndex--;
if(currentIndex < 0)
{
currentIndex = prefabs.Length - 1;
}
UpdateCurrent();
}
else if(scroll < 0.001f)
{
currentIndex++;
if(currentIndex > prefabs.Length - 1)
{
currentIndex = 0;
}
UpdateCurrent();
}
}
if(fade != null)
{
if(fadeOut)
{
fade.alpha += Time.deltaTime * 4;
if(fade.alpha >= 0.999f)
{
SceneManager.LoadScene(loadScene);
enabled = false;
}
return;
}
else
{
if(fade.alpha > 0)
{
fade.alpha -= Time.deltaTime * 3;
}
}
}
}
public void SwitchScene(string sceneName)
{
fadeOut = true;
loadScene = sceneName;
/*foreach(DamageNumber dn in FindObjectsOfType<DamageNumber>())
{
dn.DestroyDNP();
}*/
if(DNP_Camera.instance != null)
{
DNP_Camera.instance.enabled = false;
}
DNP_2DDemo demo2D = FindAnyObjectByType<DNP_2DDemo>();
if(demo2D)
{
demo2D.enabled = false;
}
if (DNP_GUI.instance != null)
{
DNP_GUI.instance.enabled = false;
}
}
void UpdateCurrent()
{
currentPrefabText.text = "➞ " + prefabs[currentIndex].name;
currentIndexText.text = (currentIndex + 1) + "/" + prefabs.Length;
currentSettings = prefabs[currentIndex].GetComponent<DNP_PrefabSettings>();
}
public DamageNumber GetCurrent()
{
return prefabs[currentIndex];
}
public DNP_PrefabSettings GetSettings()
{
if(currentSettings == null)
{
currentSettings = prefabs[currentIndex].gameObject.AddComponent<DNP_PrefabSettings>();
}
return currentSettings;
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 08fea8a978f90dc468841e0a806ab537
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_DemoManager.cs
uploadId: 731065

View file

@ -0,0 +1,65 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace DamageNumbersPro.Demo
{
public class DNP_FallingCube : MonoBehaviour
{
public float fallSpeed = 100f;
RectTransform rect;
Image image;
float currentSpeed;
bool isBroken;
void Start()
{
rect = GetComponent<RectTransform>();
image = GetComponent<Image>();
float speedAndSize = Random.value * 0.4f + 0.8f;
currentSpeed = fallSpeed * speedAndSize;
transform.localScale = Vector3.one * speedAndSize;
rect.anchoredPosition3D = new Vector3(Random.value * 560 - 280f, 260f, 0);
rect.localEulerAngles = new Vector3(0, 0, Random.value * 360f);
image.color = Color.Lerp(new Color(0.5f, 0.5f, 0.5f), image.color, speedAndSize - 0.2f);
}
void FixedUpdate()
{
rect.anchoredPosition += new Vector2(0, currentSpeed * Time.fixedDeltaTime);
if(isBroken)
{
currentSpeed = Mathf.Lerp(currentSpeed, 0, Time.fixedDeltaTime * 3f);
transform.localScale += Vector3.one * Time.fixedDeltaTime * 3f;
Color color = image.color;
color.a -= Time.fixedDeltaTime * 5f;
if(color.a <= 0)
{
Destroy(gameObject);
}
else
{
image.color = color;
}
}
if(rect.anchoredPosition.y < -270f)
{
Destroy(gameObject);
}
}
public void Break()
{
isBroken = true;
image.raycastTarget = false;
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9924040da2a5ee64ea65216464dd523a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_FallingCube.cs
uploadId: 731065

View file

@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DamageNumbersPro.Demo
{
public class DNP_GUI : MonoBehaviour
{
public static DNP_GUI instance;
float nextShotTime;
RectTransform canvasRect;
void Awake()
{
instance = this;
canvasRect = GetComponent<RectTransform>();
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
void Update()
{
HandleShooting();
}
void HandleShooting()
{
if (DNP_UIArea.CanSpawn() == false) return;
if (DNP_InputHandler.GetLeftClick())
{
Shoot();
nextShotTime = Time.time + 0.3f;
}
else if (DNP_InputHandler.GetRightHeld() && Time.time > nextShotTime)
{
Shoot();
nextShotTime = Time.time + 0.06f;
}
}
void Shoot()
{
//Select Damage Number:
DNP_PrefabSettings settings = DNP_DemoManager.instance.GetSettings();
DamageNumber prefab = DNP_DemoManager.instance.GetCurrent();
DNP_UIArea.OnSpawn();
//Number:
float number = 1 + Mathf.Pow(Random.value, 2.2f) * settings.numberRange;
if (prefab.digitSettings.decimals == 0)
{
number = Mathf.Floor(number);
}
//Get Parent:
RectTransform rectParent = DNP_UIArea.GetRect();
if (rectParent == null)
{
rectParent = canvasRect;
}
//Create Damage Number:
DamageNumber newDamageNumber = prefab.Spawn(Vector3.zero, number);
newDamageNumber.SetToMousePosition(rectParent, Camera.main);
if(rectParent != canvasRect)
{
newDamageNumber.enableFollowing = true;
newDamageNumber.followedTarget = rectParent;
}
//Apply Demo Settings:
settings.Apply(newDamageNumber);
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 39c0e5c321c3aac45b180c328fe74933
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_GUI.cs
uploadId: 731065

View file

@ -0,0 +1,247 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM && DNP_NewInputSystem
using UnityEngine.InputSystem;
namespace DamageNumbersPro.Demo
{
public static class DNP_InputHandler
{
//Directions:
public static bool GetRight()
{
if(Keyboard.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.D].isPressed || Keyboard.current[Key.RightArrow].isPressed;
}
}
public static bool GetLeft()
{
if (Keyboard.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.A].isPressed || Keyboard.current[Key.LeftArrow].isPressed;
}
}
public static bool GetBack()
{
if (Keyboard.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.S].isPressed || Keyboard.current[Key.DownArrow].isPressed;
}
}
public static bool GetForward()
{
if (Keyboard.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.W].isPressed || Keyboard.current[Key.UpArrow].isPressed;
}
}
//Vertical:
public static bool GetJump()
{
if (Keyboard.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.Space].isPressed;
}
}
public static bool GetUp()
{
if (Keyboard.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.E].isPressed || Keyboard.current[Key.Space].isPressed;
}
}
public static bool GetDown()
{
if (Keyboard.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.Q].isPressed || Keyboard.current[Key.LeftShift].isPressed;
}
}
//Mouse:
public static bool GetLeftClick()
{
if (Mouse.current == null)
{
return false;
}
else
{
return Mouse.current.leftButton.wasPressedThisFrame;
}
}
public static bool GetLeftHeld()
{
if (Mouse.current == null)
{
return false;
}
else
{
return Mouse.current.leftButton.isPressed;
}
}
public static bool GetRightClick()
{
if (Mouse.current == null)
{
return false;
}
else
{
return Mouse.current.rightButton.wasPressedThisFrame;
}
}
public static bool GetRightHeld()
{
if (Mouse.current == null)
{
return false;
}
else
{
return Mouse.current.rightButton.isPressed;
}
}
public static Vector2 GetMouseDelta()
{
if (Mouse.current == null)
{
return Vector2.zero;
}
else
{
return 100f * Mouse.current.delta.ReadValue() / (float) Screen.height;
}
}
public static float GetMouseScroll()
{
if (Mouse.current == null)
{
return 0;
}
else
{
return Mouse.current.scroll.ReadValue().y;
}
}
//Escape:
public static bool GetEscape()
{
if (Mouse.current == null)
{
return false;
}
else
{
return Keyboard.current[Key.Escape].wasPressedThisFrame;
}
}
}
}
#else
namespace DamageNumbersPro.Demo
{
public static class DNP_InputHandler
{
//Directions:
public static bool GetRight()
{
return Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow);
}
public static bool GetLeft()
{
return Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow);
}
public static bool GetBack()
{
return Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow);
}
public static bool GetForward()
{
return Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
}
//Vertical:
public static bool GetJump()
{
return Input.GetKey(KeyCode.Space);
}
public static bool GetUp()
{
return Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.Space);
}
public static bool GetDown()
{
return Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.LeftShift);
}
//Other:
public static bool GetLeftClick()
{
return Input.GetMouseButtonDown(0);
}
public static bool GetLeftHeld()
{
return Input.GetMouseButton(0);
}
public static bool GetRightClick()
{
return Input.GetMouseButtonDown(1);
}
public static bool GetRightHeld()
{
return Input.GetMouseButton(1);
}
public static Vector2 GetMouseDelta()
{
return new Vector2(Input.GetAxisRaw("Mouse X") * 2f, Input.GetAxisRaw("Mouse Y") * 2f);
}
public static float GetMouseScroll()
{
return Input.mouseScrollDelta.y;
}
//Escape:
public static bool GetEscape()
{
return Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.P) || Input.GetKeyDown(KeyCode.I);
}
}
}
#endif

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8132b2110a9847c48b639035c4baee1e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_InputHandler.cs
uploadId: 731065

View file

@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
namespace DamageNumbersPro.Demo
{
public class DNP_PrefabSettings : MonoBehaviour
{
[Header(" \nThis component is only for the demo scene.\nYou don't need it in your prefabs.\n ")]
public int damage = 1;
public int numberRange = 100;
public List<string> texts;
public List<TMP_FontAsset> fonts;
public bool randomColor;
public void Apply(DamageNumber target)
{
if (texts != null && texts.Count > 0)
{
int randomIndex = Random.Range(0, texts.Count);
target.leftText = texts[randomIndex];
if(fonts != null && randomIndex < fonts.Count)
{
target.SetFontMaterial(fonts[randomIndex]);
}
if(texts.Count > 1)
{
target.enableNumber = false;
}
}
if (randomColor)
{
target.SetColor(Color.HSVToRGB(Random.value, 0.5f, 1f));
}
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 83a59e7caad662244afa0070b2a31d01
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_PrefabSettings.cs
uploadId: 731065

View file

@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace DamageNumbersPro.Demo
{
public class DNP_SineFadeText : MonoBehaviour
{
public float fromAlpha = 0.5f;
public float toAlpha = 0.8f;
public float speed = 4f;
public float startTimeBonus = 0f;
Text text;
void Awake()
{
text = GetComponent<Text>();
}
void FixedUpdate()
{
Color color = text.color;
color.a = fromAlpha + (toAlpha - fromAlpha) * (Mathf.Sin(speed * Time.unscaledTime + startTimeBonus) * 0.5f + 0.5f);
text.color = color;
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 77d5f6b1db46fcb4da2523655a77c9ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_SineFadeText.cs
uploadId: 731065

View file

@ -0,0 +1,98 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DamageNumbersPro.Demo
{
public class DNP_Target : MonoBehaviour
{
public Vector3 movementOffset = new Vector3(0, 0, 0);
Material mat;
float defaultBrightness;
Coroutine hitRoutine;
Coroutine flipRoutine;
bool flipping;
Vector3 originalPosition;
void Start()
{
mat = GetComponent<MeshRenderer>().material;
defaultBrightness = mat.GetFloat("_Brightness");
flipping = false;
originalPosition = transform.position;
}
void Update()
{
//Move around.
transform.position = originalPosition + movementOffset * Mathf.Sin(Time.time);
}
public void Hit()
{
if(hitRoutine != null)
{
StopCoroutine(hitRoutine);
}
hitRoutine = StartCoroutine(HitCoroutine());
if (!flipping)
{
if (flipRoutine != null)
{
StopCoroutine(flipRoutine);
}
flipRoutine = StartCoroutine(FlipCoroutine());
}
}
IEnumerator HitCoroutine()
{
float brightness = 1f;
while( brightness < 3f)
{
//Glow up.
brightness = Mathf.Min(3, Mathf.Lerp(brightness, 3 + 0.1f, Time.deltaTime * 20f));
mat.SetFloat("_Brightness", brightness);
yield return null;
}
while(brightness > defaultBrightness)
{
//Glow down.
brightness = Mathf.Max(defaultBrightness, Mathf.Lerp(brightness, defaultBrightness - 0.1f, Time.deltaTime * 10f));
mat.SetFloat("_Brightness", brightness);
yield return null;
}
}
IEnumerator FlipCoroutine()
{
flipping = true;
float angle = 0f;
while(angle < 180f)
{
angle = Mathf.Min(180, Mathf.Lerp(angle, 190f, Time.deltaTime * 7f));
transform.eulerAngles = new Vector3(angle, 0, 0);
yield return null;
if(angle > 150f)
{
flipping = false;
}
}
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2a329446d6e56bf4e93cf3cc3cdbe0b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_Target.cs
uploadId: 731065

View file

@ -0,0 +1,54 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace DamageNumbersPro.Demo
{
public class DNP_UIArea : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public static DNP_UIArea currentArea;
public DNP_UIArea otherArea;
public bool noSpawnArea = false;
public bool breakCube = false;
RectTransform rectTransform;
void Start()
{
rectTransform = GetComponent<RectTransform>();
}
public void OnPointerEnter(PointerEventData eventData)
{
currentArea = this;
}
public void OnPointerExit(PointerEventData eventData)
{
if(currentArea == this)
{
currentArea = null;
}
}
public static RectTransform GetRect()
{
return currentArea != null ? (currentArea.otherArea == null ? currentArea.rectTransform : currentArea.otherArea.rectTransform) : null;
}
public static bool CanSpawn()
{
return currentArea == null || currentArea.noSpawnArea == false;
}
public static void OnSpawn()
{
if(currentArea != null && currentArea.breakCube)
{
DNP_FallingCube cube = currentArea.GetComponent<DNP_FallingCube>();
cube.Break();
}
}
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: db107ea44a70fc74581ec8390bba00be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_UIArea.cs
uploadId: 731065

View file

@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DNP_UIMove : MonoBehaviour
{
public Vector2 fromPosition;
public Vector2 toPosition;
public float frequency = 4f;
RectTransform rectTransform;
void Start()
{
rectTransform = GetComponent<RectTransform>();
}
void FixedUpdate()
{
rectTransform.anchoredPosition = Vector2.Lerp(fromPosition, toPosition, Mathf.Sin(Time.time * frequency) * 0.5f + 0.5f);
}
}

View file

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: bdea7f0af497f3046832e95200beb886
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 186447
packageName: Damage Numbers Pro
packageVersion: 4.47
assetPath: Assets/DamageNumbersPro/Demo/Scripts/DNP_UIMove.cs
uploadId: 731065