public void Damage(int points) { _healthPoints -= points; _healthPoints = Mathf.Clamp(_healthPoints, 0, _maxHealthPoints); Character character = GetComponent <Character>(); FloatingTextFactory.Create(points.ToString(), transform.position + Vector3.up, new Color(1.0f, 0.2f, 0.2f)); if (character != null) { if (isDead) { character.Kill(); } else if (points > 0) { if (GameController.state == GameState.Exploration) { GameController.instance.StartCombat(character); } character.PushAction(new CharacterHurtAction()); } } }
void Awake() { if (instance == null) { instance = this; } }
/// <summary> /// Cast the ability. This creates an action that can be pushed to a character /// </summary> /// <returns>The action</returns> public virtual CharacterActionBase Cast() { FloatingTextFactory.Create(_label, caster.position + Vector3.up, new Color(1.0f, 1.0f, 1.0f), 24); caster.mana -= manaCost; if (GameController.state == GameState.Combat) { caster.remainingActions -= actionCost; } return(null); }