示例#1
0
    public override E_PLAYER_STATES Cycle(S_inputStruct inputs)
    {
        MoveHorzontal(m_speed, inputs);

        if (inputs.m_movementVector.x != 0.0f)
        {
            m_data.m_anim.SetBool("Walking", true);
        }
        else
        {
            m_data.m_anim.SetBool("Walking", false);
        }

        m_data.SetYVelocity(-9.81f);

        if (GetInput(E_INPUTS.MOVE_BOX, inputs))
        {
            return(E_PLAYER_STATES.MOVEING_BLOCK);
        }

        if (GetInput(E_INPUTS.JUMP, inputs))
        {
            m_data.SetYVelocity(m_jumpSpeed);

            return(E_PLAYER_STATES.IN_AIR);
        }

        return(E_PLAYER_STATES.ON_GROUND);
    }
示例#2
0
    public override E_PLAYER_STATES PhysCycle(S_inputStruct inputs)
    {
        if (m_enableGroundCollisionCount > 0)
        {
            m_enableGroundCollisionCount--;
        }

        return(E_PLAYER_STATES.IN_AIR);
    }
    public override E_PLAYER_STATES InTrigger(string _tag, S_inputStruct inputs)
    {
        if (_tag == "Ladder" && inputs.m_movementVector.y > 0.0f)
        {
            return(E_PLAYER_STATES.USEING_LADDER);
        }

        return(E_PLAYER_STATES.ON_GROUND);
    }
示例#4
0
    public override E_PLAYER_STATES InTrigger(string _tag, S_inputStruct inputs)
    {
        // if the player can and wants to climb a ladder move to the using ladder state
        if (_tag == "Ladder" && inputs.m_movementVector.y > 0.0f)
        {
            return(E_PLAYER_STATES.USEING_LADDER);
        }

        return(E_PLAYER_STATES.IN_AIR);
    }
    public override E_PLAYER_STATES Cycle(S_inputStruct inputs)
    {
        MoveHorzontal(m_speed, inputs);

        m_data.SetYVelocity(m_climbSpeed * inputs.m_movementVector.y);

        if (GetInput(E_INPUTS.JUMP, inputs))
        {
            m_data.SetYVelocity(m_jumpSpeed);

            return(E_PLAYER_STATES.IN_AIR);
        }

        return(E_PLAYER_STATES.USEING_LADDER);
    }
示例#6
0
    public override E_PLAYER_STATES Cycle(S_inputStruct inputs)
    {
        m_data.SetVelocity(0.0f, 0.0f, 0.0f);

        m_KOTime.Cycle();

        if (m_KOTime.m_completed)
        {
            int scene = SceneManager.GetActiveScene().buildIndex;
            SceneManager.LoadScene(scene, LoadSceneMode.Single);

            return(E_PLAYER_STATES.IN_AIR);
        }

        return(E_PLAYER_STATES.NULL);
    }
示例#7
0
    public override E_PLAYER_STATES Cycle(S_inputStruct inputs)
    {
        Debug.DrawRay(transform.position + (transform.up * 1.5f), transform.up * 0.1f, Color.blue);

        ApplyGravity();

        MoveHorzontal(m_speed, inputs);

        if (!GetInput(E_INPUTS.JUMP, inputs) & m_data.GetVelocity().y > 0.0f)
        {
            Debug.Log("Short Jump");
            m_data.SetYVelocity(0.0f);
        }

        m_data.m_anim.SetFloat("Vertical Velocity", m_data.GetVelocity().y);

        return(E_PLAYER_STATES.IN_AIR);
    }
