Ejemplo n.º 1
0
    public void ExecuteTurn()
    {
        //if we have nothing left exit, otherwise continue combos etc
        if (actions.Count == 0)
        {
            ResetAttack();
            //BC.MonsterIsAnimating = false; //this is called at the animation IEnumarators instead at the last frame
            DoneComboing = true;             //used to determine if we have completed all our actions
            return;
        }

        //check if an animation is occuring if so then return
        if (BC.MonsterIsAnimating)
        {
            return;
        }

        previousAction = actions[0];
        currentAction  = previousAction;
        targets        = currentAction.targets;
        //this will pause time for us so other monsters dont increment
        BC.MonsterIsAnimating = true;

        if (currentAction.targetArea == TargetArea.SINGLE)
        {
            StartCoroutine(BC.BeginAttack(currentAction.owner, currentAction.targets[0], 0.5f));
        }
        else
        {
            //AoE attacks wont animate in this case this is required
            BC.MonsterIsAnimating = false;
        }

        //Apply effects to player
        if (currentAction.drawType != DrawType.NONE)
        {
            //CheckDraw();
        }

        //Apply effect to targets
        foreach (GameObject target in targets)
        {
            // Attack Canceling?
            if (currentAction.isCanceling)
            {
                MonsterController targetsMonsterController = target.GetComponent <MonsterController>();
                //we have to make sure the target has an action queued up otherwise just do damage as normal
                if (targetsMonsterController.actions.Count >= 1)
                {
                    targetsMonsterController.RemoveActionAtIndex(0);
                    BC.SpawnBattleTextAboveWithString(target, "Attack Canceled!");
                }
            }

            // Stunning?
            // if we stun enemy add us as the owner otherwise increase the number
            if (currentAction.stunNumberOfTurns > 0)
            {
                Stun stun = target.GetComponent <Stun>();

                if (stun == null)
                {
                    target.AddComponent <Stun>();
                    stun       = target.GetComponent <Stun>();
                    stun.Owner = this.gameObject;
                }
                else
                {
                    Debug.Log("Stuns found adding " + currentAction.stunNumberOfTurns);
                    stun.AddTurns(currentAction.stunNumberOfTurns);
                }
            }

            //Are we increasing this monsters current armor?
            if (currentAction.block > 0)
            {
                ApplyBlock();
            }

            //Display only if damage was > 0
            if (currentAction.damage != 0)
            {
                target.GetComponent <MonsterController>().Damage(currentAction.damage);
                // moved text generation to Damage to control what is outputted
                //BC.SpawnBattleTextAbove(target, previousAction.damage);
            }
        }

        actions.RemoveAt(0);
        currentAction.Clear();
        ExecuteTurn();
    }