Esempio n. 1
0
        public void Update()
        {
            GamePadState gamepadState = GamePad.GetState(PlayerIndex.One);

            int iInput = (int)gamepadState.ThumbSticks.Left.Y;

            if (iInput != iPreviousInput)
            {
                if (iInput != 0)
                {
                    CAudioManager.Instance.PlaySound("menucursor");
                }

                if (iInput > 0 && iSelectedItem > 0)
                {
                    iSelectedItem--;
                }
                else if (iInput < 0 && iSelectedItem < sMenuItems.Count - 1)
                {
                    iSelectedItem++;
                }
            }

            if (CInputManager.ButtonPressed(CSettings.Instance.gPJump))
            {
                CAudioManager.Instance.PlaySound("menuselect1");

                //CLoadingScreen.Instance.PrepareLevelData(sMenuItems[iSelectedItem].Split('\\')[1]);
                CGame.Instance.InitiateFadeLevel(sMenuItems[iSelectedItem]);
                //bLanded = false;
            }

            iPreviousInput = iInput;
        }
Esempio n. 2
0
    public static CInputManager Instance()
    {
        IntPtr        cPtr = testPINVOKE.CInputManager_Instance();
        CInputManager ret  = (cPtr == IntPtr.Zero) ? null : new CInputManager(cPtr, false);

        return(ret);
    }
Esempio n. 3
0
 private void Awake()
 {
     if (!_instance)
     {
         _instance = this;
     }
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            CInputManager.Update();

            /*if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
             *  Exit();*/

            if (CurrentGameState == GameState.Menu)
            {
                CMenu.Instance.Update();
            }
            else if (CurrentGameState == GameState.Loading)
            {
                CLoadingScreen.Instance.Update();
                if (CLoadingScreen.Instance.hasFinishedLoading)
                {
                    CurrentGameState = GameState.Menu;
                }
            }
            else if (CurrentGameState == GameState.Game)
            {
                CObjectManager.Instance.Update();

                CScenarioManager.Instance.Update();

                if (CInputManager.ButtonPressed(CSettings.Instance.gGPause) || CInputManager.KeyPressed(CSettings.Instance.kGPause))
                {
                    CurrentGameState = GameState.Paused;
                }
            }
            else if (CurrentGameState == GameState.Paused)
            {
                CPauseMenu.Instance.Update();

                if (CInputManager.ButtonPressed(CSettings.Instance.gGPause) || CInputManager.KeyPressed(CSettings.Instance.kGPause))
                {
                    CurrentGameState = GameState.Game;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.L))
                {
                    CGame.Instance.InitiateFadeLevel("Test2");
                }
            }

            if (CurrentGameState != GameState.Loading)
            {
                CGame.Instance.UpdateFade();
            }
            //updating the object list

            //updating the HUD
            //CHud.Instance.Update();

            base.Update(gameTime);
        }
Esempio n. 6
0
        private void MovementGamepad(GamePadState gamepadState)
        {
            fHInput = gamepadState.ThumbSticks.Left.X;
            fVInput = gamepadState.ThumbSticks.Left.Y;

            fHInput2 = gamepadState.ThumbSticks.Right.X;
            fVInput2 = gamepadState.ThumbSticks.Right.Y;

            if (CInputManager.ButtonPressed(CSettings.Instance.gPJump) && bLanded)
            {
                fZSpeed = fJumpSpeed;
                CAudioManager.Instance.PlaySound("footstep_solid1");
                //bLanded = false;
            }
        }
Esempio n. 7
0
    public void Start()
    {
        if (_inst != null && _inst != this)
        {
            Destroy(this.gameObject);
            return;
        }

        DontDestroyOnLoad(this);

        _inst = this;

        //Debug.Log("creating new input manager");

        getDevices();

        // Suscribe to device attachment.
        InputManager.OnDeviceAttached += InputManager_OnDeviceAttached;
        InputManager.OnDeviceDetached += InputManager_OnDeviceDetached;
    }
Esempio n. 8
0
        public void Update()
        {
            GamePadState gamepadState = GamePad.GetState(PlayerIndex.One);

            int iInput = (int)gamepadState.ThumbSticks.Left.Y;

            if (iInput != iPreviousInput)
            {
                if (iInput != 0)
                {
                    CAudioManager.Instance.PlaySound("menucursor");
                }

                if (iInput > 0 && iSelectedItem > 0)
                {
                    iSelectedItem--;
                }
                else if (iInput < 0 && iSelectedItem < sMenuItems.Count - 1)
                {
                    iSelectedItem++;
                }
            }

            if (CInputManager.ButtonPressed(CSettings.Instance.gPJump))
            {
                CAudioManager.Instance.PlaySound("menuselect1");

                MethodInfo method = typeof(CPauseMenu).GetMethod(sMenuCommands[iSelectedItem]);

                if (method != null)
                {
                    method.Invoke(this, new List <string>().ToArray());
                }
            }

            iPreviousInput = iInput;
        }
