IEnumerator CoroutineMove() { Vector2 starting_position = Vector2.zero; Vector2 target_position = Vector2.zero; float lerp = 0.0f; if (state == InGameMenuState.Offscreen) { starting_position = off_screen; target_position = on_screen.position; state = InGameMenuState.Onscreen; } else if (state == InGameMenuState.Onscreen) { starting_position = on_screen.position; target_position = off_screen; state = InGameMenuState.Offscreen; } while (lerp <= 1f) { lerp += speed; transform.position = Vector2.Lerp(starting_position, target_position, lerp); yield return(0); } transform.position = target_position; }
public HudBar(int screenWidth, int screenHeight) { _screenWidth = screenWidth; _screenHeight = screenHeight; ticksInLevel = 0; #region Current state and menu inits. this.currentState = InGameMenuState.noMenu; // create a RemoveComponentMenu removeMenu = new RemoveComponentMenu(); // create an AddComponentMenu addMenu = new AddComponentMenu(); #endregion #region HUD creation hudBackground = new XNACS1Rectangle( new Vector2(XNACS1Base.World.WorldMin.X + XNACS1Base.World.WorldDimension.X / 2, XNACS1Base.World.WorldMax.Y - (XNACS1Base.World.WorldDimension.Y * hudSize / 2)), XNACS1Base.World.WorldDimension.X, XNACS1Base.World.WorldDimension.Y * hudSize); // components is left most button. componentsButton = new XNACS1Rectangle(new Vector2(hudBackground.CenterX - (hudBackground.Width / 2) + (hudBackground.Width * buttonSize * .5f), hudBackground.CenterY), hudBackground.Width * buttonSize, hudBackground.Height); componentsButton.Texture = "componentButton"; //componentsButton.Label = "components"; // coins is second from left. coinsRemaining = new XNACS1Rectangle(new Vector2(hudBackground.CenterX - (hudBackground.Width / 2) + 3 * (hudBackground.Width * buttonSize * .5f), hudBackground.CenterY), hudBackground.Width * buttonSize, hudBackground.Height); coinsRemaining.Label = "0000"; // go/stop button is in middle. goStopButton = new XNACS1Rectangle(new Vector2(hudBackground.CenterX, hudBackground.CenterY), hudBackground.Width * buttonSize, hudBackground.Height); goStopButton.Texture = "goButton"; goStopButton.Label = "GO"; goStopButton.LabelColor = Color.White; // timer is second from right. timer = new XNACS1Rectangle(new Vector2(hudBackground.CenterX + (hudBackground.Width / 2) - 3 * (hudBackground.Width * buttonSize * .5f), hudBackground.CenterY), hudBackground.Width * buttonSize, hudBackground.Height); timer.Label = "00:00"; // zoom is right-most button. zoomButton = new XNACS1Rectangle( new Vector2(hudBackground.CenterX + (hudBackground.Width / 2) - (hudBackground.Width * buttonSize * .5f), hudBackground.CenterY), hudBackground.Width * buttonSize, hudBackground.Height); //zoomButton.Texture = "zoomButton"; zoomButton.Label = "Zoom-In"; zoomButton.LabelColor = Color.White; // set all background colors to black. hudBackground.Color = componentsButton.Color = coinsRemaining.Color = goStopButton.Color = timer.Color = zoomButton.Color = Color.Black; // set all label colors to white. hudBackground.LabelColor = componentsButton.LabelColor = coinsRemaining.LabelColor = goStopButton.LabelColor = timer.LabelColor = zoomButton.LabelColor = Color.White; #endregion }
// OnEnable void OnEnable() { currentState = InGameMenuState.None; nextState = InGameMenuState.None; Screen.showCursor = true; if (Player.main != null) { Player.main.crossHair.enabled = false; } }
// OnEnable void OnEnable() { currentState = InGameMenuState.None; nextState = InGameMenuState.None; Screen.showCursor = true; if (Player.main != null) { Player.main.crossHair.enabled = false; } // Try to free up some RAM PerformanceMonitor.FreeRAM(); }
// OnDisable void OnDisable() { currentState = InGameMenuState.None; nextState = InGameMenuState.None; Screen.showCursor = false; if (Player.main != null) { Player.main.crossHair.enabled = true; } if (InGameLobby.instance) { InGameLobby.instance.displayedAccount = PlayerAccount.mine; } }
public IState<CKGameManager> CreateGameState(CKGameManager.GAME_STATE_TYPE cKGameType) { IState<CKGameManager> gameState = null; switch (cKGameType) { case CKGameManager.GAME_STATE_TYPE.MAIN_MENU: gameState = new MainMenuState(); break; case CKGameManager.GAME_STATE_TYPE.WORLD_MAP: gameState = new WorldMapState(); break; case CKGameManager.GAME_STATE_TYPE.LOCAL_MAP: gameState = new LocalMapState(); break; case CKGameManager.GAME_STATE_TYPE.COMBAT: gameState = new CombatState(); break; case CKGameManager.GAME_STATE_TYPE.INGAME_MENU: gameState = new InGameMenuState(); break; } return gameState; }
// OnGUI void OnGUI() { if (GameManager.gameEnded) { return; } if (currentState != InGameMenuState.Lobby) { switch (GameManager.serverType) { case ServerType.World: menuItems = menuItemsWorld; break; case ServerType.Town: menuItems = menuItemsTown; break; default: menuItems = menuItemsArena; break; } menuItemHeight = contentStyle.CalcSize(menuItems[0].content).y + 4; height = menuItems.Length * menuItemHeight; drawRect.y = GUIArea.height / 2 - height / 2; drawRect.width = width; drawRect.height = height; using (new GUIArea(drawRect)) { using (new GUIVertical()) { for (int i = 0; i < menuItems.Length; i++) { GUILayout.BeginHorizontal(); if (menuItems[i].menuState == currentState) { GUI.backgroundColor = GUIColor.MenuItemActive; } else { GUI.backgroundColor = GUIColor.MenuItemInactive; } bool isLeave = (i == menuItems.Length - 1); bool isLogOut = (i == menuItems.Length - 2); if (isLeave) { if (GameManager.isPvP) { menuItems[i].content.text = " Leave"; } else { menuItems[i].content.text = " Exit game"; } } if (GUIHelper.Button(menuItems[i].content, contentStyle)) { Sounds.instance.buttonClick.Play(); var newState = menuItems[i].menuState; if (newState == currentState) { nextState = InGameMenuState.None; } else { if (isLeave) { new Confirm( "Are you sure you want to leave?", () => { this.nextState = newState; }, null ); } else if (isLogOut) { new Confirm( "Are you sure you want to log out?", () => { this.nextState = newState; }, null ); } else { nextState = newState; } } } GUILayout.EndHorizontal(); } } } } GUI.backgroundColor = Color.white; HandleInGameMenu(currentState); }
// HandleInGameMenu void HandleInGameMenu(InGameMenuState state) { // Disable intro if (state != InGameMenuState.None) { if (MapManager.mapIntro != null && MapManager.mapIntro.enabled) { MapManager.mapIntro.enabled = false; } switch (state) { case InGameMenuState.Continue: CameraMode.current.Continue(); break; case InGameMenuState.Lobby: /*if(InGameLobby.instance != null) { * using(new GUIArea((int)(Screen.width * 0.8f), (int)(Screen.height * 0.7f))) { * InGameLobby.instance.Draw(); * } * }*/ break; case InGameMenuState.PvP: if (ArenaGUI.instance != null) { using (new GUIArea((int)(Screen.width * 0.7f), (int)(Screen.height * 0.7f))) { if (!ArenaGUI.instance.inQueue) { ArenaGUI.instance.Draw(); } } } break; case InGameMenuState.Settings: if (SettingsGUI.instance != null) { using (new GUIArea((int)(Screen.width * 0.7f), (int)(Screen.height * 0.7f))) { SettingsGUI.instance.Draw(); } } break; case InGameMenuState.Logout: if (!loggedOut) { Login.instance.LogOut(); loggedOut = true; } break; case InGameMenuState.LeaveGame: if (!leftGame) { if (GameManager.isPvE) { LogManager.General.Log("Exiting application..."); Application.Quit(); } else { LogManager.General.Log("Leaving game..."); Login.instance.ReturnToWorld(); } leftGame = true; } break; } } }
// LateUpdate void LateUpdate() { currentState = nextState; }
// show the add Component menu private void showAddComponentMenu() { this.currentState = InGameMenuState.addComponentMenu; this.addMenu.Show(); }
private void hideRemoveComponentMenu() { this.currentState = InGameMenuState.noMenu; this.removeMenu.Hide(); }
private void hideAddComponentMenu() { this.currentState = InGameMenuState.noMenu; this.addMenu.Hide(); }
public void ShowRemoveComponentMenu(MachineComponent current) { if (current != null) { this.currentState = InGameMenuState.removeComponentMenu; this.removeMenu.Show(current); } }