/// <summary> /// moving to another menu will add the selected menu to the top of the stack /// </summary> void NextMenu(MenuNode menu) { //push the next menu stack.Push(menu); //set selected to 0 selectedNode = 0; }
//constructor public MenuStack(MenuNode root, Player player) { //instantiate the stack stack = new Stack <MenuNode>(); //always start at 0 (first item in menu) selectedNode = 0; //we need a reference to the root node this.root = root; this.player = player; }
//add method public void Add(MenuNode child) { //add the child to the list menuItems.Add(child); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //load temporary wall and floor assets wallTexture = Content.Load <Texture2D>("Wall_tile"); floorTexture = Content.Load <Texture2D>("Ground_tile"); entranceTexture = Content.Load <Texture2D>("Entrance_tile"); exitTexture = Content.Load <Texture2D>("exit"); //load spritefont font = Content.Load <SpriteFont>("File"); //Move select textures //selectionText = Content.Load<SpriteFont>("AttackFont"); selectionBGTxt = Content.Load <Texture2D>("SelectionBG"); //load temp player texture playerTexture = Content.Load <Texture2D>("mayor_anim"); enemyTexture = Content.Load <Texture2D>("slime_idle"); //item textures hpPotTexture = Content.Load <Texture2D>("HealthPotion.png"); //instantiate Tile Controller tileController = new TileController(26, 26); //create first level with filepath tileController.CreateLevel1("..\\..\\..\\..\\Levels\\Oomph.txt"); //player rectangle is set to the find rectangle point entrance1 = tileController.FindEntrance(1); exit1 = tileController.FindExit(1); playerRectangle.Location = new Point(entrance1.X * 32, entrance1.Y * 32); //gamestate textures pauseMenu = Content.Load <Texture2D>("pause screen"); //player menu texture playerMenuTexture = Content.Load <Texture2D>("MenuDrop"); //menu nodes and menu stack //why on earth did I use a tree here menuRoot = new MenuNode("menu", MenuItem.root); menuRoot.Add(new MenuNode("items", MenuItem.menu)); menuRoot.Add(new MenuNode("attacks", MenuItem.menu)); menuRoot.Add(new MenuNode("back", MenuItem.back)); //add items here menuRoot.MenuItems.ElementAt <MenuNode>(0).Add(new MenuNode("use health potion", MenuItem.item)); menuRoot.MenuItems.ElementAt <MenuNode>(0).Add(new MenuNode("back", MenuItem.back)); //add attacks here menuRoot.MenuItems.ElementAt <MenuNode>(1).Add(new MenuNode("WEAK ATTACK", MenuItem.attack)); menuRoot.MenuItems.ElementAt <MenuNode>(1).Add(new MenuNode("back", MenuItem.back)); characterController = new CharacterController(26, 26); player = new Player(characterController, tileController, 10, playerRectangle, playerTexture); enemy = new Enemy(characterController, tileController, 10, enemyRectangle, enemyTexture, player); enemy2 = new Enemy(characterController, tileController, 10, enemyRectangle2, enemyTexture, player); potOne = new HealthPotion(10, potOneRect, hpPotTexture); potTwo = new HealthPotion(10, potTwoRect, hpPotTexture); potThree = new HealthPotion(10, potThreeRect, hpPotTexture); items.Add(potOne); items.Add(potTwo); items.Add(potThree); mainMenu = Content.Load <Texture2D>("Title screen"); //loading shader stuff effect1 = Content.Load <Effect>("lighteffect"); lightMask = Content.Load <Texture2D>("lightmask"); var pp = GraphicsDevice.PresentationParameters; lightsTarget = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight); mainTarget = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight); Random rng = new Random(); foreach (Item i in items) { i.Populate(tileController, 1, rng); } //menu stack menuStack = new MenuStack(menuRoot, player); }