Ejemplo n.º 1
0
        public static IEnumerator SelectSkillApplyPoint(BattleData battleData, Direction originalDirection)
        {
            Direction beforeDirection = originalDirection;
            Unit      selectedUnit    = battleData.selectedUnitObject.GetComponent <Unit>();

            while (battleData.currentState == CurrentState.SelectSkillApplyPoint)
            {
                Vector2 selectedUnitPos = battleData.selectedUnitObject.GetComponent <Unit>().GetPosition();

                List <GameObject> activeRange   = new List <GameObject>();
                Skill             selectedSkill = battleData.SelectedSkill;
                activeRange = battleData.tileManager.GetTilesInRange(selectedSkill.GetFirstRangeForm(),
                                                                     selectedUnitPos,
                                                                     selectedSkill.GetFirstMinReach(),
                                                                     selectedSkill.GetFirstMaxReach(),
                                                                     battleData.selectedUnitObject.GetComponent <Unit>().GetDirection());

                Tile selectedTile = UdongNoodle.FindEnemyTile(activeRange, battleData.selectedUnitObject);

                if (selectedTile == null)
                {
                    // 아무것도 할 게 없을 경우 휴식
                    battleData.currentState = CurrentState.RestAndRecover;
                    yield return(battleData.battleManager.StartCoroutine(RestAndRecover.Run(battleData)));

                    yield break;
                }
                // activeRange[Random.Range(0, activeRange.Count)].GetComponent<Tile>();

                battleData.selectedTilePosition = selectedTile.GetTilePos();

                // 타겟팅 스킬을 타겟이 없는 장소에 지정했을 경우 적용되지 않도록 예외처리 필요 - 대부분의 스킬은 논타겟팅. 추후 보강.

                BattleManager battleManager = battleData.battleManager;
                battleData.currentState = CurrentState.CheckApplyOrChain;

                List <GameObject> tilesInSkillRange = GetTilesInSkillRange(battleData, selectedTile);

                yield return(SkillAndChainStates.ApplyChain(battleData, tilesInSkillRange));

                FocusUnit(battleData.SelectedUnit);
                battleData.currentState = CurrentState.FocusToUnit;

                yield return(battleManager.StartCoroutine(SkillAndChainStates.CheckApplyOrChain(battleData, battleData.SelectedTile, originalDirection)));
            }
        }
Ejemplo n.º 2
0
        public static IEnumerator SelectSkillApplyDirection(BattleData battleData, Direction originalDirection)
        {
            Direction         beforeDirection = originalDirection;
            List <GameObject> selectedTiles   = new List <GameObject>();
            Unit  selectedUnit  = battleData.selectedUnitObject.GetComponent <Unit>();
            Skill selectedSkill = battleData.SelectedSkill;

            selectedTiles = battleData.tileManager.GetTilesInRange(selectedSkill.GetSecondRangeForm(),
                                                                   selectedUnit.GetPosition(),
                                                                   selectedSkill.GetSecondMinReach(),
                                                                   selectedSkill.GetSecondMaxReach(),
                                                                   selectedUnit.GetDirection());

            if (battleData.isSelectedTileByUser)
            {
                BattleManager battleManager = battleData.battleManager;
                battleData.currentState = CurrentState.CheckApplyOrChain;
                yield return(battleManager.StartCoroutine(SkillAndChainStates.CheckApplyOrChain(battleData, battleData.SelectedUnitTile, originalDirection)));
            }
        }
Ejemplo n.º 3
0
    public static IEnumerator FocusToUnit(BattleData battleData)
    {
        while (battleData.currentState == CurrentState.FocusToUnit)
        {
            BattleManager battleManager = battleData.battleManager;
            battleData.retreatUnits = battleData.unitManager.GetRetreatUnits();
            battleData.deadUnits    = battleData.unitManager.GetDeadUnits();

            yield return(battleManager.StartCoroutine(DestroyRetreatUnits(battleData)));

            yield return(battleManager.StartCoroutine(DestroyDeadUnits(battleData)));

            if (battleData.retreatUnits.Contains(battleData.selectedUnitObject))
            {
                yield return(battleManager.StartCoroutine(FadeOutEffect(battleData.selectedUnitObject, 1)));

                battleData.unitManager.DeleteRetreatUnit(battleData.selectedUnitObject);
                Debug.Log("SelectedUnit retreats");
                Destroy(battleData.selectedUnitObject);
                yield break;
            }

            if (battleData.deadUnits.Contains(battleData.selectedUnitObject))
            {
                battleData.selectedUnitObject.GetComponent <SpriteRenderer>().color = Color.red;
                yield return(battleManager.StartCoroutine(FadeOutEffect(battleData.selectedUnitObject, 1)));

                battleData.unitManager.DeleteDeadUnit(battleData.selectedUnitObject);
                Debug.Log("SelectedUnit is dead");
                Destroy(battleData.selectedUnitObject);
                yield break;
            }

            // battleData.unitManager.MakeDeadUnitInfo(); // 문제없이 잘 돌아가면 삭제해도 무방.

            Camera.main.transform.position = new Vector3(
                battleData.selectedUnitObject.transform.position.x,
                battleData.selectedUnitObject.transform.position.y,
                -10);

            battleData.uiManager.SetSelectedUnitViewerUI(battleData.selectedUnitObject);

            battleData.uiManager.SetCommandUIName(battleData.selectedUnitObject);
            CheckStandbyPossible(battleData);
            CheckMovePossible(battleData);
            CheckSkillPossible(battleData);

            battleData.uiManager.UpdateApBarUI(battleData, battleData.unitManager.GetAllUnits());

            battleData.command = ActionCommand.Waiting;
            while (battleData.command == ActionCommand.Waiting)
            {
                yield return(null);
            }

            if (battleData.command == ActionCommand.Move)
            {
                battleData.command      = ActionCommand.Waiting;
                battleData.currentState = CurrentState.SelectMovingPoint;
                yield return(battleManager.StartCoroutine(MoveStates.SelectMovingPointState(battleData)));
            }
            else if (battleData.command == ActionCommand.Attack)
            {
                battleData.command      = ActionCommand.Waiting;
                battleData.currentState = CurrentState.SelectSkill;
                yield return(battleManager.StartCoroutine(SkillAndChainStates.SelectSkillState(battleData)));
            }
            else if (battleData.command == ActionCommand.Rest)
            {
                battleData.command      = ActionCommand.Waiting;
                battleData.currentState = CurrentState.RestAndRecover;
                yield return(battleManager.StartCoroutine(RestAndRecover.Run(battleData)));
            }
            else if (battleData.command == ActionCommand.Standby)
            {
                battleData.command      = ActionCommand.Waiting;
                battleData.currentState = CurrentState.Standby;
                yield return(battleManager.StartCoroutine(Standby()));
            }
        }
        yield return(null);
    }