public void Update(GameState current, List <MenuAction> menuActions, Vector2 selectVector) { currentMenu.reposition(); foreach (MenuAction m in menuActions) { Console.WriteLine(m); } if (currentMenu.dist < currentMenu.maxDist) { currentMenu.dist += 30; if (currentMenu.dist > currentMenu.maxDist) { currentMenu.dist = currentMenu.maxDist; } } //Console.WriteLine("DISTANCE:" + currentMenu.dist); if (menuActions.Contains(MenuAction.Up)) { if (currentMenu.selectedIndex > 0) { currentMenu.setSelected(currentMenu.selectedIndex - 1); Vector2 newMousePos = currentMenu.getItems()[currentMenu.selectedIndex].position; Mouse.SetPosition(400, (int)newMousePos.Y); } } else if (menuActions.Contains(MenuAction.Down)) { if (currentMenu.selectedIndex < (int)currentMenu.getItems().Length) { currentMenu.setSelected(currentMenu.selectedIndex + 1); Vector2 newMousePos = currentMenu.getSelectedItem().position; Mouse.SetPosition(400, (int)newMousePos.Y); } } else if (menuActions.Contains(MenuAction.Select)) { setCurrentMenu(currentMenu.getSelectedItem().nextMenu); } else if (menuActions.Contains(MenuAction.Back)) { setCurrentMenu(currentMenu.previousMenu); } else { selectAngle = (float)Math.Atan2((double)selectVector.Y, (double)selectVector.X); float initialAngle = (float)MathHelper.ToRadians(currentMenu.initial); int selectIndex = (int)((selectAngle - initialAngle + currentMenu.increment / 2) / currentMenu.increment); currentMenu.setSelected(selectIndex); } }
public void setCurrentMenu(MenuState m) { currentMenu.dist = 0; //setOverlayMode = false; //Console.WriteLine(m); if (!setOverlayMode) { menuStack.Clear(); } menuStack.Insert(0, currentMenu.getItems()); switch (m) { case MenuState.MainMenu: currentMenu = mainMenu; setOverlayMode = false; break; case MenuState.SinglePlayer: currentMenu = singlePlayerMenu; setOverlayMode = false; break; case MenuState.StartGame: startGame(); break; case MenuState.SelectMap: setOverlayMode = true; currentMenu = selectMapMenu; //Load map list from map engine break; case MenuState.BotOptions: setOverlayMode = true; currentMenu = botNumberMenu; break; case MenuState.SplitScreen: setOverlayMode = false; Console.WriteLine("SplitScreen Selected from arc"); break; case MenuState.Options: setOverlayMode = false; Console.WriteLine("Options Selected from arc"); break; case MenuState.Exit: coreEngine.Exit(); break; //when storing variable changes case MenuState.Null: if (currentMenu == selectMapMenu) { //store name of chosen map (selected item) } if (currentMenu == botNumberMenu) { //store name of chosen number of bots selectedNumBots = Int16.Parse(currentMenu.getSelectedItem().label); refreshSPMenu(); } setCurrentMenu(currentMenu.previousMenu); break; } //Console.WriteLine("--------------\n"+menuStack.Count); if (!setOverlayMode) { menuStack.Clear(); } else if (menuStack.Count >= currentMenu.level) { menuStack.RemoveAt(0); menuStack.RemoveAt(0); //Console.WriteLine(menuStack.Count); } menuStack.Insert(0, currentMenu.getItems()); //Console.WriteLine(menuStack.Count); }
public void setCurrentMenu(MenuState m) { currentMenu.dist = 0; //setOverlayMode = false; //Console.WriteLine(m); if (!setOverlayMode) menuStack.Clear(); menuStack.Insert(0, currentMenu.getItems()); switch (m) { case MenuState.MainMenu: currentMenu = mainMenu; setOverlayMode = false; break; case MenuState.SinglePlayer: currentMenu = singlePlayerMenu; setOverlayMode = false; break; case MenuState.StartGame: startGame(); break; case MenuState.SelectMap: setOverlayMode = true; currentMenu = selectMapMenu; //Load map list from map engine break; case MenuState.BotOptions: setOverlayMode = true; currentMenu = botNumberMenu; break; case MenuState.SplitScreen: setOverlayMode = false; Console.WriteLine("SplitScreen Selected from arc"); break; case MenuState.Options: setOverlayMode = false; Console.WriteLine("Options Selected from arc"); break; case MenuState.Exit: coreEngine.Exit(); break; //when storing variable changes case MenuState.Null: if (currentMenu == selectMapMenu) { //store name of chosen map (selected item) } if (currentMenu == botNumberMenu) { //store name of chosen number of bots selectedNumBots= Int16.Parse(currentMenu.getSelectedItem().label); refreshSPMenu(); } setCurrentMenu(currentMenu.previousMenu); break; } //Console.WriteLine("--------------\n"+menuStack.Count); if (!setOverlayMode) menuStack.Clear(); else if (menuStack.Count >= currentMenu.level) { menuStack.RemoveAt(0); menuStack.RemoveAt(0); //Console.WriteLine(menuStack.Count); } menuStack.Insert(0, currentMenu.getItems()); //Console.WriteLine(menuStack.Count); }