public void GoToNextBase(BaseEnum currentBase, bool isAutomaticCommand = false)
    {
        Debug.Log(this.name + " go to next base");
        this.IsStaying = false;

        PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager();

        playersTurnManager.UpdatePlayerTurnAvailability(this.gameObject.name, TurnAvailabilityEnum.WAITING);

        Vector3 nextPosition = this.GetNextBasePosition(currentBase);

        this.Target         = nextPosition;
        this.EnableMovement = true;

        GameManager gameManager = GameUtils.FetchGameManager();

        if (!isAutomaticCommand)
        {
            Debug.Log(this.name + " proceed manually");
            this.CalculateNextAction();
        }
        else if (isAutomaticCommand && gameManager.AttackTeamRunnerList.Count > 1)
        {
            if (this.gameObject.Equals(playersTurnManager.GetNextRunnerTakingAction()))
            {
                playersTurnManager.IsSkipNextRunnerTurnEnabled = true;
            }

            Debug.Log(this.name + " proceed automaticaly");

            playersTurnManager.TurnState      = TurnStateEnum.RUNNER_TURN;
            PlayersTurnManager.IsCommandPhase = true;
        }
    }
    public void StayOnCurrentBase()
    {
        Debug.Log(this.name + " wait on current base");
        this.IsStaying = true;
        PlayersTurnManager playersTurnManager = GameUtils.FetchPlayersTurnManager();

        playersTurnManager.UpdatePlayerTurnAvailability(this.gameObject.name, TurnAvailabilityEnum.WAITING);
        IsoRenderer.ReinitializeAnimator();

        GameManager gameManager = GameUtils.FetchGameManager();

        bool isRunnersAllSafeAndStaying = gameManager.AttackTeamRunnerList.TrueForAll(runner => {
            RunnerBehaviour runnerBehaviour = PlayerUtils.FetchRunnerBehaviourScript(runner);
            return(runnerBehaviour.IsSafe && runnerBehaviour.IsStaying);
        });

        //test if all remaining runner are out and there no more batters
        int runnersCount = gameManager.AttackTeamRunnerList.Count;
        int batterCount  = gameManager.AttackTeamBatterListClone.Count;

        if (runnersCount == 0 && batterCount == 0 || batterCount == 0 && runnersCount > 0 && isRunnersAllSafeAndStaying)
        {
            gameManager.IsStateCheckAllowed = false;
            gameManager.ProcessNextInningHalf();
            return;
        }
        else if (isRunnersAllSafeAndStaying)
        {
            playersTurnManager.IsRunnersTurnsDone = true;
        }

        Vector3 nextBasePosition = this.GetNextBasePosition(this.CurrentBase);

        IsoRenderer.LookAtFieldElementAnimation(nextBasePosition);

        this.CalculateNextAction();
    }
    public void CalculateRunnerColliderInterraction(BaseEnum baseReached, bool isNextRunnerTurnPossible = false)
    {
        Debug.Log(this.name + " interracted with " + baseReached.ToString());
        this.CurrentBase = baseReached;

        PlayerStatus playerStatusScript = PlayerUtils.FetchPlayerStatusScript(this.gameObject);

        this.EnableMovement = false;

        PlayersTurnManager   playersTurnManager   = GameUtils.FetchPlayersTurnManager();
        TurnAvailabilityEnum turnAvailabilityEnum = TurnAvailabilityEnum.READY;

        switch (baseReached)
        {
        case BaseEnum.HOME_BASE:

            if (baseReached == BaseEnum.HOME_BASE && !this.HasPassedThroughThreeFirstBases())
            {
                Debug.Log("Get on HOME BASE FIRST TIME !!");
                this.NextBase = BaseEnum.FIRST_BASE;
                playersTurnManager.TurnState = TurnStateEnum.STANDBY;
                playersTurnManager.UpdatePlayerTurnAvailability(this.gameObject.name, turnAvailabilityEnum);
            }
            else
            {
                Debug.Log("Get on HOME BASE to mark a point");
                Debug.Log("WIN ONE POINT !!!");
                this.Target   = null;
                this.NextBase = this.CurrentBase;
                playerStatusScript.IsAllowedToMove = false;
                this.HasReachedHomeBase            = true;

                PlayerEnum        playerEnum = playerStatusScript.PlayerOwner;
                TeamsScoreManager teamsScoreManagerScript = GameUtils.FetchTeamsScoreManager();
                teamsScoreManagerScript.IncrementTeamScore(GameData.teamIdEnumMap[playerEnum]);
                this.IsStaying = true;
                IsoRenderer.ReinitializeAnimator();
                GameManager gameManager = GameUtils.FetchGameManager();

                this.gameObject.SetActive(false);
                gameManager.AttackTeamRunnerList.Remove(this.gameObject);
                playersTurnManager.UpdatePlayerTurnQueue(this.gameObject);
                gameManager.AttackTeamRunnerHomeList.Add(this.gameObject);

                int batterCount = gameManager.AttackTeamBatterListClone.Count;
                if (this.EquipedBat != null && batterCount > 0)
                {
                    GameObject      newBatter = gameManager.AttackTeamBatterListClone.First();
                    BatterBehaviour newbatterBehaviourScript = PlayerUtils.FetchBatterBehaviourScript(newBatter);
                    newbatterBehaviourScript.EquipedBat = this.EquipedBat;
                    this.EquipedBat = null;
                    gameManager.EquipBatToPlayer(newBatter);
                }

                int runnersCount = gameManager.AttackTeamRunnerList.Count;

                bool isRunnersAllSafeAndStaying = gameManager.AttackTeamRunnerList.TrueForAll(runner => {
                    RunnerBehaviour runnerBehaviour = PlayerUtils.FetchRunnerBehaviourScript(runner);
                    return(runnerBehaviour.IsSafe && runnerBehaviour.IsStaying);
                });

                if (runnersCount == 0 && batterCount == 0 || batterCount == 0 && runnersCount > 0 && isRunnersAllSafeAndStaying)
                {
                    gameManager.IsStateCheckAllowed = false;
                    gameManager.ProcessNextInningHalf();
                }
                else
                {
                    gameManager.IsStateCheckAllowed = true;
                }
            }

            break;

        case BaseEnum.FIRST_BASE:
            Debug.Log("Get on FIRST BASE");

            this.NextBase            = BaseEnum.SECOND_BASE;
            this.HasReachedFirstBase = true;
            if (this.IsInWalkState)
            {
                this.IsInWalkState   = false;
                turnAvailabilityEnum = TurnAvailabilityEnum.WAITING;
                IsoRenderer.ReinitializeAnimator();
            }

            playersTurnManager.UpdatePlayerTurnAvailability(this.gameObject.name, turnAvailabilityEnum);
            break;

        case BaseEnum.SECOND_BASE:
            Debug.Log("Get on SECOND BASE");
            this.NextBase             = BaseEnum.THIRD_BASE;
            this.HasReachedSecondBase = true;
            playersTurnManager.UpdatePlayerTurnAvailability(this.gameObject.name, turnAvailabilityEnum);
            break;

        case BaseEnum.THIRD_BASE:
            Debug.Log("Get on THIRD BASE");
            this.NextBase            = BaseEnum.HOME_BASE;
            this.HasReachedThirdBase = true;
            playersTurnManager.UpdatePlayerTurnAvailability(this.gameObject.name, turnAvailabilityEnum);
            break;

        default:
            Debug.Log("DO NOT KNOW WHAT HAPPEN");
            break;
        }

        if (isNextRunnerTurnPossible)
        {
            playersTurnManager.TurnState      = TurnStateEnum.RUNNER_TURN;
            PlayersTurnManager.IsCommandPhase = true;
        }
    }