示例#8
0
    public override E_PLAYER_STATES Cycle(S_inputStruct inputs)
    {
        ApplyGravity();

        Standard3DMovment(m_speed, inputs);

        // stops the upward movment if the player lets go of the jump button
        if (!GetInput(E_INPUTS.JUMP, inputs) & m_data.GetVelocity().y > 0.0f)
        {
            Debug.Log("Short Jump");
            m_data.SetYVelocity(0.0f);
        }

        // updates the animator on the player current y velocity
        m_data.m_anim.SetFloat("Vertical Velocity", m_data.GetVelocity().y);

        return(E_PLAYER_STATES.IN_AIR);
    }
    public override E_PLAYER_STATES Cycle(S_inputStruct inputs)
    {
        if (!m_box)
        {
            Debug.Log("No box refrence");

            return(E_PLAYER_STATES.ON_GROUND);
        }

        bool getInput = false;

        if (m_data.m_use3D)
        {
            getInput = inputs.m_movementVector.x != 0.0f || inputs.m_movementVector.y != 0.0f;
        }
        else
        {
            getInput = inputs.m_movementVector.x != 0.0f;
        }

        if (m_data.m_use3D)
        {
            m_data.AddVelocity(inputs.m_movementVector.y * m_dragSpeed, 0.0f, inputs.m_movementVector.x * m_dragSpeed);

            if (inputs.m_movementVector.x != 0.0f || inputs.m_movementVector.y != 0.0f)
            {
                Debug.Log("moving");
            }
        }
        else
        {
            MoveHorzontal(m_dragSpeed, inputs);
        }

        m_boxRigb.velocity = m_data.GetExpectedVelocity();

        if (!GetInput(E_INPUTS.MOVE_BOX_HOLD, inputs))
        {
            Debug.Log("Box movment button relesed");
            return(E_PLAYER_STATES.ON_GROUND);
        }

        return(E_PLAYER_STATES.MOVEING_BLOCK);
    }
示例#10
0
    protected void Standard3DMovment(float _speed, S_inputStruct inputs)
    {
        Debug.DrawRay(transform.position + (-transform.up * 0.1f), -transform.up * 0.1f, Color.red);

        if (GetInput(E_INPUTS.RESET_CAMERA, inputs))
        {
            m_data.resetCameraDirection();
        }

        //m_data.m_cameraRotation *= Quaternion.Euler(transform.up * Time.deltaTime * 72.0f * inputs.m_cameraVector.x);
        m_data.m_cameraRotation += Quaternion.Euler(transform.up * Time.deltaTime * 72.0f * inputs.m_cameraVector.x).y * 360.0f;

        //Debug.DrawRay(transform.position, m_data.m_cameraRotation * Vector3.forward, Color.red);
        Debug.DrawRay(transform.position + transform.up * 1.0f, transform.up, Color.green);
        Debug.DrawRay(transform.position + transform.up * 1.0f, transform.right, Color.red);
        Debug.DrawRay(transform.position + transform.up * 1.0f, transform.forward, Color.blue);

        ///Quaternion charicterRot = transform.rotation;//transform.qua m_data.m_cameraRotation;
        //Vector3 eulerCharicterRot = new Vector3(transform.eulerAngles.x, m_data.m_cameraRotation, transform.eulerAngles.z);
        Vector3 eulerCharicterRot = transform.eulerAngles.x * transform.right;

        eulerCharicterRot += m_data.m_cameraRotation * transform.up;
        eulerCharicterRot += transform.eulerAngles.z * transform.forward;

        Quaternion charicterRot = Quaternion.Euler(eulerCharicterRot);

        if (inputs.m_movementVector.x != 0 || inputs.m_movementVector.y != 0)
        {
            charicterRot *= Quaternion.Euler(Vector3.up * (Mathf.Atan2(inputs.m_movementVector.x, inputs.m_movementVector.y) * Mathf.Rad2Deg));

            //Debug.Log("charicterRot: " + charicterRot);

            m_data.m_anim.SetBool("Walking", true);
            //transform.rotation = charicterRot;
            m_data.SetRotation(charicterRot);
            //m_data.m_velocity.x += _speed;
            m_data.AddVelocity(_speed, 0.0f, 0.0f);
        }
        else
        {
            m_data.m_anim.SetBool("Walking", false);
        }
    }
示例#11
0
    public override E_PLAYER_STATES Cycle(S_inputStruct inputs)
    {
        Standard3DMovment(m_speed, inputs);

        //m_data.m_anim.SetFloat("Horizontal Velocity", m_data.m_velocityZ);

        m_data.SetYVelocity(-9.81f);

        if (GetInput(E_INPUTS.MOVE_BOX, inputs))
        {
            return(E_PLAYER_STATES.MOVEING_BLOCK);
        }

        if (GetInput(E_INPUTS.JUMP, inputs))
        {
            m_data.SetYVelocity(m_jumpSpeed);

            return(E_PLAYER_STATES.IN_AIR);
        }

        return(E_PLAYER_STATES.ON_GROUND);
    }
