void InitializeEditor() { EditorButtons = new List <Button>(); EnemyButtons = new List <EnemyButton>(); TemplateButtons = new List <TemplateButton>(); EmptyTile = new Tile(Content.Load <Texture2D>("textures/game/tiles/empty"), false); SolidTile = new Tile(Content.Load <Texture2D>("textures/game/tiles/solid"), true); StairsSprite = Content.Load <Texture2D>("textures/game/tiles/stairs"); DoorTile = new Tile(Content.Load <Texture2D>("textures/game/tiles/door"), false); DoorTile.Door = true; EmptyTiles = new Tile[15, 10]; for (int i = 0; i < 15; i++) { for (int j = 0; j < 10; j++) { EmptyTiles[i, j] = EmptyTile.Copy(); } } DoorTiles = new Tile[15, 10]; for (int i = 0; i < 15; i++) { for (int j = 0; j < 10; j++) { DoorTiles[i, j] = EmptyTile.Copy(); } } DoorTiles[0, 4] = DoorTile.Copy(); DoorTiles[0, 5] = DoorTile.Copy(); DoorTiles[7, 0] = DoorTile.Copy(); DoorTiles[7, 9] = DoorTile.Copy(); DoorTiles[14, 4] = DoorTile.Copy(); DoorTiles[14, 5] = DoorTile.Copy(); CurrentTab = Tab.TEMPLATES; CurrentTemplate = new RoomTemplate(EmptyTiles); EditorBackground = Content.Load <Texture2D>("textures/editor/background"); SelectedTab = Content.Load <Texture2D>("textures/editor/buttons/selectedtab"); UnselectedTab = Content.Load <Texture2D>("textures/editor/buttons/unselectedtab"); UnselectedSummary = Content.Load <Texture2D>("textures/editor/buttons/unselectedsummary"); SelectedSummary = Content.Load <Texture2D>("textures/editor/buttons/selectedsummary"); MiniSolid = Content.Load <Texture2D>("textures/editor/template/solid"); MiniEmpty = Content.Load <Texture2D>("textures/editor/template/empty"); MiniItem = Content.Load <Texture2D>("textures/editor/template/item"); MiniDoor = Content.Load <Texture2D>("textures/editor/template/door"); MiniEnemy = Content.Load <Texture2D>("textures/editor/template/enemy"); MiniPrize = Content.Load <Texture2D>("textures/editor/template/prize"); DesciptionBack = Content.Load <Texture2D>("textures/game/descriptor/back"); DesciptionExit = Content.Load <Texture2D>("textures/game/descriptor/exit"); DescriptionSourceBackdrop = Content.Load <Texture2D>("textures/game/descriptor/backdrop"); Enemy1 = Content.Load <Texture2D>("textures/game/creatures/enemy"); EnemySprites[0] = Enemy1; Enemy2 = Content.Load <Texture2D>("textures/game/creatures/enemy2"); EnemySprites[1] = Enemy2; Enemy3 = Content.Load <Texture2D>("textures/game/creatures/enemy3"); EnemySprites[2] = Enemy3; Enemy4 = Content.Load <Texture2D>("textures/game/creatures/enemy4"); EnemySprites[3] = Enemy4; Payout = Content.Load <Texture2D>("textures/editor/payout"); EnemyBackground = Content.Load <Texture2D>("textures/editor/enemybackdrop"); SavedBackground = Content.Load <Texture2D>("textures/editor/saved"); Button templatestabbutton = new Button(SelectedTab, new Vector2(1100, 40), "templatestab", Keys.A); EditorButtons.Add(templatestabbutton); Button enemiestabbutton = new Button(UnselectedTab, new Vector2(1210, 40), "enemiestab", Keys.S); EditorButtons.Add(enemiestabbutton); Button newbutton = new Button(Content.Load <Texture2D>("textures/editor/buttons/new"), new Vector2(1210, 80), "new", Keys.N); EditorButtons.Add(newbutton); Button savebutton = new Button(Content.Load <Texture2D>("textures/editor/buttons/save"), new Vector2(1099, 80), "save", Keys.D); EditorButtons.Add(savebutton); // Button doorbutton = new Button("door", Keys.W); // EditorButtons.Add(doorbutton); Button itembutton = new Button("item", Keys.Q); EditorButtons.Add(itembutton); Button prizebutton = new Button("prize", Keys.E); EditorButtons.Add(prizebutton); Button breaky = new Button("break", Keys.P); EditorButtons.Add(breaky); Button hp = new Button(Content.Load <Texture2D>("textures/editor/buttons/hp"), new Vector2(1085, 640), "hp"); EditorButtons.Add(hp); Button ap = new Button(Content.Load <Texture2D>("textures/editor/buttons/ap"), new Vector2(1155, 640), "ap"); EditorButtons.Add(ap); Button sprite = new Button(Content.Load <Texture2D>("textures/editor/buttons/sprite"), new Vector2(1155, 680), "sprite"); EditorButtons.Add(sprite); Button damage = new Button(Content.Load <Texture2D>("textures/editor/buttons/damage"), new Vector2(1085, 680), "damage"); EditorButtons.Add(damage); Button difficulty = new Button(Content.Load <Texture2D>("textures/editor/buttons/difficulty"), new Vector2(1130, 480), "difficulty"); EditorButtons.Add(difficulty); Button up = new Button("up", Keys.Up); EditorButtons.Add(up); Button down = new Button("down", Keys.Down); EditorButtons.Add(down); Button quit = new Button("quit", Keys.F10); EditorButtons.Add(quit); GenericItem = new HealthPotion(Content.Load <Texture2D>("textures/editor/item")); LoadEditorCreatures(); LoadEditorTemplates(); GameState = State.EDITOR; }
RoomTemplate PickGoodTemplate(int depth) { RoomTemplate result = GoodTemps.ElementAt(Random.Next(0, GoodTemps.Count)); return(result); }
void HandleEditorInput(Button button, bool LeftClick) { if (LeftClick) { switch (button.Action) { case "quit": Quit(); break; case "templatestab": CurrentTab = Tab.TEMPLATES; button.Sprite = SelectedTab; foreach (Button b in EditorButtons) { if (b.Action == "enemy") { ((EnemyButton)b).Visable = false; } else if (b.Action == "enemiestab") { b.Sprite = UnselectedTab; } } ReallignTemplates(); break; case "enemiestab": CurrentTab = Tab.ENEMIES; button.Sprite = SelectedTab; foreach (Button b in EditorButtons) { if (b.Action == "room") { ((TemplateButton)b).Visable = false; } else if (b.Action == "templatestab") { b.Sprite = UnselectedTab; } } ReallignEnemies(); break; case "up": if (CurrentTab == Tab.TEMPLATES) { CurrentTemplateIndex--; if (CurrentTemplateIndex < 0) { CurrentTemplateIndex = 0; } else { foreach (TemplateButton B in TemplateButtons) { B.Position.Y += 51; } } ReallignTemplates(); } else { CurrentEnemyIndex--; if (CurrentEnemyIndex < 0) { CurrentEnemyIndex = 0; } else { foreach (EnemyButton E in EnemyButtons) { E.Position.Y += 51; } } ReallignEnemies(); } break; case "down": if (CurrentTab == Tab.TEMPLATES) { CurrentTemplateIndex++; if (CurrentTemplateIndex > TemplateButtons.Count() - 7) { CurrentTemplateIndex = TemplateButtons.Count() - 7; } else { foreach (TemplateButton B in TemplateButtons) { B.Position.Y -= 51; } } ReallignTemplates(); } else { CurrentEnemyIndex++; if (CurrentEnemyIndex > EnemyButtons.Count() - 7) { CurrentEnemyIndex = EnemyButtons.Count() - 7; } else { foreach (EnemyButton E in EnemyButtons) { E.Position.Y -= 51; } } ReallignEnemies(); } break; case "sprite": if (CurrentEnemy.Sprite == Enemy1) { CurrentEnemy.Sprite = Enemy2; } else if (CurrentEnemy.Sprite == Enemy2) { CurrentEnemy.Sprite = Enemy3; } else if (CurrentEnemy.Sprite == Enemy3) { CurrentEnemy.Sprite = Enemy4; } else if (CurrentEnemy.Sprite == Enemy4) { CurrentEnemy.Sprite = Enemy1; } break; case "hp": CurrentEnemy.HP++; CurrentEnemy.MaxHP++; break; case "damage": CurrentEnemy.Damage++; break; case "break": //Pause to debug break; case "room": if (((TemplateButton)button).Visable && CurrentTab == Tab.TEMPLATES) { foreach (TemplateButton c in TemplateButtons) { c.Sprite = UnselectedSummary; } button.Sprite = SelectedSummary; CurrentTemplate = ((TemplateButton)button).Template; } break; case "enemy": if (((EnemyButton)button).Visable && CurrentTab == Tab.ENEMIES) { foreach (EnemyButton e in EnemyButtons) { e.Sprite = UnselectedSummary; } button.Sprite = SelectedSummary; CurrentEnemy = ((EnemyButton)button).Enemy; } break; case "save": SaveContent(); break; case "new": if (CurrentTab == Tab.TEMPLATES) { CurrentTemplateName = Convert.ToString(Convert.ToInt32(CurrentTemplateName.Split('.')[0]) + 1); TemplateButton result = new TemplateButton(UnselectedSummary, CurrentTemplateName + ".lvl", DoorTiles, 0); TemplateButtons.Add(result); TemplateButtons.Sort(); ReallignTemplates(); } else if (CurrentTab == Tab.ENEMIES) { CurrentCreatureName = Convert.ToString(Convert.ToInt32(CurrentCreatureName.Split('.')[0]) + 1) + ".nme"; EnemyButton result = new EnemyButton(UnselectedSummary, Enemy1, CurrentCreatureName); EnemyButtons.Add(result); EnemyButtons.Sort(); ReallignEnemies(); } break; case "door": for (int i = 0; i < 15; i++) { for (int j = 0; j < 10; j++) { if (MouseOver(i, j)) { CurrentTemplate.Tiles[i, j] = DoorTile.Copy(); } } } break; case "item": for (int i = 0; i < 15; i++) { for (int j = 0; j < 10; j++) { if (MouseOver(i, j)) { HealthPotion newthing = GenericItem.Copy(new Vector2I(i, j), GenericItem.Hash); if (CurrentTemplate.Entities.Contains(newthing)) { CurrentTemplate.Entities.Remove(newthing); } else { CurrentTemplate.Entities.Add(newthing); } } } } break; case "prize": for (int i = 0; i < 15; i++) { for (int j = 0; j < 10; j++) { if (MouseOver(i, j)) { CurrentTemplate.Payout = new Vector2I(i, j); } } } break; case "difficulty": CurrentTemplate.Difficulty++; break; } } else { switch (button.Action) { case "hp": CurrentEnemy.HP--; CurrentEnemy.MaxHP--; break; case "sprite": if (CurrentEnemy.Sprite == Enemy1) { CurrentEnemy.Sprite = Enemy4; } else if (CurrentEnemy.Sprite == Enemy2) { CurrentEnemy.Sprite = Enemy3; } else if (CurrentEnemy.Sprite == Enemy3) { CurrentEnemy.Sprite = Enemy2; } else if (CurrentEnemy.Sprite == Enemy4) { CurrentEnemy.Sprite = Enemy1; } break; case "damage": CurrentEnemy.Damage--; break; case "difficulty": CurrentTemplate.Difficulty--; break; } } }