Beispiel #1
0
        public override void Update()
        {
            int iCameraRot = 0;

            if (CInputManager.KeyDown(CSettings.Instance.kCRotateCamRight) || CInputManager.ButtonDown(CSettings.Instance.gCRotateCamRight))
            {
                iCameraRot = -1;
            }
            else if (CInputManager.KeyDown(CSettings.Instance.kCRotateCamLeft) || CInputManager.ButtonDown(CSettings.Instance.gCRotateCamLeft))
            {
                iCameraRot = 1;
            }

            int iCameraVRot = 0;

            if (CInputManager.KeyDown(CSettings.Instance.kCRotateCamUp) || CInputManager.ButtonDown(CSettings.Instance.gCRotateCamUp))
            {
                iCameraVRot = -1;
            }
            else if (CInputManager.KeyDown(CSettings.Instance.kCRotateCamDown) || CInputManager.ButtonDown(CSettings.Instance.gCRotateCamDown))
            {
                iCameraVRot = 1;
            }

            /*if (keyboardState.IsKeyDown(Keys.Enter) && cameraState == CameraStates.LevelStart)
             * {
             *  cameraState = CameraStates.PlayerControlled;
             * }*/

            /*if (iCameraRot != 0 || iCameraVRot != 0)
             *  PlayerCamera(iCameraRot, iCameraVRot);
             * else
             *  AutoCamera();*/

            CameraBehaviour();

            /*if (cameraState == CameraStates.LevelStart)
             *  LevelCamera();*/
            /*else if (cameraState == CameraStates.PlayerControlled)
             * {
             *  if (iCameraRot != 0 || iCameraVRot != 0)
             *      PlayerCamera(iCameraRot, -1);
             *  else
             *      AutoCamera();
             *
             *  /*if (keyboardState.IsKeyDown(Keys.X))
             *  {
             *      fCameraRotation = ((CPlayer)oTarget).fDir;
             *  }
             * }*/

            Vector3 lerpVector = Lerp(
                new Vector3(x + distDirX(fCameraDistance, degToRad(fCameraRotation)), z + -distDirY(fCameraDistance, degToRad(fCameraVRotation)), y + distDirY(fCameraDistance, degToRad(fCameraRotation))),
                CRender.Instance.GetCameraPosition(), 0.9f);

            CRender.Instance.SetCameraTarget(TargetVector);
            CRender.Instance.SetCameraPosition(lerpVector);
            //CConsole.Instance.Print("camera rotation " + fCameraVRotation + " rot " + iCameraVRot);
        }
Beispiel #2
0
        public override void Update()
        {
            UpdateCollision();
            hitCylinder.SetPos(new Vector3(x, z, y));

            //floor collision
            CGameObject natsaCollision = CollisionCylinder(typeof(CNatsa));

            if (natsaCollision != null)
            {
                CGame.Instance.CollectNatsa(1);
                CObjectManager.Instance.DestroyInstance(natsaCollision.iIndex);
            }

            //input
            KeyboardState keyboardState = Keyboard.GetState();
            GamePadState  gamepadState  = GamePad.GetState(PlayerIndex.One);


            if (!CSettings.Instance.bGamepadEnabled)
            {
                MovementKeyboard(keyboardState);
            }
            else
            {
                MovementGamepad(gamepadState);
            }

            PlayerPhysics();
            PlayerCollision(fHeightBufferZone, 4.0f);

            if (fHInput2 != 0)
            {
                fAimDir -= (fHInput2 * 0.2f) / (float)Math.PI;
            }

            if (Math.Abs(fVInput2) >= 0.35)
            {
                fLightDistance -= (fVInput2 * 1.5f) / (float)Math.PI;

                if (fLightDistance > fLightMaxDistance)
                {
                    fLightDistance = fLightMaxDistance;
                }
                else if (fLightDistance < fLightMinDistance)
                {
                    fLightDistance = fLightMinDistance;
                }
            }

            //shoob
            if (CInputManager.ButtonDown(CSettings.Instance.gFire))
            {
                if (iShotCooldown <= 0)
                {
                    float xoffs = distDirX(5, fAimDir);
                    float yoffs = distDirY(5, fAimDir);

                    Vector3 bulletSpawnPoint = new Vector3(x + xoffs, z + 7, y + yoffs);

                    CAudioManager.Instance.PlaySound("temp_gunshot");

                    CPlayerBullet bullet = (CPlayerBullet)CObjectManager.Instance.CreateInstance(typeof(CPlayerBullet), bulletSpawnPoint.X, bulletSpawnPoint.Y, bulletSpawnPoint.Z);
                    bullet.SetProperties(fAimDir, 5);

                    CParticleManager.Instance.CreateParticle("part_muzzleflash", bulletSpawnPoint);
                    CParticleManager.Instance.CreateParticle("part_gunsmoke", bulletSpawnPoint);
                    CParticleManager.Instance.CreateParticle("part_bulletcasing", bulletSpawnPoint, new Vector3(distDirX(0.3f, fAimDir - (float)(Math.PI / 2)), 0, distDirY(0.3f, fAimDir - (float)(Math.PI / 2))));

                    iShotCooldown = iShotCooldownMax;
                }

                testframe += 0.25f;
            }

            iShotCooldown--;

            //debug
            CLevel.Instance.UpdateActiveCell(x, y);

            //we don't want to update the animation in Render() because it'll animate while paused
            UpdateAnimation();

            CGame.Instance.UpdatePlayer(new Vector2(x, y));

            vLightTarget = new Vector3(x + distDirX(fLightDistance, fAimDir), z, y + distDirY(fLightDistance, fAimDir));

            CRender.Instance.SetLightPosition(new Vector3(x, z + 10, y), vLightTarget);
        }