示例#12
0
    protected void MoveHorzontal(float _speed, S_inputStruct inputs)
    {
        //m_data.m_velocity.x += _speed * /*Mathf.Abs*/(inputs.m_movementVector.x);
        m_data.AddVelocity(_speed * inputs.m_movementVector.x, 0.0f, 0.0f);

        if (inputs.m_movementVector.x != 0.0f)
        {
            if (inputs.m_movementVector.x > 0.0f == !m_data.m_left_right)
            {
                m_data.m_left_right = !m_data.m_left_right;
                ///gameObject.transform.Rotate(new Vector3(0.0f, 180.0f));
                ///m_data.SetRotation(gameObject.transform.rotation);

                //transform.rotation *= Quaternion.Euler(Vector3.up * 180.0f);
                m_data.SetRotation(gameObject.transform.rotation * Quaternion.Euler(Vector3.up * 180.0f));

                ///transform.rotation = charicterRot;
                ///m_data.SetRotation(charicterRot);
                ///m_data.m_velocity.x += _speed;
            }
        }
    }
示例#13
0
    public void GetInputs(S_inputStruct inputs)
    {
        if (m_data.m_preloadedInputs.Count > 0)
        {
            m_inputs = m_data.m_preloadedInputs[0];
            m_data.m_preloadedInputs.RemoveAt(0);
        }
        else
        {
            m_inputs = inputs;
        }

        /*if (m_data.m_preloadedJoystickMovements.Count > 0)
         * {
         *  m_JoystickMovement = m_data.m_preloadedJoystickMovements[0];
         *  m_data.m_preloadedJoystickMovements.RemoveAt(0);
         * }
         * else
         * {
         *  m_JoystickMovement = stickMovements;
         * }*/
    }