Esempio n. 9
0
        // コンストラクタ

        internal CPad(CConfigIni configIni, CInputManager mgrInput)
        {
            this.rConfigIni    = configIni;
            this.rInputManager = mgrInput;
            this.stDetectedDevices.Clear();
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
 internal static HandleRef getCPtr(CInputManager obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 12
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //lightBatch = new SpriteBatch(GraphicsDevice);

            this.IsMouseVisible = true;

            screenBatch  = new SpriteBatch(GraphicsDevice);
            renderTarget = new RenderTarget2D(GraphicsDevice, CSettings.Instance.GAME_VIEW_WIDTH, CSettings.GAME_VIEW_HEIGHT, false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents);

            CLoadingScreen.Instance.game = this;

            BlendState bs = new BlendState();

            bs.AlphaSourceBlend       = Blend.One;
            bs.AlphaDestinationBlend  = Blend.Zero;
            bs.ColorSourceBlend       = Blend.Zero;
            bs.ColorDestinationBlend  = Blend.One;
            bs.AlphaBlendFunction     = BlendFunction.Add;
            GraphicsDevice.BlendState = bs;

            CInputManager.InitKeys();

            //setting up CSpritebasics...
            CSprite.Instance.content        = Content;
            CSprite.Instance.sbSpriteBatch  = spriteBatch;
            CSprite.Instance.graphicsDevice = GraphicsDevice;
            CSprite.Instance.graphics       = graphics;
            //loading the debug texture...
            CSprite.Instance.LoadTextureSheetRaw("AssetData/Textures", "empty");
            //loading the loading screen so we don't crash while loading assets
            //CSprite.Instance.LoadTextureSheet("LoadingScreen");
            CSprite.Instance.LoadTextureSheetRaw("AssetData/Textures/Frontend", "LoadingScreen");
            //loading a font for testing
            CSprite.Instance.LoadTextureSheetRaw("AssetData/Textures/Frontend", "spritefont");
            CSprite.Instance.LoadTextureSheetRaw("AssetData/Textures/Frontend", "numeric_font");
            CSprite.Instance.LoadTextureSheetRaw("AssetData/Textures/Frontend", "choco_health");
            CSprite.Instance.LoadTextureSheetRaw("AssetData/Textures/Frontend", "hud_natsa");
            CSprite.Instance.LoadTextureSheetRaw("AssetData/Textures/Frontend", "radar");
            //loading screen stuff NEEDS to be loaded here! it can't be loaded in during runtime, it'll just crash.

            //setting up 3D and loading debug cube
            CRender.Instance.content        = Content;
            CRender.Instance.graphics       = graphics;
            CRender.Instance.graphicsDevice = GraphicsDevice;
            CRender.Instance.Init();

            CRender.Instance.LoadTextureRaw("AssetData/Textures", "empty");
            //debug: loading some essential models

            //DEBUG: creating objects that aren't configured to be loaded in CLevel yet
            CObjectManager.Instance.CreateInstance(typeof(CCamera), 0, 10, -30);
            CObjectManager.Instance.CreateInstance(typeof(CPlayer), 5, 20, 5);
            CObjectManager.Instance.CreateInstance(typeof(CNatsa), 5, 20, 5);
            CObjectManager.Instance.CreateInstance(typeof(CNatsa), 20, 20, 5);
            CObjectManager.Instance.CreateInstance(typeof(CNatsa), 5, 20, 20);
            CObjectManager.Instance.CreateInstance(typeof(CNatsa), 20, 20, 20);
            CObjectManager.Instance.CreateInstance(typeof(CNatsa), 20, 30, 30);
            CObjectManager.Instance.CreateInstance(typeof(CCollidable), 30, 20, 30);
            //CObjectManager.Instance.CreateInstance(typeof(CCollidable), 20, 40, 30);
            //CObjectManager.Instance.CreateInstance(typeof(CEnemy), 16, 16);

            //debug
            CParticleManager.Instance.LoadParticleData();

            CLoadingScreen.Instance.Load();
        }