Finally bots can die. Player to. And another fixes.

This commit is contained in:
2022-05-17 00:21:53 +07:00
parent 06fdfc077c
commit 229c4490c4
15 changed files with 160 additions and 171 deletions

View File

@ -4,6 +4,7 @@ public class Character
public Team Team { get; set; }
public float LastTimeHit = 0;
public CharacterCondition Condition;
public TypeAI TypeAi;
public Character()
{

View File

@ -204,18 +204,20 @@ public class NPC : Agent, ICharacter
_condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - _condition.ArmourPoints * 0.5f)));
_condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
OnDamageReceived?.Invoke(damage, GetCharacter.Team);
if (_condition.HealthPoints < 0)
if (_condition.HealthPoints < 1)
{
OnDeathEvent?.Invoke(true);
MapManager.AddDeathAttributeToPoints(_moveController.PointStartID, _moveController.PointEndID,
_moveController.DistanceToGo, _moveController.RemainingDistance);
var pos = gameObject.transform.position;
var id = _moveController.PointStartID;
CharacterFactory.Instance.ReSpawn(this, ref pos, ref id);
Die();
}
}
private void Die()
{
OnDeathEvent?.Invoke(true);
MapManager.AddDeathAttributeToPoints(_moveController.PointStartID, _moveController.PointEndID,
_moveController.DistanceToGo, _moveController.RemainingDistance);
CharacterFactory.Instance.ReSpawn(this, gameObject);
}
public void ResetCharacter()
{
_condition.Reset();

View File

@ -27,8 +27,15 @@ public class Player : MonoBehaviour, ICharacter
Condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - Condition.ArmourPoints * 0.5f)));
Condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
if (Condition.HealthPoints < 0)
OnDeathEvent?.Invoke(true);
if (Condition.HealthPoints < 1)
Die();
}
private void Die()
{
print("dead");
OnDeathEvent?.Invoke(true);
CharacterFactory.Instance.ReSpawn(this, gameObject);
}
public void ResetCharacter()