Example #1
0
        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;
        }
Example #2
0
        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
        }
Example #3
0
    // OnEnable
    void OnEnable()
    {
        currentState = InGameMenuState.None;
        nextState    = InGameMenuState.None;

        Screen.showCursor = true;

        if (Player.main != null)
        {
            Player.main.crossHair.enabled = false;
        }
    }
Example #4
0
    // 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();
    }
Example #5
0
    // 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;
        }
    }
Example #6
0
 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;
 }
Example #7
0
    // 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);
    }
Example #8
0
    // 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;
            }
        }
    }
Example #9
0
 // LateUpdate
 void LateUpdate()
 {
     currentState = nextState;
 }
Example #10
0
 // show the add Component menu
 private void showAddComponentMenu()
 {
     this.currentState = InGameMenuState.addComponentMenu;
     this.addMenu.Show();
 }
Example #11
0
 private void hideRemoveComponentMenu()
 {
     this.currentState = InGameMenuState.noMenu;
     this.removeMenu.Hide();
 }
Example #12
0
 private void hideAddComponentMenu()
 {
     this.currentState = InGameMenuState.noMenu;
     this.addMenu.Hide();
 }
Example #13
0
 public void ShowRemoveComponentMenu(MachineComponent current)
 {
     if (current != null)
     {
         this.currentState = InGameMenuState.removeComponentMenu;
         this.removeMenu.Show(current);
     }
 }