示例#14
0
    public virtual void Update()
    {
        m_inputs = new S_inputStruct(0);

        if (!m_pause)
        {
            /*if (Input.GetAxisRaw("Horizontal") > 0.0f)
             * {
             *  m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.LEFT);
             * }
             *
             * if (Input.GetAxisRaw("Horizontal") < 0.0f)
             * {
             *  m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.RIGHT);
             * }*/

            //m_JoystickMovement |= (char)((int)E_JOYSTICK_INPUTS.HORIZONTAL * GetThirdOfAxis(Input.GetAxisRaw("Horizontal")));
            m_inputs.m_movementVector.x = Input.GetAxisRaw("Horizontal");

            /*if (Input.GetAxisRaw("Vertical") > 0.0f)
             * {
             *  m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.UP);
             * }
             *
             * if (Input.GetAxisRaw("Vertical") < 0.0f)
             * {
             *  m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.DOWN);
             * }*/

            //m_JoystickMovement |= (char)((int)E_JOYSTICK_INPUTS.VERTICAL * GetThirdOfAxis(Input.GetAxisRaw("Vertical")));
            m_inputs.m_movementVector.y = Input.GetAxisRaw("Vertical");

            // can't be consolidated into one axis as they will need diffrent behavior in 2D

            /*if ((Input.GetAxisRaw("Mouse X") + Input.GetAxisRaw("Right Stick X")) > 0.0f)
             * {
             *  m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.LEFT_2);
             * }
             *
             * if ((Input.GetAxisRaw("Mouse X") + Input.GetAxisRaw("Right Stick X")) < 0.0f)
             * {
             *  m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.RIGHT_2);
             * }*/

            //m_JoystickMovement |= (char)((int)E_JOYSTICK_INPUTS.HORIZONTAL_2 * GetThirdOfAxis(Input.GetAxisRaw("Mouse X") + Input.GetAxisRaw("Right Stick X")));
            m_inputs.m_cameraVector.x = Input.GetAxisRaw("Mouse X") + Input.GetAxisRaw("Right Stick X");
            //Debug.Log("Mouse: " + Input.GetAxisRaw("Mouse X"));

            if (Input.GetButton("Jump"))
            {
                m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.JUMP);
            }

            if (Input.GetButtonDown("MoveBox"))
            {
                m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.MOVE_BOX);
            }

            if (Input.GetButton("MoveBox"))
            {
                m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.MOVE_BOX_HOLD);
            }

            if (Input.GetButtonDown("PressButton"))
            {
                m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.PRESS_BUTTON);
            }

            if (Input.GetButtonDown("ResetCamera"))
            {
                m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.RESET_CAMERA);
            }

            if (Input.GetButtonDown("Ghost1") || Input.GetButtonDown("Ghost2"))
            {
                m_ghostButtonTimer.Play();
            }

            if (Input.GetAxis("Change Gravity") > 0.5f)
            {
                m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.CHANGE_GRAVITY);
                Debug.Log("Change Gravity");
            }

            if (Input.GetAxis("Cancel Gravity Change") > 0.5f)
            {
                m_inputs.m_buttons |= (char)InputToBit(E_INPUTS.CANCEL_GRAVITY_CHANGE);
                Debug.Log("Cancel Gravity Change");
            }

            // this sometimes gives a null refrence error when reloading the game after falling from the world, though it dosen't seem to affect gameplay
            if (m_ghostButtonTimer.m_playing)
            {
                m_ghostButtonTimer.Cycle();

                if (m_ghostButtonTimer.m_completed)
                {
                    m_ghostButtonTimer.m_playing = false;
                    //m_inputs |= (char)InputToBit(E_INPUTS.GHOST_BUTTON_HOLD);

                    GhostStateMachine nextGhost = GetNextGhost();

                    if (nextGhost != m_currentGhost)
                    {
                        if (m_currentGhost)
                        {
                            m_currentGhost.EndRecording();
                        }

                        nextGhost.m_overrideRecording = true;
                        ActivateGhost(nextGhost);

                        if (m_currentGhost)
                        {
                            m_ghostList.m_ghostInUse[m_currentGhost.m_id] = true;
                        }

                        m_currentGhost = nextGhost;
                    }
                    else
                    {
                        nextGhost.m_overrideRecording = true;
                        ActivateGhost(nextGhost);
                    }

                    if (nextGhost)
                    {
                        m_currentGhost = nextGhost;
                    }
                }
                else if (Input.GetButtonUp("Ghost1") || Input.GetButtonUp("Ghost2"))
                {
                    m_ghostButtonTimer.m_playing = false;
                    //m_inputs |= (char)InputToBit(E_INPUTS.GHOST_BUTTON_PRESS);

                    GhostStateMachine nextGhost = GetNextGhost();

                    if (!m_currentGhost)
                    {
                        ActivateGhost(nextGhost);
                    }
                    else if (m_currentGhost != nextGhost && !nextGhost.m_recorded)
                    {
                        if (m_currentGhost)
                        {
                            m_currentGhost.EndRecording();
                        }

                        ActivateGhost(nextGhost);

                        m_ghostList.m_ghostInUse[m_currentGhost.m_id] = true;
                        m_currentGhost = nextGhost;
                    }
                    else if (m_currentGhost != nextGhost)
                    {
                        ActivateGhost(nextGhost);
                    }
                    else // m_currentGhost == nextGhost
                    {
                        m_currentGhost.EndRecording();
                    }

                    if (nextGhost)
                    {
                        m_currentGhost = nextGhost;
                    }
                }
            }
        }
        else
        {
            m_inputs.m_buttons = (char)0;
        }

        if (m_currentGhost)
        {
            if (!m_currentGhost.m_recording)
            {
                m_currentGhost = null;
            }
        }

        m_player.GetInputs(new S_inputStruct(0));

        for (int z = 0; z < m_ghostList.m_ghostsCreated; z++)
        {
            m_ghostList.m_ghostStateMachines[z].GetInputs(new S_inputStruct(0));
        }

        if (m_currentGhost)
        {
            m_currentGhost.GetInputs(m_inputs);
            m_player.m_data.m_overideFollow = m_currentGhost.m_data;
        }
        else
        {
            m_player.GetInputs(m_inputs);
            m_player.m_data.m_overideFollow = null;
        }

        m_player.Cycle();

        for (int z = 0; z < m_ghostList.m_ghostsCreated; z++)
        {
            m_ghostList.m_ghostStateMachines[z].Cycle();
        }
    }
示例#15
0
 public virtual E_PLAYER_STATES InTrigger(string _tag, S_inputStruct inputs)
 {
     return(E_PLAYER_STATES.NULL);
 }
示例#16
0
 public virtual E_PLAYER_STATES PhysCycle(S_inputStruct inputs)
 {
     return(E_PLAYER_STATES.NULL);
 }
示例#17
0
 public virtual bool GetInput(E_INPUTS input, S_inputStruct inputs)
 {
     return((inputs.m_buttons & (char)InputToBit(input)) > 0);
 }