public void PickUp() { if (pickUp == null) { pickUp = EntityFinder.GetEnt(Position + EntityFinder.GetDir(Flipped, 16, 0)); if (pickUp != null && !pickUp.Movable) { pickUp = null; } if (pickUp != null) { pickUp.BounceC = 5; SoundMan.PlaySound("pickup", Position); pickUp.Carried = true; } } else { if (EntityFinder.GetEnt(Position + EntityFinder.GetDir(Flipped, 16, 0)) == null) { pickUp.Position = Position + EntityFinder.GetDir(Flipped, 16, 0); pickUp.Carried = false; pickUp = null; } } }
public override void Act() { base.Act(); for (int i = 0; i < 3; i++) { Entity ent = EntityFinder.GetEnt(new Vector2f(Position.X, Position.Y - 14 - i * 16)); if (ent is Player) { Player player; player = (Player)ent; player.OnLadder = true; } } Entity ent2 = EntityFinder.GetEnt(new Vector2f(Position.X, Position.Y - 16 - 34)); { if (ent2 is Player) { Player player; player = (Player)ent2; player.OnLadder = true; if (player.Position.Y <= Position.Y - 16 - 48) { player.OnTopOfLadder = true; } } } }
public void BlowUp() { ScreenShake = true; Entity a = EntityFinder.GetEnt(new Vector2f(Position.X - 16, Position.Y)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } a = EntityFinder.GetEnt(new Vector2f(Position.X + 16, Position.Y)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } a = EntityFinder.GetEnt(new Vector2f(Position.X, Position.Y - 16)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } a = EntityFinder.GetEnt(new Vector2f(Position.X, Position.Y + 16)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } a = EntityFinder.GetEnt(new Vector2f(Position.X - 16, Position.Y + 16)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } a = EntityFinder.GetEnt(new Vector2f(Position.X - 16, Position.Y - 16)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } a = EntityFinder.GetEnt(new Vector2f(Position.X + 16, Position.Y - 16)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } a = EntityFinder.GetEnt(new Vector2f(Position.X + 16, Position.Y + 16)); if (a != null && !(a is Dynamite)) { a.Destroyed = true; } Destroyed = true; }
public void Loop(RenderWindow window) { counter++; CursorPosF = new Vector2f(CursorPos.X * 16, CursorPos.Y * 16 + 8); Level.ScrollTo(CursorPosF, false); Level.GetEntities().RemoveAll(a => a.Destroyed); Type entType = Level.EntityTypes[currentEnt]; cursorEnt = (Entity)Activator.CreateInstance(entType, CursorPos); if (buttonDelay == 0) { if (Keyboard.IsKeyPressed(Keyboard.Key.F3) || Keyboard.IsKeyPressed(Keyboard.Key.F5) || Keyboard.IsKeyPressed(Keyboard.Key.F1) ) { showTextWindow = !showTextWindow; if (Keyboard.IsKeyPressed(Keyboard.Key.F3)) { textInputOperation = TextInputOperation.Save; } if (Keyboard.IsKeyPressed(Keyboard.Key.F5)) { textInputOperation = TextInputOperation.Load; } if (Keyboard.IsKeyPressed(Keyboard.Key.F1)) { textInputOperation = TextInputOperation.InfoBox; } if (textInputOperation == TextInputOperation.Save || textInputOperation == TextInputOperation.Load) { textInputString = LevelName; } bool addEvent = true; if (textInputOperation == TextInputOperation.InfoBox) { Entity ent = EntityFinder.GetEnt(new Vector2f(CursorPosF.X + 8, CursorPosF.Y - 8)); if (ent != null && ent is InfoBox) { InfoBox infoBox = (InfoBox)ent; textInputString = infoBox.InfoString; } else { showTextWindow = false; addEvent = false; } } if (addEvent) { if (showTextWindow) { window.TextEntered += TextEntered; } else { window.TextEntered -= TextEntered; } } buttonDelay = 20; } if (showTextWindow) { if (Keyboard.IsKeyPressed(Keyboard.Key.Return)) { if (textInputOperation == TextInputOperation.Save) { LevelName = textInputString; Level.SaveLevel(LevelName); } if (textInputOperation == TextInputOperation.Load) { LevelName = textInputString; Level.LoadLevel(LevelName, true); CollisionMan.Entities = Level.GetEntities(); EntityFinder.Entities = Level.GetEntities(); } if (textInputOperation == TextInputOperation.InfoBox) { Entity ent = EntityFinder.GetEnt(new Vector2f(CursorPosF.X + 8, CursorPosF.Y - 8)); if (ent != null && ent is InfoBox) { InfoBox infoBox = (InfoBox)ent; infoBox.InfoString = textInputString; } } showTextWindow = false; window.TextEntered -= TextEntered; } if (Keyboard.IsKeyPressed(Keyboard.Key.Escape)) { showTextWindow = false; window.TextEntered -= TextEntered; } } } if (buttonDelay == 0 && !showTextWindow) { if (Keyboard.IsKeyPressed(Keyboard.Key.Z)) { if (currentEnt > 0) { currentEnt--; } buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.X)) { if (currentEnt < Level.EntityTypes.Count - 1) { currentEnt++; } buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.F12)) { Level.GetEntities().Clear(); buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.Delete)) { Entity ent = EntityFinder.GetEnt(new Vector2f(CursorPosF.X + 8, CursorPosF.Y - 8)); if (ent != null) { ent.Destroyed = true; } buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.F)) { Entity ent = EntityFinder.GetEnt(new Vector2f(CursorPosF.X + 8, CursorPosF.Y - 8)); if (ent != null) { ent.Flipped = !ent.Flipped; } buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.Space)) { Entity ent = EntityFinder.GetEnt(new Vector2f(CursorPosF.X + 8, CursorPosF.Y - 8)); if (ent != null) { ent.Destroyed = true; } Entity newEnt = (Entity)Activator.CreateInstance(entType, CursorPos); Level.GetEntities().Add(newEnt); buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.Right)) { CursorPos = new Vector2i(CursorPos.X + 1, CursorPos.Y); buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.Left)) { CursorPos = new Vector2i(CursorPos.X - 1, CursorPos.Y); buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.Up)) { CursorPos = new Vector2i(CursorPos.X, CursorPos.Y - 1); buttonDelay = 10; } if (Keyboard.IsKeyPressed(Keyboard.Key.Down)) { CursorPos = new Vector2i(CursorPos.X, CursorPos.Y + 1); buttonDelay = 10; } } if (buttonDelay > 0) { buttonDelay--; } }