protected void SetupUISystems() { uis = new UISystem[] { new UISystem(new List <Button>()//menu { new Button("null", new Rectangle(0, 0, 224, 160), new TextureDrawer(Content.Load <Texture2D>("Placeholder/actualtitle"))), new Button("startGame", new Rectangle(12, 118, 60, 20), SpriteSheetCollection.GetTex("play", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button")), new Button("quit", new Rectangle(14, 136, 60, 20), SpriteSheetCollection.GetTex("exitbutton", "miscsheet1", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button")), }), new UISystem(new List <Button>()), //game new UISystem(new List <Button>() //pause { new Button("null", new Rectangle(0, 0, 224, 160), new TextureDrawer(Content.Load <Texture2D>("Placeholder/pause"))), new Button("returnToMenu", new Rectangle(120, 100, 60, 20), SpriteSheetCollection.GetTex("menu", "menuresume", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button")), new Button("retry", new Rectangle(40, 100, 60, 20), SpriteSheetCollection.GetTex("retry", "retry", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button")) }), new UISystem(new List <Button>()//death { new Button("null", new Rectangle(0, 0, 224, 160), new TextureDrawer(Content.Load <Texture2D>("Placeholder/dead"))), new Button("returnToMenu", new Rectangle(120, 100, 60, 20), SpriteSheetCollection.GetTex("menu", "menuresume", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button")), new Button("retry", new Rectangle(40, 100, 60, 20), SpriteSheetCollection.GetTex("retry", "retry", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button")), }), new UISystem(new List <Button>()//tutorial { new Button("null", new Rectangle(0, 0, 224, 160), new TextureDrawer(Content.Load <Texture2D>("UI/Image1"))), new Button("startGame", new Rectangle(168, 137, 44, 15), SpriteSheetCollection.GetTex("play", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button"), SpriteSheetCollection.GetTex("pressed", "playpressed", "button")), }), }; }
void CreateGod() { EntityCollection.AddEntity( new God( new DrawerCollection(new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "god", "god"), SpriteSheetCollection.GetTex("attack", "god", "god"), SpriteSheetCollection.GetTex("swipe", "swipe", "swipe") }, "tex"), new PositionManager(new Vector2(40, 20)), new List <Property>(), "god", "god")); }
void LoadBGs() { mainMenuBG = SpriteSheetCollection.GetTex("bg", "PlaceholderBGs", "menu"); gameBG = SpriteSheetCollection.GetTex("bg", "PlaceholderBGs", "game"); pauseBG = SpriteSheetCollection.GetTex("bg", "PlaceholderBGs", "pause"); endBG = SpriteSheetCollection.GetTex("bg", "PlaceholderBGs", "end"); tutorialBG = SpriteSheetCollection.GetTex("bg", "PlaceholderBGs", "tutorial"); goodEnding = SpriteSheetCollection.GetTex("ending", "endings", "good"); destructionEnding = SpriteSheetCollection.GetTex("ending", "endings", "destroyed"); revoltEnding = SpriteSheetCollection.GetTex("ending", "endings", "revolted"); starvationEnding = SpriteSheetCollection.GetTex("ending", "endings", "starved"); cultEnding = SpriteSheetCollection.GetTex("ending", "endings", "awakened"); }
} //update the clicky things void CreateVillager(string type_) { if (GameData.availableCitizens > 0) { EntityCollection.AddEntity(new Villager( new DrawerCollection(new List <TextureDrawer>() { SpriteSheetCollection.GetTex("normal", "villager", "villager") }, "texes"), new PositionManager(new Vector2(360, 100)), new List <Property>(), "c**t", type_ )); } }
} //check whatever is plugged in to create input settings protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); ElementCollection.ReadDocument(XDocument.Load("Content/Xml/Registry.xml")); SpriteSheetCollection.LoadFromElementCollection(Content); cursorTex = SpriteSheetCollection.GetTex("static", "PlaceholderSheet", "cursor"); icons = SpriteSheetCollection.GetTex("idle", "buttons", "question"); meterTex = new TextureDrawer(Content.Load <Texture2D>("Placeholder/meter")); cloudTex = new TextureDrawer(Content.Load <Texture2D>("Sprites/clouds")); dd = TextureDrawer.FromHorizontalStrip(Content.Load <Texture2D>("Placeholder/Daytime"), 39); mm = TextureDrawer.FromHorizontalStrip(Content.Load <Texture2D>("Placeholder/MM"), 39); LoadBGs(); CreateUI(); SoundManager.AddSong(Content.Load <Song>("Audio/PrototypeMusic3"), "game"); //SoundManager.AddSong(Content.Load<Song>("Audio/tinymusic"), "game"); SoundManager.AddSong(Content.Load <Song>("Audio/MenuTrack"), "main"); SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/build"), "build"); SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/church_victory"), "win"); SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/loss"), "lose"); SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/sacrifice"), "sacrifice"); SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/delevel"), "destroy"); gameBg = SpriteSheetCollection.GetTex("bg", "gameBgs", "bg"); clouds = SpriteSheetCollection.GetTex("clouds", "gameBgs", "bg"); mountains = SpriteSheetCollection.GetTex("fg", "gameBgs", "bg"); aendingAnim = SpriteSheetCollection.GetTex("bg", "endingSheet", "bg"); gded = SpriteSheetCollection.GetTex("bg", "churchEndingSheet", "bg"); SoundManager.PlaySong("main"); ParticleSystem.AcquireTxture(SpriteSheetCollection.GetTex("smoke", "smoke", "smoke")); CreateNewGame(); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); //LOAD XML ElementCollection.ReadDocument(XDocument.Load("Content/XML/Items.xml")); ElementCollection.ReadDocument(XDocument.Load("Content/XML/MiscEntities.xml")); ElementCollection.ReadDocument(XDocument.Load("Content/XML/Pickups.xml")); ElementCollection.ReadDocument(XDocument.Load("Content/XML/Spritesheets.xml")); SpriteSheetCollection.ReadDocument(XDocument.Load("Content/XML/Spritesheets.xml"), Content); SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit1"), "hit1"); SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit2"), "hit2"); SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit3"), "hit3"); SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit4"), "hit4"); SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit5"), "hit5"); SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit6"), "hit6"); SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit7"), "hit7"); SoundManager.AddSong(Content.Load <Song>("Music/dungeonrun"), "gamesong"); SoundManager.AddSong(Content.Load <Song>("Music/menusong"), "menusong"); SoundManager.PlaySong("menusong"); RecipeBook.ReadDocument(XDocument.Load("Content/XML/Recipes.xml")); //LOAD TEXTURES ParticleSystem.AcquireTxture(SpriteSheetCollection.GetTex("appear", "slotappears", "slot")); ParticleSystem.AcquireTxture(SpriteSheetCollection.GetTex("stars", "miscsheet1", "particle")); scoretex = SpriteSheetCollection.GetTex("score", "score", "button"); //LOAD SOUND //LOAD ENTITIES //LOAD UR MOM SetupUISystems(); //END - SETUP THE GAME! SetupGame(); }
} //update things based on game state void UpdateGame(float es_) { ParticleSystem.UpdateAll(es_); EntityCollection.UpdateAll(es_); gameTick.Update(es_); if (gameTick.Complete()) { GameData.Tick(); gameTick.Reset(); } villagerTick.Update(es_); if (villagerTick.Complete()) { if (GameData.citizensOutside < GameData.MaxVillagers) { CreateVillager("c**t"); } villagerTick.time = (float)rng.Next(3, 15); villagerTick.Reset(); } UpdateHoveredLocation(); if (GameData.madness >= 90 && !GameData.cultExists) { GameData.cultExists = true; Building cult = new Building( new DrawerCollection( new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "defBuildings", "cult"), SpriteSheetCollection.GetTex("idle", "defBuildings", "cult"), SpriteSheetCollection.GetTex("idle", "defBuildings", "cult") }, "cult"), new PositionManager(new Vector2(46, 24)), new List <Property>(), 5, "cult", "" ); EntityCollection.AddEntity(cult); } changeTooltipText = true; bool x = false; foreach (Building building in EntityCollection.GetGroup("buildings")) { if (building.Name == "cult") { building.hoveredText = ""; } else if (building.Name == "bridge") { building.hoveredText = "the god's anger is at " + GameData.godAnger.ToString() + " and his hunger is at " + GameData.godHunger.ToString() + ". you currently have " + GameData.TotalCitizens.ToString() + " villagers. Appease the god?"; } else { building.hoveredText = GameData.UpgradeCost(building.Name) + ". Level:" + GameData.LevelOfBuilding(building.Name).ToString(); } if (!x && new Rectangle(building.posman.pos.ToPoint(), building.GetBounds().Size).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos()))) { if (cursor.GetClicked() && GameData.CanUpgrade(building.Name)) { if (!building.wasClicked) { switch (building.Name) { case "field": //CreateVillager("farmer"); if (GameData.CanUpgrade("field")) { GameData.Upgrade("field"); } SoundManager.PlayEffect("build"); break; case "mine": //CreateVillager("miner"); if (GameData.CanUpgrade("mine")) { GameData.Upgrade("mine"); } SoundManager.PlayEffect("build"); break; case "forest": //CreateVillager("lumberjack"); if (GameData.CanUpgrade("forest")) { GameData.Upgrade("forest"); } SoundManager.PlayEffect("build"); break; case "city": if (GameData.CanUpgrade("city")) { GameData.Upgrade("city"); } SoundManager.PlayEffect("build"); break; case "church": if (GameData.CanUpgrade("church")) { GameData.Upgrade("church"); } SoundManager.PlayEffect("build"); break; case "bridge": foreach (God god in EntityCollection.GetGroup("god")) { god.Attack(); } break; } } building.Click(); } else { if (building.hoveredText != null) { tooltipText = building.hoveredText; changeTooltipText = false; } if (GameData.CanUpgrade(building.Name)) { building.isHovered = true; } } x = true; } else { building.isHovered = false; } } if (new Rectangle(10, 165, 100, 10).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos()))) { tooltipText = "The village's madness is at " + GameData.madness.ToString() + "/100"; changeTooltipText = false; } else if (new Rectangle(135, 165, 50, 10).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos())) && GameData.cultExists) { tooltipText = GameData.daysUntilDoom.ToString() + " days until doom."; changeTooltipText = false; } else if (new Rectangle(260, 165, 100, 10).Contains(scenes.GetScene("base").ToVirtualPos(cursor.RawPos()))) { tooltipText = "Next day in " + Math.Ceiling(gameTick.timer).ToString() + " s"; changeTooltipText = false; } } //update the movey things
} //create whatever's needed to start a new game void CreateUI() { //NOTE: CREATE BUTTON VARIANTS mainUI = new UISystem(new List <Button>() { new Button("startGame", new Rectangle(220, 42, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "play"), SpriteSheetCollection.GetTex("pressed", "buttons", "play"), SpriteSheetCollection.GetTex("hovered", "buttons", "play") ), new Button("tutorial", new Rectangle(220, 82, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "square"), SpriteSheetCollection.GetTex("pressed", "buttons", "square"), SpriteSheetCollection.GetTex("hovered", "buttons", "square") ), new Button("exitGame", new Rectangle(220, 122, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "quit"), SpriteSheetCollection.GetTex("pressed", "buttons", "quit"), SpriteSheetCollection.GetTex("hovered", "buttons", "quit") ) } ); endgameUI = new UISystem(new List <Button>() { new Button("mainMenu", new Rectangle(144, 140, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "menu"), SpriteSheetCollection.GetTex("pressed", "buttons", "menu"), SpriteSheetCollection.GetTex("hovered", "buttons", "menu") ), new Button("restartGame", new Rectangle(68, 140, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "restart"), SpriteSheetCollection.GetTex("pressed", "buttons", "restart"), SpriteSheetCollection.GetTex("hovered", "buttons", "restart") ), new Button("exitGame", new Rectangle(220, 140, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "quit"), SpriteSheetCollection.GetTex("pressed", "buttons", "quit"), SpriteSheetCollection.GetTex("hovered", "buttons", "quit") ), } ); tutorialUI = new UISystem(new List <Button>() { new Button("startGame", new Rectangle(64, 160, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "play"), SpriteSheetCollection.GetTex("pressed", "buttons", "play"), SpriteSheetCollection.GetTex("hovered", "buttons", "play") ), new Button("mainMenu", new Rectangle(224, 160, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "menu"), SpriteSheetCollection.GetTex("pressed", "buttons", "menu"), SpriteSheetCollection.GetTex("hovered", "buttons", "menu") ) } ); pauseUI = new UISystem(new List <Button>() { new Button("resumeGame", new Rectangle(60, 120, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "play"), SpriteSheetCollection.GetTex("pressed", "buttons", "play"), SpriteSheetCollection.GetTex("hovered", "buttons", "play") ), new Button("mainMenu", new Rectangle(144, 120, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "menu"), SpriteSheetCollection.GetTex("pressed", "buttons", "menu"), SpriteSheetCollection.GetTex("hovered", "buttons", "menu") ), new Button("restartGame", new Rectangle(228, 120, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "restart"), SpriteSheetCollection.GetTex("pressed", "buttons", "restart"), SpriteSheetCollection.GetTex("hovered", "buttons", "restart") ) } ); gameUI = new UISystem(new List <Button>() { new Button("pauseGame", new Rectangle(288, 0, 32, 16), SpriteSheetCollection.GetTex("idle", "buttons", "pause"), SpriteSheetCollection.GetTex("pressed", "buttons", "pause"), SpriteSheetCollection.GetTex("hovered", "buttons", "pause") ) } ); }
void CreateNewGame() { ParticleSystem.Flush(); EntityCollection.Flush(); GameData.Initialize(); CreateGod(); Building church = new Building( new DrawerCollection( new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "defBuildings", "church"), SpriteSheetCollection.GetTex("hovered", "defBuildings", "church"), SpriteSheetCollection.GetTex("idle", "defBuildings", "church") }, "church"), new PositionManager(new Vector2(217, 8)), new List <Property>(), .1f, "church", "this is a building" ); Building field = new Building( new DrawerCollection( new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "defBuildings", "farm"), SpriteSheetCollection.GetTex("hovered", "defBuildings", "farm"), SpriteSheetCollection.GetTex("clicked", "defBuildings", "farm") }, "field"), new PositionManager(new Vector2(53, 131)), new List <Property>(), .1f, "field", "this is a building" ); Building mine = new Building( new DrawerCollection( new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "defBuildings", "mine"), SpriteSheetCollection.GetTex("hovered", "defBuildings", "mine"), SpriteSheetCollection.GetTex("idle", "defBuildings", "mine") }, "mine"), new PositionManager(new Vector2(31, 55)), new List <Property>(), .1f, "mine", "this is a building" ); Building forest = new Building( new DrawerCollection( new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "defBuildings", "forest"), SpriteSheetCollection.GetTex("hovered", "defBuildings", "forest"), SpriteSheetCollection.GetTex("idle", "defBuildings", "forest") }, "forest"), new PositionManager(new Vector2(0, 89)), new List <Property>(), .1f, "forest", "this is a building" ); Building city = new Building( new DrawerCollection( new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "defBuildings", "city"), SpriteSheetCollection.GetTex("hovered", "defBuildings", "city"), SpriteSheetCollection.GetTex("clicked", "defBuildings", "city") }, "city"), new PositionManager(new Vector2(204, 112)), new List <Property>(), .1f, "city", "this is a building" ); Building bridge = new Building( new DrawerCollection( new List <TextureDrawer>() { SpriteSheetCollection.GetTex("idle", "defBuildings", "bridge"), SpriteSheetCollection.GetTex("hovered", "defBuildings", "bridge"), SpriteSheetCollection.GetTex("clicked", "defBuildings", "bridge") }, "bridge"), new PositionManager(new Vector2(111, 133)), new List <Property>(), .1f, "bridge", "this is a building" ); EntityCollection.CreateGroup("building", "buildings"); EntityCollection.CreateGroup("c**t", "villagers"); EntityCollection.CreateGroup("god", "god"); EntityCollection.AddEntities(new List <Entity>() { church, field, mine, forest, city, bridge }); } //create whatever's needed to start a new game