Add damage settings for hitbox class to be passed to enemy.damage
This commit is contained in:
parent
909f1e0ae7
commit
f7552b362e
@ -23,6 +23,7 @@ public class Gobler : Alive {
|
|||||||
[SerializeField] public float Health = 10f;
|
[SerializeField] public float Health = 10f;
|
||||||
[SerializeField] public float Energy = 10f;
|
[SerializeField] public float Energy = 10f;
|
||||||
|
|
||||||
|
protected FloatingTextSpawner TextPopUp;
|
||||||
|
|
||||||
|
|
||||||
private Player Player { get { return Player.Instance; } }
|
private Player Player { get { return Player.Instance; } }
|
||||||
@ -56,6 +57,8 @@ public class Gobler : Alive {
|
|||||||
Rigidbody = Owner.GetComponent<Rigidbody2D>();
|
Rigidbody = Owner.GetComponent<Rigidbody2D>();
|
||||||
Materials = Owner.GetComponentsInChildren<SpriteRenderer>().Select(x => x.material).ToList();
|
Materials = Owner.GetComponentsInChildren<SpriteRenderer>().Select(x => x.material).ToList();
|
||||||
|
|
||||||
|
TextPopUp = new FloatingTextSpawner(Owner.transform, 1);
|
||||||
|
|
||||||
SetState(State.GoToCrystal);
|
SetState(State.GoToCrystal);
|
||||||
EnemyManagers[Enemies.Gobler].UpdateTick += Update;
|
EnemyManagers[Enemies.Gobler].UpdateTick += Update;
|
||||||
EnemyManagers[Enemies.Gobler].GizmoTick += OnDrawGizmos;
|
EnemyManagers[Enemies.Gobler].GizmoTick += OnDrawGizmos;
|
||||||
@ -173,6 +176,7 @@ public class Gobler : Alive {
|
|||||||
|
|
||||||
case State.TakeDamage:
|
case State.TakeDamage:
|
||||||
PathAgent.isStopped = true;
|
PathAgent.isStopped = true;
|
||||||
|
TextPopUp.SpawnFloatingText(DamageTaken.ToString(), Color.red, 3);
|
||||||
Materials.ForEach(x => x.SetColor("_FlashColor", Color.white));
|
Materials.ForEach(x => x.SetColor("_FlashColor", Color.white));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class ClassBase {
|
|||||||
Player = player;
|
Player = player;
|
||||||
Animator = Player.Animator;
|
Animator = Player.Animator;
|
||||||
AttackAnimator = PlayerAttackAnimatorFactory.Instance;
|
AttackAnimator = PlayerAttackAnimatorFactory.Instance;
|
||||||
TextPopUp = new FloatingTextSpawner(player.transform);
|
TextPopUp = new FloatingTextSpawner(player.transform, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual public void Tick() {
|
virtual public void Tick() {
|
||||||
@ -98,13 +98,14 @@ public class ClassBase {
|
|||||||
|
|
||||||
|
|
||||||
protected Coroutine AttackCoroutine;
|
protected Coroutine AttackCoroutine;
|
||||||
protected void CreateHitBoxOffset(float centerOffset, float radius, float hitDelay, float hitDuration, int knockback) {
|
protected void CreateHitBoxOffset(float centerOffset, float radius, float hitDelay, float hitDuration, int damage, int knockback) {
|
||||||
if (AttackCoroutine != null)
|
if (AttackCoroutine != null)
|
||||||
Player.Instance.StopCoroutine(AttackCoroutine);
|
Player.Instance.StopCoroutine(AttackCoroutine);
|
||||||
var center = PlayerPos + Player.PrevDirection * centerOffset;
|
var center = PlayerPos + Player.PrevDirection * centerOffset;
|
||||||
hitDelay = 0;
|
hitDelay = 0;
|
||||||
HitBoxDraw.Knockback = knockback;
|
HitBoxDraw.Knockback = knockback;
|
||||||
HitBoxDraw.Directional = centerOffset != 0;
|
HitBoxDraw.Directional = centerOffset != 0;
|
||||||
|
HitBoxDraw.Damage = damage;
|
||||||
AttackCoroutine = Player.Instance.StartCoroutine(CreateHitBoxHelper(center, radius, hitDelay, hitDuration));
|
AttackCoroutine = Player.Instance.StartCoroutine(CreateHitBoxHelper(center, radius, hitDelay, hitDuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,5 +135,6 @@ public class ClassBase {
|
|||||||
public float Radius;
|
public float Radius;
|
||||||
public Color Color;
|
public Color Color;
|
||||||
public int Knockback;
|
public int Knockback;
|
||||||
|
public int Damage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,9 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
public float Cooldown;
|
public float Cooldown;
|
||||||
public bool TimesUp;
|
public bool TimesUp;
|
||||||
|
|
||||||
|
public int DamageMultiplier = 1;
|
||||||
|
public int DamageOffset = 0;
|
||||||
|
|
||||||
|
|
||||||
public VfxHandlerBase VfxKineticSurgeHandler { get { return Player.VfxKineticSurgeHandler; } }
|
public VfxHandlerBase VfxKineticSurgeHandler { get { return Player.VfxKineticSurgeHandler; } }
|
||||||
|
|
||||||
@ -74,9 +77,9 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
AttackAnimator?.MeleeResetKineticCharge();
|
AttackAnimator?.MeleeResetKineticCharge();
|
||||||
AttackAnimator?.MeleeKineticSurge();
|
AttackAnimator?.MeleeKineticSurge();
|
||||||
AnimationToPlay = "Attack1";
|
AnimationToPlay = "Attack1";
|
||||||
TextPopUp.SpawnFloatingText("KineticSurge", Color.red, 3);
|
//TextPopUp.SpawnFloatingText("KineticSurge", Color.red, 3);
|
||||||
AllowBladeVortex = ComboTimeElapsed <= 0.1f;
|
AllowBladeVortex = ComboTimeElapsed <= 0.1f;
|
||||||
CreateHitBoxOffset(0, 5, 0.1f, 0.1f, 20);
|
CreateHitBoxOffset(0, 5, 0.1f, 0.1f, (10 * DamageMultiplier) + DamageOffset, 20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@ -207,7 +210,7 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
Player.MoveSpeedDampener = (state == AttackState.None) ? 1 : 1 / decreasedSpeed;
|
Player.MoveSpeedDampener = (state == AttackState.None) ? 1 : 1 / decreasedSpeed;
|
||||||
if (state == AttackState.None) return;
|
if (state == AttackState.None) return;
|
||||||
Cooldown = cooldown;
|
Cooldown = cooldown;
|
||||||
TextPopUp.SpawnFloatingText(state.ToString(), Color.red, 3);
|
//TextPopUp.SpawnFloatingText(state.ToString(), Color.red, 3);
|
||||||
ComboResetTime = resetTime;
|
ComboResetTime = resetTime;
|
||||||
LastComboTime = Time.time;
|
LastComboTime = Time.time;
|
||||||
|
|
||||||
@ -224,7 +227,7 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
case AttackState.Shockwave:
|
case AttackState.Shockwave:
|
||||||
AnimationToPlay = "Shockwave";
|
AnimationToPlay = "Shockwave";
|
||||||
Player.VfxShockwavePool.Get(Player.transform.position);
|
Player.VfxShockwavePool.Get(Player.transform.position);
|
||||||
CreateHitBoxOffset(0, 5, 0.1f, 0.1f, 20);
|
CreateHitBoxOffset(0, 5, 0.1f, 0.1f, (20 * DamageMultiplier) + DamageOffset, 20);
|
||||||
Player.IsJumping = false;
|
Player.IsJumping = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -234,17 +237,17 @@ public class MeleeFighterClass : ClassBase {
|
|||||||
|
|
||||||
case AttackState.BasicAttack1:
|
case AttackState.BasicAttack1:
|
||||||
AnimationToPlay = "Attack1";
|
AnimationToPlay = "Attack1";
|
||||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, 10);
|
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, (2 * DamageMultiplier) + DamageOffset, 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AttackState.BasicAttack2:
|
case AttackState.BasicAttack2:
|
||||||
AnimationToPlay = "Attack2";
|
AnimationToPlay = "Attack2";
|
||||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, 15);
|
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, (4 * DamageMultiplier) + DamageOffset, 15);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AttackState.BasicAttack3:
|
case AttackState.BasicAttack3:
|
||||||
AnimationToPlay = "Attack1";
|
AnimationToPlay = "Attack1";
|
||||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, 20);
|
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, (6 * DamageMultiplier) + DamageOffset, 20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AttackState.KineticSurgeRelease:
|
case AttackState.KineticSurgeRelease:
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class PlayerAttackAnimatorFactory : MonoBehaviour {
|
|||||||
public void Awake() {
|
public void Awake() {
|
||||||
Instance = this;
|
Instance = this;
|
||||||
Player = GetComponentInParent<Player>();
|
Player = GetComponentInParent<Player>();
|
||||||
TextPopUp = new FloatingTextSpawner(this.transform);
|
TextPopUp = new FloatingTextSpawner(this.transform, 0.5f);
|
||||||
|
|
||||||
BuildMeleeAnimationClips();
|
BuildMeleeAnimationClips();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -204,7 +204,7 @@ public class Player : MonoBehaviour {
|
|||||||
|
|
||||||
GameObject parent = hit.transform.parent?.gameObject;
|
GameObject parent = hit.transform.parent?.gameObject;
|
||||||
Vector2 knockbakDirection = ActiveClass.HitBoxDraw.Directional ? PrevDirection : parent.transform.position - transform.position;
|
Vector2 knockbakDirection = ActiveClass.HitBoxDraw.Directional ? PrevDirection : parent.transform.position - transform.position;
|
||||||
EnemySpawnerData.EnemyMap[parent].Damage(0, knockbakDirection, ActiveClass.HitBoxDraw.Knockback);
|
EnemySpawnerData.EnemyMap[parent].Damage(ActiveClass.HitBoxDraw.Damage, knockbakDirection, ActiveClass.HitBoxDraw.Knockback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,12 @@ using UnityEngine;
|
|||||||
public class FloatingTextSpawner {
|
public class FloatingTextSpawner {
|
||||||
private static GameObject GameObjectContainer = new GameObject($"Floating Text Container");
|
private static GameObject GameObjectContainer = new GameObject($"Floating Text Container");
|
||||||
private Transform Transform;
|
private Transform Transform;
|
||||||
|
private float YOffset;
|
||||||
private List<Transform> TextList = new List<Transform>();
|
private List<Transform> TextList = new List<Transform>();
|
||||||
|
|
||||||
public FloatingTextSpawner(Transform transform) {
|
public FloatingTextSpawner(Transform transform, float yOffset) {
|
||||||
Transform = transform;
|
Transform = transform;
|
||||||
|
YOffset = yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SpawnFloatingText(string message, Color color, float duration = 1.5f) {
|
public void SpawnFloatingText(string message, Color color, float duration = 1.5f) {
|
||||||
@ -33,7 +35,7 @@ public class FloatingTextSpawner {
|
|||||||
renderer.sortingLayerName = "UI";
|
renderer.sortingLayerName = "UI";
|
||||||
renderer.sortingOrder = 0;
|
renderer.sortingOrder = 0;
|
||||||
|
|
||||||
textObj.AddComponent<FloatingText>().Init(duration, ref TextList);
|
textObj.AddComponent<FloatingText>().Init(duration, ref TextList, YOffset);
|
||||||
UnityEngine.Object.Instantiate(textObj, GameObjectContainer.transform);
|
UnityEngine.Object.Instantiate(textObj, GameObjectContainer.transform);
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
}
|
}
|
||||||
@ -47,7 +49,7 @@ public class FloatingText : MonoBehaviour {
|
|||||||
private TextMesh textMesh;
|
private TextMesh textMesh;
|
||||||
|
|
||||||
|
|
||||||
public void Init(float duration, ref List<Transform> textList) {
|
public void Init(float duration, ref List<Transform> textList, float yOffset) {
|
||||||
try {
|
try {
|
||||||
lifetime = duration;
|
lifetime = duration;
|
||||||
textMesh = GetComponent<TextMesh>();
|
textMesh = GetComponent<TextMesh>();
|
||||||
@ -57,7 +59,7 @@ public class FloatingText : MonoBehaviour {
|
|||||||
if (textList[i] == null)
|
if (textList[i] == null)
|
||||||
textList.RemoveAt(i);
|
textList.RemoveAt(i);
|
||||||
else
|
else
|
||||||
textList[i].position += Vector3.up * 0.5f;
|
textList[i].position += Vector3.up * yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
textList.Add(this.transform);
|
textList.Add(this.transform);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user