Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        switch (m_moveDir)
        {
        case EMovementDirection.Left:
            transform.position = (Vector2)transform.position + Vector2.left * speed * Time.deltaTime;

            float leftEdgeOfFormation = transform.position.x - (0.5f * width);
            if (leftEdgeOfFormation <= m_xMin)
            {
                //m_remainingVertDistance = verticalMovement;
                //m_moveDir = EMovementDirection.Down;
                //m_LastDir = EMovementDirection.Left;

                m_moveDir = EMovementDirection.Right;
            }
            break;

        case EMovementDirection.Right:
            transform.position = (Vector2)transform.position + Vector2.right * speed * Time.deltaTime;

            float rightEdgeOfFormation = transform.position.x + (0.5f * width);
            if (rightEdgeOfFormation >= m_xMax)
            {
                //m_remainingVertDistance = verticalMovement;
                //m_moveDir = EMovementDirection.Down;
                //m_LastDir = EMovementDirection.Right;

                m_moveDir = EMovementDirection.Left;
            }
            break;

        case EMovementDirection.Down:
            if (m_remainingVertDistance > 0)
            {
                Vector2 nextPosition = (Vector2)transform.position + Vector2.down * speed * Time.deltaTime;
                m_remainingVertDistance -= transform.position.y - nextPosition.y;
                transform.position       = nextPosition;
            }
            else
            {
                if (m_LastDir == EMovementDirection.Left)
                {
                    m_moveDir = EMovementDirection.Right;
                }
                else
                {
                    m_moveDir = EMovementDirection.Left;
                }
            }
            transform.position = Vector2.down * speed * Time.deltaTime;
            break;
        }

        if (AllMembersDead())
        {
            SpawnUntilFull();
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Converts a Movement Direction to a Vector2 direction
    /// </summary>
    /// <param name="_direction">Movement Direction</param>
    /// <returns>Vector2 direction</returns>
    public static Vector2 GetMovementVectorFromDirection(EMovementDirection _direction)
    {
        switch (_direction)
        {
        case EMovementDirection.EMD_UP:
            return(Vector2.up);

        case EMovementDirection.EMD_RIGHT:
            return(Vector2.right);

        case EMovementDirection.EMD_DOWN:
            return(Vector2.down);

        case EMovementDirection.EMD_LEFT:
            return(Vector2.left);
        }

        return(Vector2.zero);
    }
Exemplo n.º 3
0
 private void Update()
 {
     m_CurrentMovementDirection = m_PlayerInput.TickInput();
 }