public RunningCharacterState(Scene scene, Character character) : base(scene, character) { texture = scene.Game.Content.Load<Texture2D>("running"); characterWidth = texture.Width / 10;// 8; characterHeight = texture.Height / 2;///5; character.texture = texture; textureXmin = 0; textureYmin = 0; }
public ClimbingCharacterState(Scene scene, Character character) : base(scene, character) { texture = scene.Game.Content.Load<Texture2D>("climbing"); characterWidth = texture.Width / 7; characterHeight = texture.Height; character.texture = texture; textureXmin = 0; textureYmin = 0; }
public FallingCharacterState(Scene scene, Character character) : base(scene, character) { texture = scene.Game.Content.Load<Texture2D>("falling"); characterWidth = texture.Width / columns; characterHeight = texture.Height / rows; character.texture = texture; textureXmin = 0; textureYmin = 0; }
public JumpingCharacterState(Scene scene, Character character) : base(scene, character) { texture = scene.Game.Content.Load<Texture2D>("jumpingStart"); characterWidth = texture.Width / 5; characterHeight = texture.Height; character.texture = texture; textureXmin = 0; textureYmin = 0; }
public DyingCharacterState(Scene scene, Character character) : base(scene, character) { texture = scene.Game.Content.Load<Texture2D>("dyingGas"); columns = 5; rows = 4; totalFrames = 16; characterWidth = (int)(texture.Width / columns); characterHeight = (int)(texture.Height / rows); character.texture = texture; textureXmin = 0; textureYmin = 0; }
public override void Update(GameTime gameTime) { if (Selection != null && IsFocusOnWindow()) { float speed = Conversion.ToWorld(1); if (Keyboard.GetState().IsKeyDown(Keys.LeftShift)) speed = Conversion.ToWorld(20); if (Keyboard.GetState().IsKeyDown(Keys.OemBackslash)) speed = Conversion.ToWorld(0.02f); if (Keyboard.GetState().IsKeyDown(Keys.W)) Selection.Position = Selection.Position - Vector2.UnitY * speed; if (Keyboard.GetState().IsKeyDown(Keys.S)) Selection.Position = Selection.Position + Vector2.UnitY * speed; if (Keyboard.GetState().IsKeyDown(Keys.A)) Selection.Position = Selection.Position - Vector2.UnitX * speed; if (Keyboard.GetState().IsKeyDown(Keys.D)) Selection.Position = Selection.Position + Vector2.UnitX * speed; if (Keyboard.GetState().IsKeyDown(Keys.Add) && Keyboard.GetState().IsKeyDown(Keys.LeftControl)) Selection.Height = Selection.Height + speed; else if (Keyboard.GetState().IsKeyDown(Keys.Add)) Selection.Width = Selection.Width + speed; if (Keyboard.GetState().IsKeyDown(Keys.Subtract) && Keyboard.GetState().IsKeyDown(Keys.LeftControl)) Selection.Height = Math.Max(0.001f, Selection.Height - speed); else if (Keyboard.GetState().IsKeyDown(Keys.Subtract)) Selection.Width = Math.Max(0.001f, Selection.Width - speed); if (Keyboard.GetState().IsKeyDown(Keys.Delete) || Keyboard.GetState().IsKeyDown(Keys.Back)) { selection.Dispose(); Selection = null; } if (Keyboard.GetState().IsKeyDown(Keys.W) || Keyboard.GetState().IsKeyDown(Keys.S) || Keyboard.GetState().IsKeyDown(Keys.A) || Keyboard.GetState().IsKeyDown(Keys.D) || Keyboard.GetState().IsKeyDown(Keys.Add) || Keyboard.GetState().IsKeyDown(Keys.Subtract)) { form.Selection = selection; } } if (Mouse.GetState().LeftButton == ButtonState.Pressed && previous.LeftButton == ButtonState.Released && IsMouseInWindow(Mouse.GetState())) { Console.WriteLine(scene.Camera.ScreenToWorld(Mouse.GetState())); Element newSelection = null; List<Element> elements = new List<Element>(); elements.AddRange(scene.Elements); foreach (Element i in elements) { if (Vector2.Distance(scene.Camera.WorldToScreen(i.Position), new Vector2(Mouse.GetState().X, Mouse.GetState().Y)) < 8) { newSelection = i; Console.WriteLine("Selected one at " + i.Position + ", Width " + i.Width + ", Height " + i.Height); break; } } if (newSelection != Selection) Selection = newSelection; else Selection = null; } if (Mouse.GetState().RightButton == ButtonState.Pressed && previous.RightButton == ButtonState.Released) { Element element = null; switch (form.NewElementType) { case "Platform": element = new Platform(Game, scene, scene.Camera.ScreenToWorld(previous), Vector2.One); break; case "Bridge": element = new Bridge(Game, scene, scene.Camera.ScreenToWorld(previous), Vector2.One); break; case "Ladder": element = new Ladder(Game, scene, 1, scene.Camera.ScreenToWorld(previous)); break; case "Character": element = new Character(Game, scene, scene.Camera.ScreenToWorld(previous)); scene.Camera.Target = element; //scene.InputManager.Target = (Character)element; break; } if (element != null) scene.Elements.Add(element); } previous = Mouse.GetState(); }
public CharacterState(Scene scene, Character character) { this.character = character; this.scene = scene; }