Example #1
0
    void StartAtk()
    {
        state = ActionState.atkbegin;

        if (target == null || target.IsDie())
        {
            state = ActionState.non;
            return;
        }
        if (Vector2.Distance(parent.transform.position, target.transform.position) > parent.GetAtkDis(target))
        {
            state = ActionState.move;
            return;
        }

        if (GameConst.CAMP_ATK[(int)target.camp, (int)parent.camp] == 0)
        {
            if (target.GetObjType() == InGameBaseObj.enObjType.equip)
            {
                InGameBaseEquip equip = (InGameBaseEquip)target;
                EquipData       e     = EquipSystem.GetInstance().RandEquipProperty(equip);
                InGameManager.GetInstance().inGamePlayerManager.AddEquip(e);
                MonoBehaviour.Destroy(equip.gameObject);
                parent.StopAction();
                return;
            }
            else if (target.GetObjType() == InGameBaseObj.enObjType.map)
            {
                InGameBaseMapObj mapobj = (InGameBaseMapObj)target;
                bool             isfin  = mapobj.HandleFuntion(parent);

                if (!isfin)
                {
                    Debug.Log("stop action");
                    parent.StopAction();
                    return;
                }
                Debug.Log("continue action");
            }
        }

        parent.SetAnimatorState(parent.GetAtkAnimator(), parent.GetAtkSpeed());
        atkTime = 0;

        parent.SetDir(target.transform.position.x - parent.transform.position.x);
    }