damage numbers
This commit is contained in:
parent
23380bde9b
commit
30af4cf09a
@ -1,6 +1,6 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &3926925622483940932
|
||||
--- !u!1 &3181908850916544684
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -8,9 +8,10 @@ GameObject:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 151968675300118951}
|
||||
- component: {fileID: 3711194229666358687}
|
||||
- component: {fileID: 7695890463420359245}
|
||||
- component: {fileID: 2142314076888331892}
|
||||
- component: {fileID: 122049154265232293}
|
||||
- component: {fileID: 6942678313689161613}
|
||||
- component: {fileID: 8657215674263572467}
|
||||
m_Layer: 5
|
||||
m_Name: Damage
|
||||
m_TagString: Untagged
|
||||
@ -18,14 +19,14 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &151968675300118951
|
||||
--- !u!224 &2142314076888331892
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3926925622483940932}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_GameObject: {fileID: 3181908850916544684}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@ -35,23 +36,23 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 2, y: 1}
|
||||
m_SizeDelta: {x: 6.04, y: 1}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &3711194229666358687
|
||||
--- !u!222 &122049154265232293
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3926925622483940932}
|
||||
m_GameObject: {fileID: 3181908850916544684}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &7695890463420359245
|
||||
--- !u!114 &6942678313689161613
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3926925622483940932}
|
||||
m_GameObject: {fileID: 3181908850916544684}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
@ -67,8 +68,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: 213
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: e783ea6501f7a4a27836c112a08ad05f, type: 2}
|
||||
m_sharedMaterial: {fileID: 4124135905796688568, guid: e783ea6501f7a4a27836c112a08ad05f, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@ -136,3 +137,18 @@ MonoBehaviour:
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!114 &8657215674263572467
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3181908850916544684}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5a5aa803630ff8c40850bf6e316ed173, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
textMesh: {fileID: 6942678313689161613}
|
||||
speed: 175
|
||||
moveSpeed: 1.5
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3271bbbbf5316d7499619a30d0167519
|
||||
guid: 174e0d007c667514aae5c50223ecec58
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
@ -119,157 +119,6 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &90702011
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 90702012}
|
||||
- component: {fileID: 90702014}
|
||||
- component: {fileID: 90702013}
|
||||
- component: {fileID: 90702015}
|
||||
m_Layer: 5
|
||||
m_Name: Text (TMP)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &90702012
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 90702011}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1999379258}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 6.04, y: 1}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &90702013
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 90702011}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: 213
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: e783ea6501f7a4a27836c112a08ad05f, type: 2}
|
||||
m_sharedMaterial: {fileID: 4124135905796688568, guid: e783ea6501f7a4a27836c112a08ad05f, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 1.4
|
||||
m_fontSizeBase: 1.4
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 256
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 0
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!222 &90702014
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 90702011}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &90702015
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 90702011}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5a5aa803630ff8c40850bf6e316ed173, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
textMesh: {fileID: 0}
|
||||
speed: 100
|
||||
--- !u!1 &104565599
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -468,7 +317,7 @@ GameObject:
|
||||
- component: {fileID: 298037254}
|
||||
- component: {fileID: 298037253}
|
||||
m_Layer: 6
|
||||
m_Name: GameObject
|
||||
m_Name: Enemy
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -487,6 +336,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
initHealth: 100
|
||||
canvas: {fileID: 1999379257}
|
||||
damagePrefab: {fileID: 3181908850916544684, guid: 174e0d007c667514aae5c50223ecec58, type: 3}
|
||||
--- !u!136 &298037254
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1459,6 +1310,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
initHealth: 100
|
||||
canvas: {fileID: 0}
|
||||
damagePrefab: {fileID: 0}
|
||||
--- !u!1 &832575517
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1519,7 +1372,6 @@ GameObject:
|
||||
- component: {fileID: 862052083}
|
||||
- component: {fileID: 862052082}
|
||||
- component: {fileID: 862052081}
|
||||
- component: {fileID: 862052084}
|
||||
m_Layer: 6
|
||||
m_Name: Capsule
|
||||
m_TagString: Untagged
|
||||
@ -1595,19 +1447,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 298037255}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &862052084
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 862052079}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d05ad440f2c88de4a91ec5e324740d7d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
initHealth: 100
|
||||
--- !u!1 &1060623000
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2725,6 +2564,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
initHealth: 100
|
||||
canvas: {fileID: 0}
|
||||
damagePrefab: {fileID: 0}
|
||||
--- !u!96 &1931938469
|
||||
TrailRenderer:
|
||||
serializedVersion: 3
|
||||
@ -3067,13 +2908,12 @@ RectTransform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 0.625, z: 1}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children:
|
||||
- {fileID: 90702012}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 298037255}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 2.75, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 2, y: 1}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1999379259
|
||||
|
@ -116,7 +116,7 @@ IEnumerator DealDamage()
|
||||
if (!damagedColliders.Contains(enemy))
|
||||
{
|
||||
print(enemy.gameObject.GetComponent<Vitals>().Health);
|
||||
enemy.gameObject.GetComponent<Vitals>().Health -= CalculateDamage(enemy);
|
||||
enemy.gameObject.GetComponent<Vitals>().Health = -CalculateDamage(enemy);
|
||||
damagedColliders.Add(enemy);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class Vitals : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float initHealth = 100;
|
||||
[SerializeField]
|
||||
private GameObject canvas;
|
||||
[SerializeField]
|
||||
private GameObject damagePrefab;
|
||||
|
||||
private float health;
|
||||
public float Health
|
||||
@ -14,7 +19,20 @@ public float Health
|
||||
}
|
||||
set
|
||||
{
|
||||
health = value;
|
||||
GameObject damageInstance = Instantiate(damagePrefab, canvas.transform);
|
||||
damageInstance.transform.localPosition = Vector3.zero;
|
||||
|
||||
damageInstance.GetComponent<TextMeshProUGUI>().SetText(Mathf.Abs((int)value).ToString());
|
||||
if (value < 0)
|
||||
{
|
||||
//hit
|
||||
}
|
||||
else
|
||||
{
|
||||
//heal
|
||||
}
|
||||
|
||||
health += value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@ public class DamageNumber : MonoBehaviour
|
||||
TextMeshProUGUI textMesh;
|
||||
[SerializeField]
|
||||
private float speed;
|
||||
[SerializeField]
|
||||
private float moveSpeed=10f;
|
||||
|
||||
private Camera mainCamera;
|
||||
|
||||
@ -19,24 +21,27 @@ void Start()
|
||||
speed += rnd.Next(-10, 10)/100f;
|
||||
mainCamera = Camera.main;
|
||||
|
||||
transform.LookAt(transform.position - mainCamera.transform.position);
|
||||
//StartCoroutine(Animate());
|
||||
StartCoroutine(Animate());
|
||||
}
|
||||
|
||||
IEnumerator Animate()
|
||||
{
|
||||
textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, 1);
|
||||
transform.LookAt(transform.position - mainCamera.transform.position);
|
||||
|
||||
yield return new WaitForSeconds(0.6f);
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
while (textMesh.color.a > 0)
|
||||
{
|
||||
float newAlpha = textMesh.color.a - Time.deltaTime * speed / 255f; // Reduce alpha in the float range
|
||||
newAlpha = Mathf.Clamp01(newAlpha); // Ensure it remains between 0 and 1
|
||||
textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, newAlpha); // Assign the new alpha value
|
||||
|
||||
print(textMesh.color.a);
|
||||
this.transform.position = new Vector3(transform.position.x, transform.position.y+moveSpeed*Time.deltaTime, transform.position.z);
|
||||
|
||||
transform.LookAt(transform.position - mainCamera.transform.position);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
@ -2716,7 +2716,7 @@ Material:
|
||||
- _OutlineSoftness: 0
|
||||
- _OutlineUVSpeedX: 0
|
||||
- _OutlineUVSpeedY: 0
|
||||
- _OutlineWidth: 0.2
|
||||
- _OutlineWidth: 0.5
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 0.85714287
|
||||
@ -2735,7 +2735,7 @@ Material:
|
||||
- _TextureHeight: 512
|
||||
- _TextureWidth: 512
|
||||
- _UnderlayDilate: 0
|
||||
- _UnderlayOffsetX: 0
|
||||
- _UnderlayOffsetX: 1
|
||||
- _UnderlayOffsetY: 0
|
||||
- _UnderlaySoftness: 0
|
||||
- _VertexOffsetX: 0
|
||||
|
Loading…
Reference in New Issue
Block a user