Ejemplo n.º 1
0
    public void Execute(Player player)
    {
        if (!drewMouseSuggestions && _gameSceneManager.numberOfMoves > 0)
        {
            _mouse.DrawMoveSuggestions(player);
            drewMouseSuggestions = true;
        }

        if (_gameSceneManager.numberOfMoves > 0)
        {
            player.isAbleToMove = true;
        }

        if (player.isAbleToMove)
        {
            player.Move();
            _mouse.DrawMoveSuggestionsHover(player);
        }
    }
    public IEnumerator Move(Player player)
    {
        PlayMoveSoundEffect();
        var mouseUI = player.mouseUI.GetComponent <MouseUI>();

        _mouse.Clear(mouseUI);
        _playerFogOfWar.ChangeFogOfWar(player, player.visitedAlphaLevel);
        _playerFogOfWar.RevealPlayersRefineries(player);

        player._isMoving = true;
        var startPos = player.transform.position;
        var t        = 0f;

        var endPos = new Vector3(GetMousePos(player).x, GetMousePos(player).y, startPos.z);

        while (player.transform.position != endPos)
        {
            t += Time.deltaTime * player.moveSpeed;
            player.transform.position = Vector3.Lerp(startPos, endPos, t);
            yield return(null);
        }

        _playerFogOfWar.ChangeFogOfWar(player, player.revealAlphaLevel);
        player._isMoving = false;
        AddAllTilesOf(player);
        _playerMoney.CheckIfOnMoney(player);
        _gameMap.CheckAndHideGameEntities(player);

        // check if more moves are available
        if (_gameSceneManager.numberOfMoves > 0)
        {
            _mouse.DrawMoveSuggestions(player);
        }

        yield return(0);
    }