public Main() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; m_CurrentGameState = GameState.Game; m_InputHandler = new InputHandler(4); m_MenuState = new StateMenu("Menu"); m_Sprites = new Dictionary<string, Texture2D>(); m_Fonts = new Dictionary<string, SpriteFont>(); INSTANCE = this; }
public override void Update(GameTime pGameTime, ref InputHandler pInputHandler) { base.Update(pGameTime, ref pInputHandler); }
public virtual void Update(GameTime pGameTime, ref InputHandler pInputHandler, Level.Level pLevel) { Vector2 currentPosition = this.Position; if (m_PlayerType == PlayerType.Local) { // When past a certain threshold then move with the given constant added on. if (pInputHandler.GetInput(this.m_PlayerIndex).ThumbSticks.Left.X > 0.15f) { this.m_Direction = Direction.Right; this.m_Action = ActionFlag.Running; this.m_Position.X += RUN_SPEED; } // Same again, but opposite direction. if (pInputHandler.GetInput(this.m_PlayerIndex).ThumbSticks.Left.X < -0.15) { this.m_Direction = Direction.Left; this.m_Action = ActionFlag.Running; this.m_Position.X += -RUN_SPEED; } // Make sure the stick is within the deadzone before declaring the character as idle. if (pInputHandler.GetInput(this.m_PlayerIndex).ThumbSticks.Left.X < 0.15f && pInputHandler.GetInput(this.m_PlayerIndex).ThumbSticks.Left.X > -0.15f) { m_Action = ActionFlag.Idle; } if (pInputHandler.isButtonDown(this.m_PlayerIndex, Buttons.A)) { //Console.WriteLine("Player: Jump"); this.m_Action = ActionFlag.Jump; } #region Frame Handling switch (m_Action) { case ActionFlag.Running: m_FrameIndex.Y = 2; if (m_FrameIndex.X == 0) { m_FrameIndex.X = 1; } // Increase the counter m_FrameChangeCounter += (float) pGameTime.ElapsedGameTime.TotalMilliseconds; // Has the counter exceeded the rate at which we want the animations to animate? if (m_FrameChangeCounter > m_FrameChangeRate) { m_FrameChangeCounter = 0; m_FrameIndex.X++; } // Out of animation bound -- restart. if (m_FrameIndex.X > 2) { m_FrameIndex.X = 1; } break; case ActionFlag.Jump: m_FrameChangeCounter = 0; m_FrameIndex.X = 0; m_FrameIndex.Y = 3; break; case ActionFlag.Crouch: m_FrameIndex.X = 0; m_FrameIndex.Y = 3; break; case ActionFlag.Walking: // Define the row that we want to animate from m_FrameIndex.Y = 2; if (m_FrameIndex.X > 3) { m_FrameIndex.X = 0; } else { m_FrameIndex.X++; } break; case ActionFlag.Idle: m_FrameIndex.Y = 2; m_FrameIndex.X = 0; m_FrameChangeCounter = 0f; break; } #endregion // Check for collisions with the level here. // If there is a collision with the lev } else if (m_PlayerType == PlayerType.Net) { // Receive the data from the internets! // } base.Update(pGameTime, ref pInputHandler); }
public override void Update(GameTime pGameTime, ref InputHandler pInputHandler) { // For saving the level to a text file temporarily. if (pInputHandler.isKeyboardDown(Keys.Home)) { new Thread(new ThreadStart(delegate() { m_GameLevel.SaveLevelAsTextFile(); })).Start(); } #if DEBUG // Move the camera around a little bit. if (pInputHandler.isKeyboardDown(Keys.Down)) { m_CameraManager.ActiveCamera().Position -= new Vector2(0, 2.5f); Console.WriteLine("Down arrow was activated. {0}",pGameTime.TotalGameTime.TotalMilliseconds); } if (pInputHandler.isKeyboardDown(Keys.Up)) { m_CameraManager.ActiveCamera().Position -= new Vector2(0, -2.5f); Console.WriteLine("Up arrow was activated."); } if (pInputHandler.isKeyboardDown(Keys.Left)) { m_CameraManager.ActiveCamera().Position -= new Vector2(-2.5f, 0); Console.WriteLine("left arrow was activated."); } if (pInputHandler.isKeyboardDown(Keys.Right)) { m_CameraManager.ActiveCamera().Position -= new Vector2(2.5f, 0.0f); // Console.WriteLine("right arrow was activated."); } if (pInputHandler.isKeyboardDown(Keys.PageUp)) { m_CameraManager.ActiveCamera().Position -= new Vector2(-2.5f, 0); //Console.WriteLine("left arrow was activated."); } #endif this.m_GameLevel.Update(pGameTime, ref pInputHandler); base.Update(pGameTime,ref pInputHandler); }
public override void Update(GameTime pGameTime, ref InputHandler pInputHandler) { m_MenuManager.Update(pGameTime, ref pInputHandler); base.Update(pGameTime, ref pInputHandler); }
public void Update(GameTime pGameTime, ref InputHandler pInputHandler) { throw new NotImplementedException(); }
public void Update(GameTime pGameTime, ref InputHandler pInputHandler) { // Select item on the list properly. if (pInputHandler.isButtonDown(PlayerIndex.One, Buttons.DPadDown)) { Console.WriteLine("Dpad was touched"); NextItem(); } if (pInputHandler.isButtonDown(PlayerIndex.One, Buttons.DPadUp)) { Console.WriteLine("Dpad was touched"); PreviousItem(); } if (pInputHandler.isButtonDown(PlayerIndex.One, Buttons.A)) { Main.INSTANCE.CurrentGameState = (GameState)m_SelectionIndex; } }
public virtual void Update(GameTime pGameTime, ref InputHandler pInputHandler) { }
public void Update(GameTime pGameTime,ref InputHandler pInputHandler) { // Update the players. for (int i = 0; i < m_Players.Count; i++) { m_Players[i].Update(pGameTime, ref pInputHandler,this); } }
public override void Update(GameTime pGameTime, ref InputHandler pInputHandler) { // If the rate is met, then increase the index. if (pGameTime.TotalGameTime.TotalMilliseconds % m_FrameIncreaseRate == 0) { m_FrameIndex.X++; } throw new NotImplementedException(); }
public override void Update(GameTime pGameTime, ref InputHandler pInputHandler) { // Determine that the active state exists within the states provided. if (this.m_ActiveState != "" && this.m_States.ContainsKey(m_ActiveState)) { Enemy _enemy = this; this.m_States[m_ActiveState].m_Action(ref _enemy); } base.Update(pGameTime, ref pInputHandler); }