public MenuScreen(Screen parentScreen, ContentManager m, string title, Vector2i pos, bool centeredX, bool centeredY, bool bordered, bool hasBackground, Color backgroundColor) { this.ParentScreen = parentScreen; this.ButtonColor = Color.Black; this.BackGroudColor = backgroundColor; this.TitleFont = m.Media.loadFont("Content/fonts/sweetness.ttf"); this.ButtonFont = m.Media.loadFont("Content/fonts/sweetness.ttf"); this.TitleSize = 90; this.ButtonSize = 55; this.buttons = new List<MenuButton>(); this.Title = new Text(title, TitleFont, TitleSize); Title.Origin = new Vector2f(Title.GetLocalBounds().Left, Title.GetLocalBounds().Top); this.bounds = new Rectangle(pos.X, pos.Y, 0,0); this.isBordered = bordered; this.isCenteredX = centeredX; this.isCenteredY = centeredY; this.IsDrawn = true; this.IsUpdated = true; this.hasBackground = hasBackground; this.BackGroudColor = backgroundColor; setButtons(); }
public MainMenuScreen(Vector2u gameResolution, Vector2u windowResolution) { this.GameResolution = gameResolution; this.WindowResolution = windowResolution; this.IsDrawn = true; this.IsUpdated = true; this.ParentScreen = null; //mPlayer = new MusicPlayer(); //mPlayer.add("bg", new Music(@"Content/music/never_short.ogg")); //mPlayer.currentMusic.Volume = 50; //mPlayer.currentMusic.Loop = true; //mPlayer.play(); contentManager = new ContentManager(Game1.defaultWorldParameters); IO.loadLevel(contentManager, @"Content/levels/menuLevel.xml"); backGround = new Sprite(contentManager.Media.loadTexture("Content/images/bg.jpg", true)); backGround.Scale = new Vector2f(gameResolution.X / (float)backGround.Texture.Size.X, gameResolution.Y / (float)backGround.Texture.Size.Y); lightLayer = new LightLayer(this.GameResolution, this.WindowResolution); lightLayer.add(new Light(new Vector2f(700, 350), new Color(255, 255, 200), .55f)); lightLayer.add(new Light(new Vector2f(1920 - 700, 350), new Color(255, 255, 200), .55f)); contentManager.foreceBlocks(); lightLayer.setPolygons(contentManager.getLightPolygons()); mainMenu = new MenuScreen(this, this.contentManager, null, new Vector2i(0, 0), true, true, false); mainMenu.Title.Color = Color.Black; mainMenu.ButtonColor = Color.Black; mainMenu.addButtons(new string[] { "Play", "Level Editor", "Options", "Help", "Credits", "Quit"}); mainMenu.MouseClick += mainMenu_ButtonClick; mainMenu.MouseEnter += mainMenu_MouseEnter; mainMenu.MouseLeave += mainMenu_MouseLeave; }
public Player(ContentManager content, float x, float y, float width, float height) { this.ContentManager = content; this.Ppm = content.Ppm; this.InitialPosition = new Vector2((x + ( width / 2)) / Ppm, (y + (width /2)) / Ppm); this.Body = BodyFactory.CreateRectangle(content.World, width / Ppm, height / Ppm, 1); Body.Position = new Vector2((x + width / 2f) / Ppm, (y + height / 2f) / Ppm); Body.BodyType = BodyType.Dynamic; this.staminaBox = new Rectangle(x, y - 20, width, 10); this.Stamina = 1; this.PositionBox = new Rectangle(x, y, width, height); this.Shape = (PolygonShape)Body.FixtureList[0].Shape; this.Vertices = new List<Vector2>(); this.updateVerts(); this.IsDrawn = true; this.IsActive = true; this.IsCollidable = true; this.Id = 0; this.Color = Color.Red; this.Texture = ContentManager.Media.loadTexture(@"Content\images\player.png", true); Texture.Smooth = false; }
public override void Dispose() { this.ChildScreens.Clear(); this.ChildScreens = null; this.contentManager.Dispose(); this.contentManager = null; this.guide = null; this.lightLayer.Dispose(); this.lightLayer = null; this.ofd.Dispose(); this.ofd = null; this.pannel.Dispose(); this.pannel = null; this.ParentScreen = null; this.pauseMenu.Dispose(); this.pauseMenu = null; this.sfd.Dispose(); this.sfd = null; this.view.Dispose(); this.view = null; }
public override void Dispose() { this.contentManager.Dispose(); this.contentManager = null; this.lightLayer.Dispose(); this.lightLayer = null; this.mainMenu.Dispose(); this.mainMenu = null; this.mPlayer = null; this.ParentScreen = null; }
public override void Dispose() { ParentScreen = null; foreach (Screen s in ChildScreens) s.Dispose(); ChildScreens.Clear(); ChildScreens = null; this.contentManager.Dispose(); this.contentManager = null; this.lightLayer.Dispose(); this.lightLayer = null; }
public SelectorPannel(Screen parent, ContentManager c,GuideBlock g) { this.ParentScreen = parent; this.GameResolution = parent.GameResolution; this.WindowResolution = parent.WindowResolution; this.contentManager = c; this.guide = g; this.IsDrawn = true; this.IsUpdated = true; this.ChildScreens = null; this.state = States.showing; this.currentButton = null; this.Color = new Color(200, 200, 200, 255); this.PositionBox = new Rectangle(0, -300, 1920, 400); addButtons(); }
public Tile(ContentManager c, float x, float y, float width, float height) { this.Ppm = c.Ppm; this.Body = BodyFactory.CreateRectangle(c.World, width / Ppm, height / Ppm, 1); Body.Position = new Vector2((x + width / 2f) / Ppm, (y + height / 2f) / Ppm); Body.BodyType = BodyType.Static; this.Shape = (PolygonShape)Body.FixtureList[0].Shape; this.Vertices = new List<Vector2>(); this.updateVerts(); this.PositionBox = new Rectangle(x, y, width, height); this.IsActive = true; this.IsDrawn = true; this.IsCollidable = true; this.Color = Color.Green; this.Id = 1; }
private static void loadBlock(int id, float[] info, ContentManager c) { switch (id) { case 0: c.add(new Player(c, info[0], info[1], info[2], info[3])); break; case 1: c.add(new Tile(c, info[0], info[1], info[2], info[3])); break; case 2: c.add(new ExitTile(c, info[0], info[1], info[2], info[3])); break; case 3: c.add(new Tip(c, info[0], info[1], info[2], info[3])); break; } }
public static void loadLevel(ContentManager c, String path) { c.clear(); XmlDocument reader = new XmlDocument(); reader.Load(path); int id = 0; float[] blockInfo = new float[4]; foreach(XmlNode node in reader.DocumentElement) { foreach(XmlNode child in node.ChildNodes) { id = int.Parse(child.Attributes[0].Value); blockInfo[0] = float.Parse(child.Attributes[1].Value); blockInfo[1] = float.Parse(child.Attributes[2].Value); blockInfo[2] = float.Parse(child.Attributes[3].Value); blockInfo[3] = float.Parse(child.Attributes[4].Value); loadBlock(id, blockInfo, c); } } reader.Clone(); }
public static void saveLevel(String path, ContentManager c) { XmlDocument writer = new XmlDocument(); XmlNode rootNode = writer.CreateElement("Level"); XmlNode blocksNode = writer.CreateElement("Blocks"); foreach(Entity e in c.Entities) { XmlNode block = writer.CreateElement("Entity"); XmlAttribute at = writer.CreateAttribute("id"); at.InnerText = e.Id.ToString(); block.Attributes.Append(at); Rectangle pos = e.PositionBox; at = writer.CreateAttribute("x"); at.InnerText = pos.x.ToString(); block.Attributes.Append(at); at = writer.CreateAttribute("y"); at.InnerText = pos.y.ToString(); block.Attributes.Append(at); at = writer.CreateAttribute("w"); at.InnerText = pos.width.ToString(); block.Attributes.Append(at); at = writer.CreateAttribute("h"); at.InnerText = pos.height.ToString(); block.Attributes.Append(at); blocksNode.AppendChild(block); } rootNode.AppendChild(blocksNode); writer.AppendChild(rootNode); writer.Save(path); }
public ExitTile(ContentManager c, float x, float y, float width, float height) { this.ContentManager = c; this.Ppm = c.Ppm; this.Body = BodyFactory.CreateRectangle(c.World, width / Ppm, height / Ppm, 1); Body.Position = new Vector2((x + width / 2f) / Ppm, (y + height / 2f) / Ppm); Body.BodyType = BodyType.Dynamic; Body.OnCollision += Body_OnCollision; this.PositionBox = new Rectangle(x, y, width, height); this.Shape = (PolygonShape)Body.FixtureList[0].Shape; this.Vertices = new List<Vector2>(); this.updateVerts(); this.IsActive = true; this.IsDrawn = true; this.IsCollidable = true; this.Color = new Color(0, 0, 255); this.Texture = ContentManager.Media.loadTexture(@"Content\images\surge.png", true); this.Id = 2; }
public LevelEditorScreen(Screen screen) { this.ParentScreen = screen; this.GameResolution = ParentScreen.GameResolution; this.WindowResolution = ParentScreen.WindowResolution; this.ChildScreens = new List<Screen>(); this.IsDrawn = true; this.IsUpdated = true; //this.level = null; this.showGrid = true; //this.blocksPaused = true; this.lightLayer = new LightLayer(this.GameResolution, this.WindowResolution); this.contentManager = new ContentManager(Game1.defaultWorldParameters); this.guide = new GuideBlock(this.contentManager); this.view = new View(new FloatRect(0, 0, this.GameResolution.X, this.GameResolution.Y)); loadMenus(); }
public GameScreen(Screen parentScreen) { this.GameResolution = parentScreen.GameResolution; this.WindowResolution = parentScreen.WindowResolution; this.ParentScreen = parentScreen; this.IsDrawn = true; this.IsUpdated = true; this.contentManager = new ContentManager(Game1.defaultWorldParameters); contentManager.LevelWon += contentManager_LevelWon; IO.loadLevel(this.contentManager, "Content/levels/level1.xml"); this.currentLevel = 1; this.lightLayer = new LightLayer(this.GameResolution, this.WindowResolution); lightLayer.Lights.Add(new Light(new Vector2f(100, 100), Color.White, .4f)); this.sp = new Sprite(contentManager.Media.loadTexture("Content/images/bg.jpg", true)); sp.Scale = new Vector2f(this.GameResolution.X / (float)sp.TextureRect.Width, this.GameResolution.Y / (float)sp.TextureRect.Height); loadMenuScreens(); }
public Tip(ContentManager c, float x, float y, float width, float height) { this.ContentManager = c; this.InitialPosition = new Vector2(x / Ppm, y / Ppm); this.Ppm = c.Ppm; this.Body = BodyFactory.CreateRectangle(c.World, width / Ppm, height / Ppm, 1); Body.Position = new Vector2((x + width / 2f) / Ppm, (y + height / 2f) / Ppm); Body.BodyType = BodyType.Static; Body.CollidesWith = Category.None; Body.OnCollision += Body_OnCollision; this.PositionBox = new Rectangle(x, y, width, height); this.Shape = (PolygonShape)Body.FixtureList[0].Shape; this.Vertices = new List<Vector2>(); this.updateVerts(); this.Color = Color.Yellow; this.Id = 3; this.IsActive = true; this.IsDrawn = true; this.IsCollidable = false; }
public MenuScreen(Screen parentScreen, ContentManager m, string title, Vector2i pos) : this(parentScreen, m, title, pos, true, true, false, false, Color.White) { }
public GuideBlock(ContentManager content) { this.state = States.placingScaleableBlock; this.type = SelectorButton.Types.Tile; this.contentManager = content; }
public void update(ContentManager content) { this.Polygons = content.getLightPolygons(); }
public MenuScreen(Screen parentScreen, ContentManager m, string title, Vector2i pos, bool centeredX, bool centeredY, bool bordered) : this(parentScreen, m, title, pos, centeredX, centeredY, bordered, false, Color.White) { }