Exemplo n.º 1
0
    public bool IsAttacked(UnitProxy oppUnit, bool useAttack = true)
    {
        Debug.Log("IsAttacked");
        if (useAttack)
        {
            oppUnit.GetData().GetTurnActions().Attack();
        }
        PanelControllerNew.SwitchChar(oppUnit);

        //Damage the unit

        /*
         * Trigger the opponent's attack trigger here
         */

        Vector3Int animStart = oppUnit.GetPosition();
        Vector3Int animEnd   = GetPosition();

        Debug.Log("animStart: " + animStart.ToString());
        Debug.Log("animEnd: " + animEnd.ToString());

        Vector3Int diff = animEnd - animStart;

        if (_data.GetAegis())
        {
            Debug.Log("Aegis!");
            //_data.SetAegis(false);
            StartCoroutine(AttackAnim(oppUnit, oppUnit.gameObject.transform.GetChild(0).GetComponent <Animator>(),
                                      oppUnit.gameObject.transform, diff, "", useAttack));
            //LostAegisAnim();
            SetAegis(false, AnimationInteractionController.ATK_WAIT);
            return(false);
        }
        Debug.Log("No Aegis");

        StartCoroutine(AttackAnim(oppUnit, oppUnit.gameObject.transform.GetChild(0).GetComponent <Animator>(),
                                  oppUnit.gameObject.transform, diff, "-" + oppUnit.GetData().GetAttack().ToString(), useAttack));

        GetData().IsAttacked(oppUnit.GetData().GetAttack());
        if (GetData().IsDead())
        {
            if (oppUnit == this)
            {
                BoardProxy.instance.GiveLowestCharLvl(this);
            }
            else
            {
                oppUnit.AddLevel();
            }
            return(true);
        }
        return(false);
    }