Exemple #1
0
 private void Start()
 {
     move = GetComponent <NPCMove>();
     aim  = GetComponent <NPCAim>();
     talk = GetComponent <NPCTalk>();
     anim = GetComponentInChildren <Animator>();
 }
Exemple #2
0
 public void OnClickStonePickUp()
 {
     for (int i = 0; i < variable.selectnpc_count; i++)
     {
         Debug.Log(variable.selectnpc [i].name);
         npcmove = variable.selectnpc[i].GetComponent <NPCMove>();
         npcmove.commandstate = NPCMove.CommandState.STONE_PICKING;
     }
 }
Exemple #3
0
 public void OnClickHitAnimall()
 {
     for (int i = 0; i < variable.selectnpc_count; i++)
     {
         Debug.Log(variable.selectnpc [i].name);
         npcmove = variable.selectnpc[i].GetComponent <NPCMove>();
         npcmove.commandstate = NPCMove.CommandState.HIT_SMALL_ANIMALL;
     }
 }
Exemple #4
0
    void CheckMouse()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Tile")
                {
                    Tile t = hit.collider.GetComponent <Tile>();

                    if (t.selectable)
                    {
                        //todo: move target
                        anim.Play("Run");

                        MoveToTile(t);
                    }
                }
                if (hit.collider.tag == "NPC")
                {
                    //GameObject Target = hit.collider.GetComponent;

                    NPCMove npc = hit.collider.GetComponent <NPCMove>();

                    Debug.Log(currentWeapon);
                    if (Physics.Raycast(transform.position, (npc.transform.position - transform.position), out hit, 10000))
                    {
                        if (!npc.killed && hit.transform.tag != "Wall" && !npc.GetComponent <TacticsMove>().killed)
                        {
                            //npc.Kill();
                            npc.Shoot(transform.position, weapons[currentWeapon]);

                            transform.LookAt(npc.transform);
                            transform.Rotate(transform.rotation.x, transform.rotation.y, 0);

                            anim.Play(weapons[currentWeapon].GetComponent <WeaponStats>().shootAnim);


                            moveCount++;
                        }
                    }
                    // if(moveCount == moves){
                    //  moveCount = 0;
                    //  anim.Play(weapons[currentWeapon].GetComponent<WeaponStats>().idleAnim);

                    //  TurnManager.EndTurn();//todo: This will end the unit's turn when it is done moving, needs to change when combat is added
                    // }
                    //Destroy(npc);
                }
            }
        }
    }
Exemple #5
0
    private void Start()
    {
        targeting = GetComponent <ObjectTargeting>();
        aim       = GetComponent <NPCAim>();
        shoot     = GetComponent <NPCShoot>();
        move      = GetComponent <NPCMove>();
        hp        = GetComponent <Health>();
        talk      = GetComponent <NPCTalk>();

        hp.SetHealth(hp.GetMaxHealth());
        StartAI();
    }
    // Use this for initialization
    void Start()
    {
        GameObject.Find ("sim").GetComponent<BoxCollider2D>().enabled = false;
        GameObject.Find ("nao").GetComponent<BoxCollider2D>().enabled = false;

        timer[3] = 5f;
        start = false;
        cmt_plr = GameObject.FindGameObjectWithTag("Player").GetComponent<ComunicationAndStatusPlayer>();
        plr_mov = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMove>();
        npc_mov = GameObject.Find("NPCF").GetComponent<NPCMove>();
        cam = GameObject.Find ("Main Camera").GetComponent<CamControl> ();
        cam_size = GameObject.Find ("Main Camera").GetComponent<Camera> ();
    }
    // Use this for initialization
    void Start()
    {
        time = 0;

        player = GameObject.Find("First Person Controller");
        cam = GameObject.Find("Main Camera");
        hud = GameObject.Find("HUD");
        bridgeLight = GameObject.Find("BridgeLight");

        jumpScare = (AudioClip) Instantiate(Resources.Load("JumpScareSounds/Scary_Shack") as AudioClip);

        player.GetComponent<CharacterMotor>().enabled = false;
        player.GetComponent<MouseLook>().enabled = false;
        cam.GetComponent<MouseLook>().enabled = false;
        player.GetComponentInChildren<Interaction>().stopMove = true;

        defaultFOV = cam.camera.fieldOfView;
        speedMod = GetComponent<NPCMove>();
    }
