예제 #1
0
    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());
            }
        }
    }
예제 #2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
예제 #3
0
    /// <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);
    }