Beispiel #1
0
    private void TurnGoOn()
    {
        if (actor_curTurn.group == ActorMono.Group.monster)
        {
            return;
        }

        // 处于UI交互状态 或 动画状态
        if (CombatManager.instance.isCombating || UIManager.instance.IsAtUIArea || UIManager.instance.IsHandUsing || GameManager.instance.gameInputMode == GameManager.InputMode.animation)
        {
            UIManager.instance.InActivePath();
            return;
        }

        // 不处于UI交互状态

        // 路径搜索与显示
        do
        {
            if (!UIManager.instance.mouse.IsCellChanged)
            {
                break;
            }
            if (actor_curTurn.IsMoving)
            {
                break;
            }
            Vector3 targetPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            targetPos.z = 0;

            path_list = PathFinderManager.instance.SearchPathTo(actor_curTurn.WorldPos, targetPos);

            UIManager.instance.ShowPath(path_list);
        }while (false);


        // 玩家不处于移动状态 而且按下左键 便开始移动
        if (Input.GetKeyDown(KeyCode.Mouse0) && !actor_curTurn.IsMoving)
        {
            actor_curTurn.StartMoveByList(path_list);
        }

        // 移动状态下取消移动
        if (actor_curTurn.IsMoving)
        {
            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                actor_curTurn.stopMoveByList = true;
            }
            return;
        }
    }
Beispiel #2
0
    IEnumerator TurnGoOn()
    {
        if (target == null)
        {
            BattleManager.instance.OnTurnEnd();
            StopAllCoroutines();
        }

        // 确定行动
        if (actor.healPoint <= actor.healPoint_max * 0.4f)
        {
            actionMode = ActionMode.dfend;
        }
        else
        {
            int r = Random.Range(0, 2);
            if (r == 0)
            {
                actionMode = ActionMode.attack;
            }
            if (r == 1)
            {
                actionMode = ActionMode.attack_defend;
            }
        }

        bool ifFocus = (Random.Range(0, 100)) < (15f + (100f * (actor.healPoint / actor.healPoint_max))) ? true : false;

        if (ifFocus)
        {
            if (actionMode == ActionMode.attack)
            {
                actor.FocusCard(focusCard_attack);
            }

            if (actionMode == ActionMode.attack_defend || actionMode == ActionMode.dfend)
            {
                actor.FocusCard(focusCard_defend);
            }
            actor.StartDoAction("专注", null, false);
            yield return(new WaitForSeconds(0.5f));
        }


        for (int i = 0; i < action_count; i++)
        {
            // 一次攻击



            // 移动
            if (actionMode == ActionMode.attack || actionMode == ActionMode.attack_defend)
            {
                // 确定要发动的卡牌
                //Card card = card_intention_cast_list[index];
                //index++;
                //if (index >= card_intention_cast_list.Count)
                //{
                //    index = 0;
                //}

                Card card = castCard;

                // 是否需要移动
                Vector2 dirWithDis = target.GetComponent <ActorMono>().WorldPos - actor.WorldPos;
                if (!card.IfCanCast(actor, target.GetComponent <ActorMono>()))
                {
                    // 确定路径
                    var path_list = PathFinderManager.instance.SearchPathLinkTo(actor.WorldPos, target.GetComponent <ActorMono>().WorldPos);
                    //path_list.RemoveAt(path_list.Count - 1);

                    actor.StartMoveByList(path_list);

                    while (actor.IsMoving)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
                // 距离不够 结束回合
                dirWithDis = target.GetComponent <ActorMono>().WorldPos - actor.WorldPos;
                if (!card.IfCanCast(actor, target.GetComponent <ActorMono>()))
                {
                    break;
                }
                // 移动完毕

                // 释放卡牌
                UIManager.instance.UpdateActorFloatUI(gameObject, card.cardName, 2);
                CombatManager.instance.StartCombat(actor, card, target.GetComponent <ActorMono>());
            }
            if (actionMode == ActionMode.dfend)
            {
                List <Vector3>    path_list      = new List <Vector3>();
                List <Vector3Int> targetPos_list = new List <Vector3Int>();
                int count = 0;
                while ((path_list == null || path_list.Count == 0) && count < 10)
                {
                    count++;

                    int        tileCount = (int)(actor.movePoint / BattleManager.instance.moveCost_varCell);
                    int        c         = Random.Range(0, tileCount + 1);
                    Vector2Int tilePos   = new Vector2Int(c, tileCount - c);
                    Vector3Int pos       = PathFinderManager.instance.grid.WorldToCell(actor.WorldPos);

                    int x = target.GetComponent <ActorMono>().WorldPos.x > actor.WorldPos.x ? -1 : 1;
                    int y = target.GetComponent <ActorMono>().WorldPos.y > actor.WorldPos.y ? -1 : 1;

                    pos += new Vector3Int(x * tilePos.x, y * tilePos.y, 0);

                    if (targetPos_list.Contains(pos))
                    {
                        continue;
                    }
                    else
                    {
                        targetPos_list.Add(pos);
                    }

                    Vector3 targetPos = PathFinderManager.instance.grid.GetCellCenterWorld(pos);

                    path_list = PathFinderManager.instance.SearchPathTo(actor.WorldPos, targetPos);
                }

                actor.StartMoveByList(path_list);

                while (actor.IsMoving)
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
            // 专注卡牌
            // 确定是否要专注

            while (CombatManager.instance.isCombating)
            {
                yield return(new WaitForEndOfFrame());
            }
        }

        while (CombatManager.instance.isCombating)
        {
            yield return(new WaitForEndOfFrame());
        }

        yield return(new WaitForSeconds(0.6f));

        BattleManager.instance.OnTurnEnd();
    }