Exemple #8
0
    private void SelectTarget()
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, 100))
        {
            NPCMove target = hit.collider.GetComponentInParent <NPCMove>(); // TODO might change this in the future
            if (target != null)
            {
                if (Input.GetMouseButtonUp(0) && indicator != null)
                {
                    // Move our indicator
                    Debug.Log("selected");
                    indicator.MoveIndicator(target.gameObject);
                }
            }
        }
    }
 public static void InitNPCTurn()
 {
     Debug.Log("TurnoNPC");
     GameObject[] units = GameObject.FindGameObjectsWithTag("NPC");
     Debug.Log(units.Length);
     countMovs = units.Length;
     countAtks = 0;        //units.Length;
     foreach (GameObject unit in units)
     {
         TacticsMove npc = unit.GetComponent <TacticsMove>();
         //npc.moved = false;
         currentUnit = npc;
         //PROBAR EL INVOKE REPEATING
         NPCMove prueba = unit.GetComponent <NPCMove> ();
         prueba.FindNearestTarget();
         currentUnit.BeginTurn();
     }
     InitPlayerTurn();          //??? - REVISAR POR QUE NO LO SETEA A 4 Y LO SETEA A 0
 }
Exemple #10
0
    /// <summary>
    /// Spawns an enemy character on the map.
    /// </summary>
    /// <param name="pos"></param>
    /// <param name="stats"></param>
    /// <param name="inventory"></param>
    /// <param name="skills"></param>
    public void SpawnAllyCharacter(SpawnData pos)
    {
        Transform allyTransform = Instantiate(enemyPrefab, battleMap.enemyParent);
        NPCMove   tactics       = allyTransform.GetComponent <NPCMove>();

        tactics.battleMap   = battleMap;
        tactics.posx        = pos.x;
        tactics.posy        = pos.y;
        tactics.faction     = Faction.ALLY;
        tactics.stats       = new StatsContainer(pos);
        tactics.inventory   = new InventoryContainer(playerClassWheel.GetWpnSkillFromLevel(pos.charData.startClassLevels), pos.inventory);
        tactics.skills      = new SkillsContainer(playerClassWheel.GetSkillsFromLevel(pos.charData.startClassLevels, pos.charData.startClass, pos.level));
        tactics.fightQuotes = pos.quotes;
        tactics.talkQuotes  = pos.talks;
        tactics.aggroType   = pos.aggroType;
        tactics.huntTile    = battleMap.GetTile(pos.huntX, pos.huntY);
        tactics.patrolTiles.Clear();
        for (int i = 0; i < pos.patrolPositions.Count; i++)
        {
            tactics.patrolTiles.Add(battleMap.GetTile(pos.patrolPositions[i]));
        }
        tactics.Setup();
    }
    /*
     */
    // Update is called once per frame
    void Update()
    {
        fingerpsL[0]   = fingerL[0].transform.eulerAngles;
        fingerpsL[1]   = fingerL[1].transform.eulerAngles;
        fingerpsL[2]   = fingerL[2].transform.eulerAngles;
        fingerpsL[3]   = fingerL[3].transform.eulerAngles;
        fingerpsL[4]   = fingerL[4].transform.eulerAngles;
        fingerpsR[0]   = fingerR[0].transform.eulerAngles;
        fingerpsR[1]   = fingerR[1].transform.eulerAngles;
        fingerpsR[2]   = fingerR[2].transform.eulerAngles;
        fingerpsR[3]   = fingerR[3].transform.eulerAngles;
        fingerpsR[4]   = fingerR[4].transform.eulerAngles;
        palmpsL        = palmL.transform.eulerAngles;
        palmpsR        = palmR.transform.eulerAngles;
        indexfingerpsL = indexfingerL.transform.position;
        indexfingerpsR = indexfingerR.transform.position;

        CheckPalm();
        CheckFinger();

        //지목 모션
        if (CheckLandmarkMotion() == true)
        {
            Ray ray = new Ray();

            ray.origin    = indexfingerpsL;
            ray.direction = indexfingerL.transform.forward;
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, rayLength))
            {
                Debug.Log("지목");
                // Debug.Log(hit.collider.name);
                hitname = hit.collider.name;
                //되는지 확인
                Debug.DrawRay(ray.origin, ray.direction * 10f, Color.red, 5f);
                //검출된 타겟이 Worker 일때
                if (hit.transform.gameObject.tag == "Worker")
                {
                    //본 타겟이 리스트에 없고, 최대 선택인원수 보다 적으면 effect를 생성하고 리스트에 추가한다.
                    if (CheckList() && variable.selectnpc_count < variable.Choose_NPCCount)
                    {
                        GameObject obj = Instantiate(prefab, new Vector3(hit.collider.gameObject.transform.position.x, hit.collider.gameObject.transform.position.y + 0.3f, hit.collider.gameObject.transform.position.z), Quaternion.identity) as GameObject;
                        obj.name             = hitname + "Effect";
                        obj.transform.parent = hit.collider.gameObject.transform;

                        variable.selectnpc.Add(hit.transform.gameObject);
                        variable.selectnpc_count++;

                        npcmove          = hit.transform.gameObject.GetComponent <NPCMove>();
                        npcmove.npcstate = NPCMove.NPCState.SELECT_NPC; //선택된 npc의 상태를 select npc로 변경한다.
                    }
                }
                //검출된 타겟이 FruitFarm 일때
                else if (hit.transform.gameObject.tag == "FruitFarm")
                {
                    //선택된 모든 npc에게 명령을 지정함
                    for (int i = 0; i < variable.selectnpc_count; i++)
                    {
                        npcmove = variable.selectnpc [i].GetComponent <NPCMove> ();

                        //현재 사용자를 따라오는 상태라면 COMMAND_STATE 상태로 변경한다.
                        if (npcmove.npcstate == NPCMove.NPCState.FOLLOW_PLAYER && npcmove.commandstate == NPCMove.CommandState.FRUIT_PICKING)
                        {
                            npcmove.npcstate = NPCMove.NPCState.COMMAND_STATE;

                            npcmove.target = hit.transform.gameObject;                             //npc가 추적하는 target을 넘겨준다.
                        }
                    }
                }

                //검출된 타겟이 Mine 일때
                else if (hit.transform.gameObject.tag == "Mine")
                {
                    //돌 채집 인원이 많으면 초기로 돌림
                    if (variable.selectnpc_count >= variable.Stone_NPCCount)
                    {
                        Debug.Log("수행인원이 너무 많습니다.");

                        int imsi_count = variable.selectnpc_count;

                        for (int i = 0; i < imsi_count; i++)
                        {
                            npcmove = variable.selectnpc [0].GetComponent <NPCMove> ();
                            npcmove.StandardMode();
                        }
                    }

                    //아니라면 STONE_PICKING, COMMAND_STATE 상태로 변경하고 타겟을 넘겨준다.
                    else
                    {
                        for (int i = 0; i < variable.selectnpc_count; i++)
                        {
                            npcmove = variable.selectnpc [i].GetComponent <NPCMove> ();

                            if (npcmove.npcstate == NPCMove.NPCState.FOLLOW_PLAYER && npcmove.commandstate == NPCMove.CommandState.STONE_PICKING)
                            {
                                npcmove.npcstate = NPCMove.NPCState.COMMAND_STATE;

                                npcmove.target = hit.transform.gameObject;
                            }
                        }
                    }
                }
            }
        }

        if (CheckStoneMotion() == true)
        {
            Debug.Log("돌");
            for (int i = 0; i < variable.selectnpc_count; i++)
            {
                Debug.Log(variable.selectnpc[i].name);
                variable.selectnpc [i].GetComponent <Animator> ().SetInteger("ani_state", 2);

                npcmove = variable.selectnpc[i].GetComponent <NPCMove>();
                npcmove.commandstate = NPCMove.CommandState.STONE_PICKING;
            }
        }

        //열매따기
        if (CheckFruitMotion() == true)
        {
            Debug.Log("열매");
            variable.selectnpc [i].GetComponent <Animator> ().SetInteger("ani_state", 2);

            for (int i = 0; i < variable.selectnpc_count; i++)
            {
                Debug.Log(variable.selectnpc[i].name);
                npcmove = variable.selectnpc[i].GetComponent <NPCMove>();
                npcmove.commandstate = NPCMove.CommandState.FRUIT_PICKING;
            }
        }

        //사냥하기
        if (CheckHuntMotion() == true)
        {
            Debug.Log("사냥");
            variable.selectnpc [i].GetComponent <Animator> ().SetInteger("ani_state", 2);

            for (int i = 0; i < variable.selectnpc_count; i++)
            {
                Debug.Log(variable.selectnpc[i].name);
                npcmove = variable.selectnpc[i].GetComponent <NPCMove>();
                npcmove.commandstate = NPCMove.CommandState.HIT_SMALL_ANIMALL;
            }
        }

        //플레이어 직진
        if (CheckGoMotion() == true)
        {
            float fMove = Time.deltaTime * speed;
            Player.transform.Translate(Vector3.forward * fMove);
        }

        //UI
        if (CheckUIMotion() == true)
        {
            Debug.Log("UI");
        }
    }
 // Use this for initialization
 void Start()
 {
     anim = GetComponent<Animator> ();
     npc_mov = this.GetComponent<NPCMove>();
 }
 private void Start()
 {
     aimDir = transform.forward;
     ot     = GetComponent <ObjectTargeting>();
     move   = GetComponent <NPCMove>();
 }
    // Update is called once per frame
    void Update()
    {
        //마우스 왼쪽 버튼 클릭
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, rayLength))
            {
                Debug.Log(hit.collider.name);
                hitname = hit.collider.name;

                //검출된 타겟이 Worker 일때
                if (hit.transform.gameObject.tag == "Worker")
                {
                    //본 타겟이 리스트에 없고, 최대 선택인원수 보다 적으면 effect를 생성하고 리스트에 추가한다.
                    if (CheckList() && variable.selectnpc_count < variable.Choose_NPCCount)
                    {
                        GameObject obj = Instantiate(prefab, new Vector3(hit.collider.gameObject.transform.position.x, hit.collider.gameObject.transform.position.y + 0.3f, hit.collider.gameObject.transform.position.z), Quaternion.identity) as GameObject;
                        obj.name             = hitname + "Effect";
                        obj.transform.parent = hit.collider.gameObject.transform;

                        variable.selectnpc.Add(hit.transform.gameObject);
                        variable.selectnpc_count++;

                        npcmove          = hit.transform.gameObject.GetComponent <NPCMove> ();
                        npcmove.npcstate = NPCMove.NPCState.SELECT_NPC;                         //선택된 npc의 상태를 select npc로 변경한다.
                    }
                }

                //검출된 타겟이 FruitFarm 일때
                else if (hit.transform.gameObject.tag == "FruitFarm")
                {
                    //선택된 모든 npc에게 명령을 지정함
                    for (int i = 0; i < variable.selectnpc_count; i++)
                    {
                        npcmove = variable.selectnpc [i].GetComponent <NPCMove> ();

                        //현재 사용자를 따라오는 상태라면 COMMAND_STATE 상태로 변경한다.
                        if (npcmove.npcstate == NPCMove.NPCState.FOLLOW_PLAYER && npcmove.commandstate == NPCMove.CommandState.FRUIT_PICKING)
                        {
                            npcmove.npcstate = NPCMove.NPCState.COMMAND_STATE;

                            npcmove.target = hit.transform.gameObject;                             //npc가 추적하는 target을 넘겨준다.
                        }
                    }
                }

                //검출된 타겟이 Mine 일때
                else if (hit.transform.gameObject.tag == "Mine")
                {
                    //돌 채집 인원이 많으면 초기로 돌림
                    if (variable.selectnpc_count >= variable.Stone_NPCCount)
                    {
                        Debug.Log("수행인원이 너무 많습니다.");

                        int imsi_count = variable.selectnpc_count;

                        for (int i = 0; i < imsi_count; i++)
                        {
                            npcmove = variable.selectnpc [0].GetComponent <NPCMove> ();
                            npcmove.StandardMode();
                        }
                    }

                    //아니라면 STONE_PICKING, COMMAND_STATE 상태로 변경하고 타겟을 넘겨준다.
                    else
                    {
                        for (int i = 0; i < variable.selectnpc_count; i++)
                        {
                            npcmove = variable.selectnpc [i].GetComponent <NPCMove> ();

                            if (npcmove.npcstate == NPCMove.NPCState.FOLLOW_PLAYER && npcmove.commandstate == NPCMove.CommandState.STONE_PICKING)
                            {
                                npcmove.npcstate = NPCMove.NPCState.COMMAND_STATE;

                                npcmove.target = hit.transform.gameObject;
                            }
                        }
                    }
                }

                //검출된 타겟이 Samll_Animal 일때
                else if (hit.transform.gameObject.tag == "Small_Animal")
                {
                    //수행인원과 돌개수를 확인하여 적절하지 않다면 초기로 돌린다.
                    if (variable.selectnpc_count >= variable.Hit_Small_Animal_NPCCount || CaveStorage.Instance.storedStoneObjs.Count < variable.Hit_Small_Animal_Stone)
                    {
                        Debug.Log("수행인원이 너무 많거나 돌이 부족합니다.");

                        int imsi_count = variable.selectnpc_count;

                        for (int i = 0; i < imsi_count; i++)
                        {
                            npcmove = variable.selectnpc [0].GetComponent <NPCMove> ();
                            npcmove.StandardMode();
                        }
                    }

                    //아니라면 HIT_SMALL_ANIMAL, COMMAND_STATE 상태로 변경하고 타겟을 넘겨준다.
                    else
                    {
                        for (int i = 0; i < variable.selectnpc_count; i++)
                        {
                            npcmove = variable.selectnpc [i].GetComponent <NPCMove> ();

                            if (npcmove.npcstate == NPCMove.NPCState.FOLLOW_PLAYER && npcmove.commandstate == NPCMove.CommandState.HIT_SMALL_ANIMALL)
                            {
                                npcmove.npcstate = NPCMove.NPCState.COMMAND_STATE;

                                npcmove.target = hit.transform.gameObject;
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #15
0
    public void EndTurn()
    {
        if (enemyTurn)
        {
            if (NPCMove.turnOrderSize > 1)
            {
                NPCMove.turnsTaken++;
            }

            //print(NPCMove.turnsTaken);
            //print(NPCMove.turnOrderSize);

            //If more than one enemy is in range and seperate turns are required
            if (NPCMove.turnOrderSize > 1 && NPCMove.turnsTaken != NPCMove.turnOrderSize)
            {
                //get component in enemy whose turn it is
                GetComponent <NPCMove>().thisTurn = false;


                print("back to enemy turn");


                NPCMove.EnemyTurn();
            }
            else
            {
                GetComponent <NPCMove>().thisTurn = false;
                print("Ending enemy turn");
                enemyTurn          = false;
                NPCMove.turnsTaken = 0;
                TurnManagerPun2.SendTurnEvent();
            }
        }
        else
        {
            turnManagerPun2 = this.GetComponent <TurnManagerPun2>();

            turn = false;


            //TurnManagerPun2.turnCount++;

            //print(players.Length);
            //print("Turn Count: " + TurnManagerPun2.turnCount);

            //if (TurnManagerPun2.turnCount == players.Length)
            //{
            //    TurnManagerPun2.turnCount = 0;
            // }



            //turnManagerPun2.SyncTurnCount();


            PlayerStatus.LocalPlayerInstance.GetComponent <PlayerStatus>().turnCount++;


            if (!enemyTurn && endingTurn)
            {
                endingTurn = false;
                NPCMove.EnemyTurn();
                myTurn = false;



                //base.photonView.RPC("SendTurn", RpcTarget.Others, TurnManagerPun2.EndOfTurn);
                //GameObject.Find("EndTurn").GetComponent<EndTurnButton>().enabled = true;
            }
        }
    }
 void Start()
 {
     _player = GameObject.FindGameObjectWithTag("Player");
     _npc    = gameObject.GetComponent <NPCMove>();
 }
Exemple #17
0
    //Different functions regarding winning and losing the mission
    #region VictoryDefeat

    /// <summary>
    /// Checks to see if the win/lose condition has been met, displays a message and ends the game.
    /// </summary>
    public void CheckGameFinished()
    {
        if (gameover)
        {
            return;
        }

        // Check if any players are alive
        bool     gameFinished = false;
        MapEntry map          = (MapEntry)currentMap.value;

        // Basic lose condition
        bool isAlive = false;

        for (int i = 0; i < playerList.values.Count; i++)
        {
            if (playerList.values[i].IsAlive())
            {
                isAlive = true;
            }
            if (playerList.values[i].stats.charData.mustSurvive && !playerList.values[i].IsAlive())
            {
                gameFinished = true;
                break;
            }
        }
        if (!isAlive)
        {
            gameFinished = true;
        }

        if (map.loseCondition == LoseCondition.TIME)
        {
            if (currentTurn.value > map.turnLimit)
            {
                gameFinished = true;
            }
        }
        else if (map.loseCondition != LoseCondition.NONE)
        {
            Debug.LogError("Undefined lose condition:   " + map.loseCondition);
        }

        if (gameFinished)
        {
            Debug.Log("GAME OVER");
            StartCoroutine(EndGameLose());
            gameover = true;
            return;
        }

        // Check if any enemies are alive
        gameFinished = true;
        // Rout win condition
        if (map.winCondition == WinCondition.ROUT)
        {
            for (int i = 0; i < enemyList.values.Count; i++)
            {
                if (enemyList.values[i].IsAlive())
                {
                    gameFinished = false;
                    break;
                }
            }
        }
        else if (map.winCondition == WinCondition.BOSS)
        {
            gameFinished = false;
            for (int i = 0; i < enemyList.values.Count; i++)
            {
                NPCMove enemy = (NPCMove)enemyList.values[i];
                if (enemy.aggroType == AggroType.BOSS && !enemyList.values[i].IsAlive())
                {
                    gameFinished = true;
                    break;
                }
            }
        }
        else if (map.winCondition == WinCondition.CAPTURE)
        {
            gameFinished = (triggeredWin.value);
        }
        else if (map.winCondition == WinCondition.ESCAPE)
        {
            gameFinished = true;
            bool escaped = false;
            for (int i = 0; i < playerList.values.Count; i++)
            {
                if (playerList.values[i].hasEscaped)
                {
                    escaped = true;
                }
                else if (playerList.values[i].IsAlive())
                {
                    gameFinished = false;
                }
            }
            gameFinished &= escaped;
        }
        else
        {
            Debug.LogError("Undefined win condition:   " + map.winCondition);
        }

        // DEBUG
        if (autoWin.value)
        {
            gameFinished = true;
        }

        if (gameFinished)
        {
            Debug.Log("BATTLE WON");
            gameover = true;
            StartCoroutine(EndGameWin());
            return;
        }

        gameover = false;
    }
Exemple #18
0
 void Start()
 {
     instance = this;
     Init();
     animator = GetComponentInChildren <Animator>();
 }
Exemple #19
0
    /// <summary>
    /// Takes each enemy that is alive and runs their turn.
    /// </summary>
    /// <returns></returns>
    private IEnumerator RunNPCTurn(CharacterListVariable list, float startDelay)
    {
        isRunning = true;
        yield return(new WaitForSeconds(startDelay * currentGameSpeed.value));

        battleWeaponIndex.value = 0;
        currentPage.value       = 0;

        yield return(new WaitForSeconds(2f * currentGameSpeed.value));

        for (int i = 0; i < list.Count; i++)
        {
            if (!list.values[i].IsAlive() || list.values[i].hasEscaped)
            {
                continue;
            }

            // Select the next enemy and show its movement
            //Debug.Log(list.values[i].gameObject.name + " turn");
            selectCharacter.value = list.values[i];
            selectTile.value      = selectCharacter.value.currentTile;
            tactics = (NPCMove)list.values[i];
            // enemy.FindAllMoveTiles(false);
            cursorX.value = tactics.posx;
            cursorY.value = tactics.posy;
            cursorMovedEvent.Invoke();

            // Calculate the tile to move towards and wait for the character to move there if any
            MapTile moveTile = tactics.CalculateMovement();
            if (moveTile == null)
            {
                tactics.EndMovement();
                waitForNextAction = false;
            }
            else
            {
                tactics.ShowMove(moveTile);
                waitForNextAction = true;
            }

            if (waitForNextAction)
            {
                yield return(new WaitForSeconds(1.5f * currentGameSpeed.value));

                tactics.StartMove();
            }
            while (waitForNextAction)
            {
                yield return(null);
            }

            // Calculate which character to attack/support and waits for the battle scene to finish
            // Debug.Log("Attack time");
            bool res = waitForNextAction = tactics.CalculateAttacksHeals();
            while (waitForNextAction)
            {
                yield return(null);
            }

            if (res)
            {
                yield return(new WaitForSeconds(1f * currentGameSpeed.value));
            }
            // Finish the turn
            // Debug.Log("End turn");
            tactics.End();
            cursorX.value = tactics.posx;
            cursorY.value = tactics.posy;
            cursorMovedEvent.Invoke();
        }

        yield return(new WaitForSeconds(3f * currentGameSpeed.value));

        isRunning = false;
        nextStateEvent.Invoke();
    }