Пример #1
0
    /*
     * IEnumerator Delay(int time)
     * {
     *  Debug.Log("5초 후에");
     *  yield return new WaitForSeconds(time);
     *  Debug.Log("5초 지남");
     * }
     */
    public void ProcessTurn()
    {
        if (_eCurTurn.Equals(eTURN.PLAYER))
        {
            if (_eCurAction.Equals(eACTION.ATTACK))
            {
                _player.Attack(_enemy);
            }
            else if (_eCurAction.Equals(eACTION.DEFEND))
            {
                _player.Defend();
            }
            else if (_eCurAction.Equals(eACTION.SKILL))
            {
                _player.Skill(_enemy);
            }
            else if (_eCurAction.Equals(eACTION.USEITEM))
            {
            }
            else if (_eCurAction.Equals(eACTION.RUN))
            {
            }
        }
        else if (_eCurTurn.Equals(eTURN.ENEMY))
        {
            int enemyAction = Random.Range(0, 3);

            if (enemyAction == 0)
            {
                _enemy.Attack(_player);
            }
            else if (enemyAction == 1)
            {
                _enemy.Defend();
            }
            else
            {
                _enemy.Skill(_player);
            }
        }

        CheckHP();

        changeTurn();
        UpdateUI();
        //Debug.Log(_eCurTurn);
    }
    public void Attack(BaseCharacter defender, Skill attackSkill)
    {
        GameEventsLogger.LogSeparator("Attack");
        List <string> tags = new List <string>();

        for (int i = 0; i < defender.Stats.Tags.Count; i++)
        {
            if (!tags.Contains(defender.Stats.Tags[i]))
            {
                tags.Add(defender.Stats.Tags[i]);
            }
        }
        //for (int i = 0; i < GameMaster.CurrentTags.Length; i++)
        //{
        //    if (!tags.Contains(GameMaster.CurrentTags[i]))
        //    {
        //        tags.Add(GameMaster.CurrentTags[i]);
        //    }
        //}
        int skillValue = Stats.SkillValue(attackSkill, tags.ToArray());
        int diceValue  = Dice.Roll();
        int totalValue = skillValue + diceValue;

        //if (stunt != null)
        //{
        //    totalValue += stunt.Bonus;
        //    GameEventsLogger.LogUsesStunt(this, stunt);
        //}
        if (Spin > 0)
        {
            totalValue += Spin;
            GameEventsLogger.LogUsesSpin(this, Spin);
            Spin = 0;
        }
        GameEventsLogger.LogAttack(this, defender, attackSkill, totalValue, skillValue, diceValue);
        int shifts = defender.Defend(this, attackSkill, totalValue);

        if (shifts > 0)
        {
            bool isTakenOut = defender.ReceiveDamage(shifts + Stats.Damage);
            if (isTakenOut)
            {
                Stats.ReceiveXP(defender.Stats.Cost);
            }
        }
    }