private void InputCheck() { if (currentControlScheme != Globals.controlScheme) // change control scheme only when the setting is changed { currentControlScheme = Globals.controlScheme; CheckControlScheme(); } Vector2 movement = Vector2.Zero; #if WINDOWS if (Globals.input.KeyPressed(MoveRight)) { movement.X = 1; Direction = FacingDirection.Right; } else if (Globals.input.KeyPressed(MoveLeft)) { movement.X = -1; Direction = FacingDirection.Left; } if (Globals.input.KeyPressed(MoveUp)) { movement.Y = -1; Direction = FacingDirection.Up; } else if (Globals.input.KeyPressed(MoveDown)) { movement.Y = 1; Direction = FacingDirection.Down; } #endif if (Globals.input.ButtonPressed(PlayerIndex.One, Buttons.DPadRight) || Globals.input.ButtonPressed(PlayerIndex.One, Buttons.LeftThumbstickRight)) { movement.X = 1; Direction = FacingDirection.Right; } else if (Globals.input.ButtonPressed(PlayerIndex.One, Buttons.DPadLeft) || Globals.input.ButtonPressed(PlayerIndex.One, Buttons.LeftThumbstickLeft)) { movement.X = -1; Direction = FacingDirection.Left; } if (Globals.input.ButtonPressed(PlayerIndex.One, Buttons.DPadUp) || Globals.input.ButtonPressed(PlayerIndex.One, Buttons.LeftThumbstickUp)) { movement.Y = -1; Direction = FacingDirection.Up; } else if (Globals.input.ButtonPressed(PlayerIndex.One, Buttons.DPadDown) || Globals.input.ButtonPressed(PlayerIndex.One, Buttons.LeftThumbstickDown)) { movement.Y = 1; Direction = FacingDirection.Down; } if (movement != Vector2.Zero) { movement.Normalize(); UpdateSpriteAnimation(movement); SpriteAnimation.IsAnimating = true; } else SpriteAnimation.IsAnimating = false; SpriteAnimation.Position += SpriteAnimation.Speed * movement; LastMovement = SpriteAnimation.Speed * movement; #if WINDOWS if (Globals.input.KeyPressed(Keys.D1) || (Globals.red == 1 && Globals.blue == 0 && Globals.green == 0)) selectedSpell = SelectedSpell.fire; else if (Globals.input.KeyPressed(Keys.D2) || (Globals.red == 0 && Globals.blue == 0 && Globals.green == 1)) selectedSpell = SelectedSpell.wind; #endif if(Globals.red == 1 && Globals.blue == 1) if (Globals.input.ButtonPressed(PlayerIndex.One, Buttons.LeftShoulder) || Globals.input.ButtonPressed(PlayerIndex.One, Buttons.RightShoulder)) { if (selectedSpell == SelectedSpell.fire) selectedSpell = SelectedSpell.wind; else selectedSpell = SelectedSpell.fire; } CastSpell(); /* if (Globals.input.KeyJustPressed(Keys.I)) Globals.I_AM_INVINCIBLE = !Globals.I_AM_INVINCIBLE; if (Globals.input.KeyJustPressed(Keys.U)) Globals.UNLIMITED_MANA = !Globals.UNLIMITED_MANA; */ }
public override void Initialize() { SpriteAnimation = new AnimatedSprite(Globals.content.Load<Texture2D>("Sprites/Player/man1")); FrameAnimation up = new FrameAnimation(2, 32, 32, 0, 0); up.FramesPerSecond = 10; SpriteAnimation.Animations.Add("Up", up); FrameAnimation down = new FrameAnimation(2, 32, 32, 64, 0); down.FramesPerSecond = 10; SpriteAnimation.Animations.Add("Down", down); FrameAnimation left = new FrameAnimation(2, 32, 32, 128, 0); left.FramesPerSecond = 10; SpriteAnimation.Animations.Add("Left", left); FrameAnimation right = new FrameAnimation(2, 32, 32, 192, 0); right.FramesPerSecond = 10; SpriteAnimation.Animations.Add("Right", right); SpriteAnimation.CurrentAnimationName = "Down"; Direction = FacingDirection.Down; selectedSpell = SelectedSpell.none; currentControlScheme = Globals.controlScheme; CheckControlScheme(); Collidable = true; CollisionRadius = 64; stopwatch = new Stopwatch(); }