示例#1
0
    //------------------------------------------------METHODS------------------------------------
    /// <summary>   StartPosition()
    ///     We get the distance between the reference of the leftPoint and rightPoint. Then we made
    ///     a 3 by 3 matrix.
    ///     We initialize the start position to de middle position of x and y axis.
    ///     And also we say the spaceship is not moving.
    /// </summary>
    void StartPosition()
    {
        m_distance = (leftPointCircle.position - rightPointCircle.position).magnitude;

        m_middleHPos = 0.0f;
        m_leftPos    = -m_distance / 3;
        m_rightPos   = m_distance / 3;

        m_middleVPos = 0.0f;
        m_downPos    = -m_distance / 3;
        m_upPos      = m_distance / 3;

        this.transform.position = new Vector3(m_middleHPos, m_middleVPos);

        //States inicialization
        m_stateH      = STATE_HORIZONTAL.MIDDLE;
        m_stateV      = STATE_VERTICAL.MIDDLE;
        m_stateMove   = STATEMOVE.NONE;
        m_stateRotate = STATEROTATE.NONE;
    }//StartPosition
示例#2
0
    }//MoveForward

    /// <summary>   MovementWithAxis()
    ///     Movement of the Ship whith the gamepad
    /// </summary>
    void MovementWithAxis()
    {
        //STATES MACHINE FOR MOVEMENT
        switch (m_stateMove)
        {
        case STATEMOVE.MOVE_LEFT:     //Moving Left
            //Used position instead of Translate because i wanted to use world space coordinates
            transform.position += Vector3.right * -moveSpeedAxis * Time.deltaTime;
            switch (m_stateH)
            {
            case STATE_HORIZONTAL.MIDDLE:
                if (transform.position.x <= m_leftPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateH    = STATE_HORIZONTAL.LEFT;
                }
                break;

            case STATE_HORIZONTAL.RIGHT:
                if (transform.position.x <= m_middleHPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateH    = STATE_HORIZONTAL.MIDDLE;
                }
                break;
            }
            break;

        case STATEMOVE.MOVE_RIGHT:     //Moving Right
            transform.position += Vector3.right * moveSpeedAxis * Time.deltaTime;
            switch (m_stateH)
            {
            case STATE_HORIZONTAL.MIDDLE:
                if (transform.position.x >= m_rightPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateH    = STATE_HORIZONTAL.RIGHT;
                }
                break;

            case STATE_HORIZONTAL.LEFT:
                if (transform.position.x >= m_middleHPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateH    = STATE_HORIZONTAL.MIDDLE;
                }
                break;
            }
            break;

        case STATEMOVE.MOVE_UP:     //Moving Up
            transform.position += Vector3.up * moveSpeedAxis * Time.deltaTime;
            switch (m_stateV)
            {
            case STATE_VERTICAL.DOWN:
                if (transform.position.y >= m_middleVPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateV    = STATE_VERTICAL.MIDDLE;
                }
                break;

            case STATE_VERTICAL.MIDDLE:
                if (transform.position.y >= m_upPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateV    = STATE_VERTICAL.UP;
                }
                break;
            }
            break;

        case STATEMOVE.MOVE_DOWN:     //Moving Down
            transform.position += Vector3.up * -moveSpeedAxis * Time.deltaTime;
            switch (m_stateV)
            {
            case STATE_VERTICAL.UP:
                if (transform.position.y <= m_middleVPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateV    = STATE_VERTICAL.MIDDLE;
                }
                break;

            case STATE_VERTICAL.MIDDLE:
                if (transform.position.y <= m_downPos)
                {
                    m_stateMove = STATEMOVE.NONE;
                    m_stateV    = STATE_VERTICAL.DOWN;
                }
                break;
            }
            break;
        }
    }//MovementWithAxis
示例#3
0
    //------------------------------------------------METHODS------------------------------------
    /// <summary>   StartPosition()
    ///     We get the distance between the reference of the leftPoint and rightPoint. Then we made
    ///     a 3 by 3 matrix.
    ///     We initialize the start position to de middle position of x and y axis.
    ///     And also we say the spaceship is not moving.
    /// </summary>
    void StartPosition()
    {
        m_distance = (leftPointCircle.position - rightPointCircle.position).magnitude;

        m_middleHPos = 0.0f;
        m_leftPos = - m_distance / 3;
        m_rightPos = m_distance / 3;

        m_middleVPos = 0.0f;
        m_downPos = -m_distance / 3;
        m_upPos = m_distance / 3;

        this.transform.position = new Vector3(m_middleHPos, m_middleVPos);

        //States inicialization
        m_stateH = STATE_HORIZONTAL.MIDDLE;
        m_stateV = STATE_VERTICAL.MIDDLE;
        m_stateMove = STATEMOVE.NONE;
        m_stateRotate = STATEROTATE.NONE;
    }
示例#4
0
    /// <summary>   MovementWithAxis()
    ///     Movement of the Ship whith the gamepad
    /// </summary>
    void MovementWithAxis()
    {
        //STATES MACHINE FOR MOVEMENT
        switch(m_stateMove)
        {
            case STATEMOVE.MOVE_LEFT: //Moving Left
                //Used position instead of Translate because i wanted to use world space coordinates
                transform.position += Vector3.right * -moveSpeedAxis * Time.deltaTime;
                switch (m_stateH)
                {
                    case STATE_HORIZONTAL.MIDDLE:
                        if (transform.position.x <= m_leftPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateH = STATE_HORIZONTAL.LEFT;
                        }
                        break;
                    case STATE_HORIZONTAL.RIGHT:
                        if (transform.position.x <= m_middleHPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateH = STATE_HORIZONTAL.MIDDLE;
                        }
                        break;
                }
                break;

            case STATEMOVE.MOVE_RIGHT: //Moving Right
                transform.position += Vector3.right * moveSpeedAxis * Time.deltaTime;
                switch (m_stateH)
                {
                    case STATE_HORIZONTAL.MIDDLE:
                        if (transform.position.x >= m_rightPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateH = STATE_HORIZONTAL.RIGHT;
                        }
                        break;
                    case STATE_HORIZONTAL.LEFT:
                        if (transform.position.x >= m_middleHPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateH = STATE_HORIZONTAL.MIDDLE;
                        }
                        break;
                }
                break;

            case STATEMOVE.MOVE_UP: //Moving Up
                transform.position += Vector3.up * moveSpeedAxis * Time.deltaTime;
                switch (m_stateV)
                {
                    case STATE_VERTICAL.DOWN:
                        if (transform.position.y >= m_middleVPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateV = STATE_VERTICAL.MIDDLE;
                        }
                        break;
                    case STATE_VERTICAL.MIDDLE:
                        if (transform.position.y >= m_upPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateV = STATE_VERTICAL.UP;
                        }
                        break;
                }
                break;

            case STATEMOVE.MOVE_DOWN: //Moving Down
                transform.position += Vector3.up * -moveSpeedAxis * Time.deltaTime;
                switch (m_stateV)
                {
                    case STATE_VERTICAL.UP:
                        if (transform.position.y <= m_middleVPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateV = STATE_VERTICAL.MIDDLE;
                        }
                        break;
                    case STATE_VERTICAL.MIDDLE:
                        if (transform.position.y <= m_downPos)
                        {
                            m_stateMove = STATEMOVE.NONE;
                            m_stateV = STATE_VERTICAL.DOWN;
                        }
                        break;
                }
                break;
        }
    }