mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-20 20:32:23 +01:00
merloj: added Soldier onDeath UnityEvent
This commit is contained in:
parent
decfc8bfca
commit
2645aad5f4
@ -2,6 +2,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
|
||||||
public class Soldier : MonoBehaviour
|
public class Soldier : MonoBehaviour
|
||||||
{
|
{
|
||||||
@ -43,10 +44,8 @@ public class Soldier : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Ally,
|
Ally,
|
||||||
Enemy
|
Enemy
|
||||||
}
|
}
|
||||||
[SerializeField] private Soldier target;
|
[Header("Values")]
|
||||||
[SerializeField] private SoldierType enemyType;
|
|
||||||
[SerializeField] private SoldierType ourType;
|
|
||||||
[SerializeField] private float maxHealthPoints = 10;
|
[SerializeField] private float maxHealthPoints = 10;
|
||||||
[SerializeField] private float healthPoints = 1;
|
[SerializeField] private float healthPoints = 1;
|
||||||
[SerializeField] private float rangeAttack = 100;
|
[SerializeField] private float rangeAttack = 100;
|
||||||
@ -54,12 +53,20 @@ public class Soldier : MonoBehaviour
|
|||||||
[SerializeField] private float damageAttack = 1;
|
[SerializeField] private float damageAttack = 1;
|
||||||
[SerializeField] private int speedAttack = 1; // ticks between attacks
|
[SerializeField] private int speedAttack = 1; // ticks between attacks
|
||||||
[SerializeField] private int lastAttackTick = -1;
|
[SerializeField] private int lastAttackTick = -1;
|
||||||
|
[Header("References")]
|
||||||
[SerializeField] private TMP_Text nameText = null;
|
[SerializeField] private TMP_Text nameText = null;
|
||||||
[SerializeField] private TMP_Text healthPointsText = null;
|
[SerializeField] private TMP_Text healthPointsText = null;
|
||||||
|
[Header("Do-not-change-in-game values")]
|
||||||
|
[SerializeField] private Soldier target;
|
||||||
|
[SerializeField] private SoldierType enemyType;
|
||||||
|
[SerializeField] private SoldierType ourType;
|
||||||
|
|
||||||
[SerializeField] private Vector2Int movementDestination = Vector2Int.zero;
|
[SerializeField] private Vector2Int movementDestination = Vector2Int.zero;
|
||||||
|
|
||||||
|
// variables not visible in inspector
|
||||||
|
|
||||||
|
[HideInInspector] public UnityEvent onDeath = new UnityEvent();
|
||||||
|
|
||||||
public SoldierType TempGetOwnType()
|
public SoldierType TempGetOwnType()
|
||||||
{
|
{
|
||||||
return ourType;
|
return ourType;
|
||||||
@ -109,6 +116,7 @@ public class Soldier : MonoBehaviour
|
|||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
TickSystem.OnTick -= HandleTick;
|
TickSystem.OnTick -= HandleTick;
|
||||||
|
onDeath.Invoke();
|
||||||
|
|
||||||
Debug.Log("Soldier: " + ourType.ToString() + " has died", gameObject);
|
Debug.Log("Soldier: " + ourType.ToString() + " has died", gameObject);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user