} // NewAwake

    public override void UpdateMethod(float deltaTime)
    {
        _newDirection = EDirectionsPositions.Size;

        if (Input.anyKeyDown)
        {
            if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A))
            {
                _newDirection = EDirectionsPositions.Left;
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
            {
                _newDirection = EDirectionsPositions.Right;
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
            {
                _newDirection = EDirectionsPositions.Bot;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
            {
                _newDirection = EDirectionsPositions.Top;
            }

            _playerState.NewInput(_newDirection);
        }
    } // UpdateMethod
    public void NewInput(EDirectionsPositions newState)
    {
        bool isNewState = false;

        if (newState != _currentPushState)
        {
            _currentPushState = newState;
            isNewState        = true;
        }

        OnNewPush(_currentPushState, isNewState);
    } // SetState
Exemplo n.º 3
0
    } // EDirectiosPositionsToVector3

    public static Vector3 EDirectiosPositionsToVector3(EDirectionsPositions directionOrPoint)
    {
        switch (directionOrPoint)
        {
        case EDirectionsPositions.Top: return(Vector3.up);

        case EDirectionsPositions.Bot: return(Vector3.down);

        case EDirectionsPositions.Left: return(Vector3.left);

        case EDirectionsPositions.Right: return(Vector3.right);
        }
        Debug.LogWarning("Calling EDirectiosPositionsToVector3 with No Valid Value" + directionOrPoint);
        return(Vector3.zero);
    } // EDirectiosPositionsToVector3
Exemplo n.º 4
0
    } // GetPlayerStrength

    public static EDirectionsPositions GetOpositeDirection(EDirectionsPositions directionOrPoint)
    {
        switch (directionOrPoint)
        {
        case EDirectionsPositions.Top: return(EDirectionsPositions.Bot);

        case EDirectionsPositions.Bot: return(EDirectionsPositions.Top);

        case EDirectionsPositions.Left: return(EDirectionsPositions.Right);

        case EDirectionsPositions.Right: return(EDirectionsPositions.Left);
        }
        Debug.LogWarning("Calling GetOpositeDirection with No Valid Value" + directionOrPoint);
        return(EDirectionsPositions.Size);
    } // EDirectiosPositionsToVector3
Exemplo n.º 5
0
    } // Start

    private void OnPush(EDirectionsPositions direction, bool isNewDirection)
    {
        if (isNewDirection)
        {
            _timesPushSameDirection = 1;
        }
        else
        {
            ++_timesPushSameDirection;
        }

        _pushStrength  = _gameData.GetPlayerStrength(_timesPushSameDirection);
        _pushDirection = direction;

        transform.position = GameManager.GetPtr().GetLevelManager().Push(_pushDirection, _pushStrength);
        _timeStamp         = 0;
    } // OnChangeState
    } // FinishGame

    /// <summary>
    /// If there are road in this direccion, call the road for push the bear and return the bear position
    /// otherwise return one position close to honey in the direccion.
    ///
    /// In both scenario, call the player with the pushed object, bear if can or null otherwise
    /// </summary>
    /// <param name="pushDirection"></param>
    /// <param name="pushStrength"></param>
    /// <returns></returns>
    public Vector3 Push(EDirectionsPositions pushDirection, float pushStrength)
    {
        for (int i = 0; i < _roads.Count; i++)
        {
            if (_roads[i].GetRoadPosition() == pushDirection)
            {
                if (_roads[i].gameObject.activeSelf)
                {
                    _playerController.SetPushingItem(_roads[i].GetBear());
                    return(_roads[i].PushBear(pushStrength));
                }
                else
                {
                    _playerController.SetPushingItem(null);
                    return(GetTemporalPositionForPlayer(pushDirection));
                }
            }
        }
        _playerController.SetPushingItem(null);
        return(GetTemporalPositionForPlayer(pushDirection));
    } // Push
    } // Push

    private Vector3 GetTemporalPositionForPlayer(EDirectionsPositions pushDirection)
    {
        Debug.Log("set position close to honey depending of the pushDirection");
        return(_honeyController.transform.position);
    } // GetTemporalPositionForPlayer