Пример #1
0
    public override bool OnUpdate(Transform character)
    {
        switch (skillState)
        {
        case SkillState.init:
            Init(character);
            skillState = SkillState.waitForInput;
            break;

        case SkillState.waitForInput:
            if (final)
            {
                if (Check())
                {
                    foreach (var f in BattleFieldManager.GetInstance().floors)
                    {
                        f.Value.GetComponent <Floor>().FloorClicked -= Confirm;
                        f.Value.GetComponent <Floor>().FloorHovered -= Focus;
                        f.Value.GetComponent <Floor>().FloorExited  -= RecoverColor;
                    }
                    path = range.CreatePath(focus);
                    //角色取出忽略层
                    UnitManager.GetInstance().units.FindAll(u => u.playerNumber == character.GetComponent <Unit>().playerNumber).ForEach(u => BattleFieldManager.GetInstance().GetFloor(u.transform.position).gameObject.layer = 0);
                    UnitManager.GetInstance().units.ForEach(u => u.gameObject.layer = 0);
                    skillState = SkillState.confirm;
                }
                else
                {
                    final = false;
                }
            }
            break;

        case SkillState.confirm:
            movement.SetMovement(path, character);
            skillState = SkillState.applyEffect;
            break;

        case SkillState.applyEffect:
            if (movement.ExcuteMove())
            {
                range.Delete();
                //SecondAction
                character.GetComponent <CharacterAction>().SetSkill("SecondAction");

                return(true);
            }
            break;

        case SkillState.reset:

            return(true);
        }
        return(false);
    }
Пример #2
0
 public override void OnStateExit()
 {
     if (roleInfoPanel)
     {
         GameObject.Destroy(roleInfoPanel);
     }
     if (range != null)
     {
         range.Delete();
     }
     base.OnStateExit();
 }
Пример #3
0
 public override void OnStateExit()
 {
     GameObject.Find("Canvas").transform.Find("MenuButton").gameObject.SetActive(false);
     GameObject.Find("Canvas").transform.Find("DebugMenu").gameObject.SetActive(false);
     if (roleInfoPanel)
     {
         GameObject.Destroy(roleInfoPanel);
     }
     if (range != null)
     {
         range.Delete();
     }
     base.OnStateExit();
 }
Пример #4
0
    private void GetAttackMovePosition()
    {
        //get move range
        MoveRange moveRange = new MoveRange();

        moveRange.CreateMoveRange(aiUnit.transform);
        //find the nearest enemy
        getNeareatTarget(aiUnit);
        //find if the nearest enemy in attack range
        List <Vector3> enemyFloor = moveRange.enemyFloor;

        foreach (Vector3 v in enemyFloor)
        {
            enemyList.Add(getEnemyUnit(v));
        }

        if (enemyList.Contains(aiTarget))
        { //if the enemy is in attack range of aiUnit
            //choose a floor in moveRange and it is the neareast from aiUnit to aiTarget
            //get the four floors next aiTarget
            List <Vector3> nextFloors = getNextFloors(aiTarget.transform.position);

            //just leave these floors that could be reached in moveRange
            List <Vector3> canReachNextFloors = nextFloors.FindAll(nf => moveRange.rangeDic.ContainsKey(nf));

            //detect if there are other team mates in these floors
            List <Unit>    teamMatesList   = UnitManager.GetInstance().units.FindAll(p => p.playerNumber == aiUnit.playerNumber);
            List <Vector3> availableFloors = new List <Vector3>(canReachNextFloors);
            foreach (Unit u in teamMatesList)
            {
                foreach (Vector3 v in canReachNextFloors)
                {
                    if (u.transform.position == v)
                    {
                        availableFloors.Remove(v);
                    }
                }
            }

            if (availableFloors.Count > 0)
            {
                //find the nearest floor
                moveTarget = getNeareastFloor(aiUnit, availableFloors);
            }
            else
            {
                if (remoteAttackDetect())
                {
                    remoteAttack();
                }
                else
                {
                    moveMoreStep();
                }
            }
            //cancel render moveRange
            moveRange.Delete();
        }
        else
        {
            moveMoreStep();
        }
    }