void ModifySpeed(float scale)
    {
        float speed = 16.0f;
        float dt    = FrameController.DT();

        scale *= thumbstickMagnitude; // scale the supposed speed on the thumbstick mag

        Vector3 dir = playerCamera.transform.GetForwardVector();

        dir.Y = 0;
        dir.Normalize(); // direction for z axis
        Vector3 right = playerCamera.transform.GetRightVector();

        right.Y = 0;
        right.Normalize(); // direction for x axis

        Vector3 currVel          = playerPhysics.rigidCom.Body().LinearVelocity();
        float   currentYVelocity = currVel.Y;

        Vector3 newVel = new Vector3();  // has no y component here

        newVel  = right * speedX;        // update X
        newVel += dir * speedZ;          // update Z
        newVel.Normalize();
        newVel = newVel * scale * speed; // scalar for velocity (less speed in air)

        if (smc.GetCurrentState() == jump)
        {
            float limitSpeedInJump = speedWhenJumped * speed;

            newVel   = currVel + newVel * dt;
            newVel.X = MathHelper.Clamp(newVel.X, -limitSpeedInJump, limitSpeedInJump);
            newVel.Z = MathHelper.Clamp(newVel.Z, -limitSpeedInJump, limitSpeedInJump);
        }
        else
        {
            newVel.Y = 0;//currentYVelocity;
        }
        playerPhysics.rigidCom.Body().SetLinearVelocity(newVel * dt * 30.0f);

#if ZERO
        float max = 33.0f;
        // cap it to max
        if (newVel.LengthSquared() < max * max)
        {
            newVel.Y = yVel;
            playerPhysics.rigidCom.Body().SetLinearVelocity(newVel);
        }
        else
        {
            newVel.Normalize();
            newVel  *= max;
            newVel.Y = yVel;
            playerPhysics.rigidCom.Body().SetLinearVelocity(newVel);
        }
#endif
    }
Esempio n. 2
0
 public void Kill()
 {
     if (smc.GetCurrentState() != dying)
     {
         smc.SetState(dying);
     }
 }
Esempio n. 3
0
    /// /////////

    public void TransitionUp(Paper p)
    {
        if (smc.GetCurrentState() != idle)
        {
            return;
        }
        //takes the place of the state_start
        paperMesh.setEnabled(true);
        paperMesh.mMaterial.SetTexture(p.PaperTexture);

        //might be reference checks
        gameObject.transform.SetPosition(p.gameObject.transform.position);
        downPos = p.gameObject.transform.position;
        gameObject.transform.rotation.Angles = p.gameObject.transform.rotation.Angles;
        downRot = gameObject.transform.rotation.Angles;

        smc.SetState(transitionUp);
        isPaperSelected = true;
    }
Esempio n. 4
0
    public void OnCollisionEnter(CollisionData data)
    {
        if (smc.GetCurrentState() == flyingTowardsWall &&
            data.collidedObj.GetID() != player.GetID())
        {
            CPhysics phyComp = data.collidedObj.GetComponent <CPhysics>();
            if (phyComp != null && !phyComp.mIsTriggered)
            {
                Logger.Log("Collided with: " + data.collidedObj.GetName());

                OnCollidingAgainstWall(data.collidedObj);
                hasHitWall = true;
            }
        }
    }
    public void OnUpdate()
    {
        gameObject.transform.LookAt(stealth_player.transform.position);

        checkLightTimer++;
        if (checkLightTimer > 4)
        {
            if (smc.GetCurrentState() != panicking && helper.CheckLights(gameObject))
            {
                //we are in the light
                smc.SetState(panicking);
            }
            checkLightTimer = 0;
        }
        smc.Update();
    }
Esempio n. 6
0
 public void S_Light_Update()
 {
     light.mIntensity = MMath.Cerp(mBeginInten, mTargetIntensity, smc.GetCurrentState().GetPercentageTime());
 }
 public bool GetIsDead()
 {
     return(smc.GetCurrentState() == dead);
 }