Beispiel #1
0
 void OnInputEscape(M8.InputManager.Info data)
 {
     if (data.state == M8.InputManager.State.Released)
     {
         Close();
     }
 }
Beispiel #2
0
        void OnInputJump(InputManager.Info dat)
        {
            //jumpWall
            if (dat.state == InputManager.State.Pressed)
            {
                if (isUnderWater || isOnLadder)
                {
                    mJump = true;
                }
                else if (jumpWall && collisionFlags == CollisionFlags.Sides)
                {
                    bool        found = false;
                    CollideInfo inf   = new CollideInfo();

                    for (int i = 0; i < mCollCount; i++)
                    {
                        CollideInfo cInf = mColls[i];
                        if (cInf.flag == CollisionFlags.Sides)
                        {
                            if (Vector3.Angle(dirHolder.forward, cInf.normal) > 120.0f)
                            {
                                inf   = cInf;
                                found = true;
                                break;
                            }
                        }
                    }

                    if (found)
                    {
                        Vector3 jumpDir = inf.normal + dirHolder.up;

                        if (jumpImpulse > 0.0f)
                        {
                            ClearCollFlags();
                            mBody.drag = airDrag;
                            mBody.AddForce(jumpDir * jumpImpulse, ForceMode.Impulse);
                        }

                        mJump         = true;
                        mJumpLastTime = Time.fixedTime;

                        float a = M8.MathUtil.AngleForwardAxisDir(dirHolder.worldToLocalMatrix, Vector3.forward, inf.normal);
                        dirHolder.rotation *= Quaternion.AngleAxis(a, Vector3.up);
                        EyeOrient();
                        //TurnTo(inf.normal);
                    }
                }
                else if (!mJump)
                {
                    if (isUnderWater || isOnLadder)
                    {
                        mJump = true;
                    }
                    else if (!isSlopSlide)
                    {
                        if (isGrounded)
                        {
                            if (jumpImpulse > 0.0f)
                            {
                                ClearCollFlags();
                                mBody.drag = airDrag;
                                mBody.AddForce(dirHolder.up * jumpImpulse, ForceMode.Impulse);
                            }

                            mJump         = true;
                            mJumpLastTime = Time.fixedTime;
                        }
                    }
                }
            }
            else if (dat.state == InputManager.State.Released)
            {
                mJump = false;
            }
        }