Exemplo n.º 1
0
 /// <summary>
 /// Shows the pause menu landing screen and unlocks the cursor
 /// </summary>
 public void OpenPauseMenu()
 {
     loadedMenu       = PauseMenuState.LandingPage;
     Cursor.lockState = CursorLockMode.None;
     Cursor.visible   = true;
     pauseLandingScreen.SetActive(true);
     paused = true;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Opens the player info screen
 /// </summary>
 /// <param name="playerID">What Player ID to grab the info of</param>
 public void ToPlayerScreen(int playerID)
 {
     PauseGUI.playerID = playerID;
     playerSkillScreen.SetActive(false);
     playerInfoScreen.SetActive(true);
     loadedMenu = PauseMenuState.PlayerInspector;
     UpdatePlayerEquipped();
 }
Exemplo n.º 3
0
 void Start()
 {
     GameManager.pauseMenuReference = this;
     defaultMenu  = transform.GetChild((int)PauseMenuChildren.DefaultMenu).gameObject;
     settingsMenu = transform.GetChild((int)PauseMenuChildren.Settings).gameObject;
     exitMenu     = transform.GetChild((int)PauseMenuChildren.Exit).gameObject;
     CurrentState = PauseMenuState.Default;
     gameObject.SetActive(false);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Moves back to the landing page
 /// </summary>
 public void BackToLanding()
 {
     loadedMenu = PauseMenuState.LandingPage;
     playerInfoScreen.SetActive(false);
     if (equipInv.gameObject.activeSelf)
     {
         equipInv.Close();
     }
 }
Exemplo n.º 5
0
    public MenuHub(MenuManager menuManager)
    {
        manager = menuManager;

        pauseMenu = new PauseMenuState(this);
        playMenu  = new PlayMenuState(this);

        // TODO: switch to main menu state
        SwitchToPlay();
    }
Exemplo n.º 6
0
 /// <summary>
 /// Closes the pause menu
 /// </summary>
 public void BackToGame()
 {
     loadedMenu       = PauseMenuState.Closed;
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible   = false;
     ClosePlayerSelection();
     outerGear.GetComponent <PauseInventory>().Close();
     innerGear.moveToButton(3);
     pauseLandingScreen.SetActive(false);
     paused = false;
 }
Exemplo n.º 7
0
 public PauseStateManager(GameObject pauseMenu, GameObject weaponMenu, PauseAudioSettings audioSettings)
 {
     this.pauseMenu     = pauseMenu;
     this.weaponMenu    = weaponMenu;
     this.audioSettings = audioSettings;
     unpausedState      = new UnpausedState(this);
     pauseMenuState     = new PauseMenuState(this);
     weaponMenuState    = new WeaponMenuState(this);
     currentState       = unpausedState;
     pauseMenu.SetActive(false);
     weaponMenu.SetActive(false);
 }
    public void OpenOptionsMenu()
    {
        PauseMenuState = PauseMenuState.Options;

        if (pauseMenu)
        {
            pauseMenu.SetActive(false);
        }
        if (optionsMenu)
        {
            optionsMenu.SetActive(true);
        }
    }
Exemplo n.º 9
0
        public override void Initialize()
        {
            menuGray = new menuItem();
            menuBackground = new menuItem();

            menuItems = new menuItem[int_NumOfOptions];
            for (int i = 0; i < int_NumOfOptions; i++)
            {
               menuItems[i] = new menuItem();
            }

            CurrentWorkerState = PauseMenuState.CONTINUE;
            isUpdating = false;
        }
Exemplo n.º 10
0
    }     //end update

    public void SetPlayGame(bool newPlayGame)
    {
        playGame = newPlayGame;
        if (playGame)
        {
            Time.timeScale = 1;
            selected       = 0;
            pauseMenustate = PauseMenuState.Main;
        }
        else
        {
            Time.timeScale = 0;
        }
    }
    public void CloseMenu()
    {
        PauseMenuState = PauseMenuState.Closed;

        if (pauseMenu)
        {
            pauseMenu.SetActive(false);
        }
        if (optionsMenu)
        {
            optionsMenu.SetActive(false);
        }

        PauseGame(false);
    }
Exemplo n.º 12
0
 /// <summary>
 /// Shows the pause inventory and associated controls and generates the initial view of items
 /// </summary>
 public void OpenPauseInventory()
 {
     if (loadedMenu == PauseMenuState.Closed)
     {
         OpenPauseMenu();
     }
     else if (loadedMenu == PauseMenuState.PlayerInspector)
     {
         BackToLanding();
     }
     else if (loadedMenu == PauseMenuState.SkillTreeScreen)
     {
         playerSkillScreen.SetActive(false);
         BackToLanding();
     }
     loadedMenu = PauseMenuState.LandingPage;
     ClosePlayerSelection();
     innerGear.moveToButton(2);
     pauseInventory.SortAndChangeFilter();
 }
    void OpenPauseMenu()
    {
        PauseMenuState = PauseMenuState.Main;

        if (optionsMenu)
        {
            optionsMenu.SetActive(false);
        }
        if (pauseMenu)
        {
            pauseMenu.SetActive(true);
        }

        // Closes the Hub if it's open.
        if (hubMenuController?.HubMenuState != HubMenuState.Closed)
        {
            hubMenuController.CloseMenu();
        }

        PauseGame(true);
    }
Exemplo n.º 14
0
        public void DisplayPauseMenuUI(int state)
        {
            playerStatsUI.SetActive(false);
            inventoryUI.SetActive(false);
            skillsUI.SetActive(false);
            missionsUI.SetActive(false);

            PauseMenuState newState = (PauseMenuState)state;

            switch (newState)
            {
            case PauseMenuState.PlayerStatsMenu:
            {
                playerStatsUI.SetActive(true);
                break;
            }

            case PauseMenuState.InventoryMenu:
            {
                inventoryUI.SetActive(true);
                break;
            }

            case PauseMenuState.SkillsMenu:
            {
                skillsUI.SetActive(true);
                break;
            }

            case PauseMenuState.MissionsMenu:
            {
                missionsUI.SetActive(true);
                break;
            }
            }
            currentPauseMenuState = newState;
            SetSelectedButton();
        }
Exemplo n.º 15
0
 /// <summary>
 /// Shows the buttons that allow the player to open the player info screen for a specified pawn
 /// </summary>
 public void ToPlayerSelection()
 {
     if (loadedMenu == PauseMenuState.Closed)
     {
         OpenPauseMenu();
     }
     else if (loadedMenu == PauseMenuState.PlayerInspector)
     {
         BackToLanding();
     }
     else if (loadedMenu == PauseMenuState.SkillTreeScreen)
     {
         playerSkillScreen.SetActive(false);
         BackToLanding();
     }
     loadedMenu = PauseMenuState.LandingPage;
     pauseInventory.Close();
     foreach (GameObject p in playerButtons)
     {
         p.SetActive(true);
     }
     innerGear.moveToButton(1);
     outerGear.frozen = true;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Opens the skill menu for the currently selected player
 /// </summary>
 public void OpenSkillScreen()
 {
     loadedMenu = PauseMenuState.SkillTreeScreen;
     playerSkillScreen.SetActive(true);
     playerSkillScreen.GetComponent <SkillTreeGUI>().OpenSkillMenu(playerID);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Puts the worker state on void
 /// </summary>
 public void MenuVoid()
 {
     PreviousWorkerState = CurrentWorkerState;
     CurrentWorkerState = PauseMenuState.VOID;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Goes to the "next" option
        /// </summary>
        private void CycleForward()
        {
            if (CurrentWorkerState == PauseMenuState.EXIT)
            {
                CurrentWorkerState = PauseMenuState.CONTINUE;
            }
            else
            {
                CurrentWorkerState++;
            }

            for (int i = 0; i < int_NumOfOptions; i++)
            {
                if (i == (int)CurrentWorkerState)
                {
                    menuItems[i].t2d_Texture = menuItems[i].t2d_Texture_Highlight;
                }
                else
                {
                    menuItems[i].t2d_Texture = menuItems[i].t2d_Texture_Original;
                }
            }
        }
Exemplo n.º 19
0
 public MenuResult Update(GameTime gameTime)
 {
     cooldown -= gameTime.ElapsedGameTime.Milliseconds;
     if (cooldown < 0) cooldown = 0;
     if (state == PauseMenuState.NURSEIN || state == PauseMenuState.NURSEOUT)
     {
         animateTime+=gameTime.ElapsedGameTime.Milliseconds;
     }
     if (state == PauseMenuState.NURSEIN && animateTime > 250)
     {
         state = PauseMenuState.READY;
     }
     if (state == PauseMenuState.NURSEOUT && animateTime > 250)
     {
         animateTime = 0;
         state = PauseMenuState.NURSEIN;
         return result;
     }
     if (state == PauseMenuState.READY && cooldown == 0)
     {
         GamePadState gamePadState = GamePad.GetState(Game.playerIndex);
         Vector2 leftStick = gamePadState.ThumbSticks.Left;
         Vector2 rightStick = gamePadState.ThumbSticks.Right;
         if (Keyboard.GetState().IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A) || gamePadState.IsButtonDown(Buttons.Start))
         {
             result = optionList[selectedOption].result;
             animateTime = 0;
             state = PauseMenuState.NURSEOUT;
             SoundEffects.PlayMove();
         }
         if (gamePadState.IsButtonDown(Buttons.DPadRight) || gamePadState.IsButtonDown(Buttons.DPadRight) || Keyboard.GetState().IsKeyDown(Keys.Right) || leftStick.X > Game.gameSettings.controlStickTrigger || rightStick.X > Game.gameSettings.controlStickTrigger)
         {
             selectedOption++;
             SoundEffects.PlayClick();
             if (selectedOption >= optionList.Count())
                 selectedOption = optionList.Count() - 1;
             cooldown = 250;
         }
         if (gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.IsButtonDown(Buttons.DPadLeft) || Keyboard.GetState().IsKeyDown(Keys.Left) || leftStick.X < -Game.gameSettings.controlStickTrigger || rightStick.X < -Game.gameSettings.controlStickTrigger)
         {
             selectedOption--;
             SoundEffects.PlayClick();
             if (selectedOption < 0)
                 selectedOption = 0;
             cooldown = 250;
         }
         if (gamePadState.IsButtonDown(Buttons.B))
         {
             result = MenuResult.ResumeGame;
             animateTime = 0;
             state = PauseMenuState.NURSEOUT;
             SoundEffects.PlayMove();
         }
     }
     return MenuResult.None;
 }
Exemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        if (gameIsPaused)
        {
            if (currentState == PauseMenuState.PAUSED)
            {
                #region paused
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    TogglePause();
                }
                else if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    selectedOption--;
                    if (selectedOption < 0)
                    {
                        selectedOption = 4 + selectedOption;
                    }

                    selectedOption = selectedOption % 4;

                    audioSource.PlayOneShot(navigateSound);
                }

                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    selectedOption++;
                    selectedOption = selectedOption % 4;

                    audioSource.PlayOneShot(navigateSound);
                }

                if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
                {
                    if (selectedOption == 0)
                    {
                        currentState   = PauseMenuState.INVENTORY;
                        hoveredItemNum = 0;
                        selectedOption = 0;
                        if (GetComponent <DimensionManager>().currentDimension == Dimension.DIMENSION_A)
                        {
                            invBG.GetComponent <Image>().sprite        = invBGa;
                            itemSelector.GetComponent <Image>().sprite = invSelectorA;
                        }
                        else
                        {
                            invBG.GetComponent <Image>().sprite        = invBGz;
                            itemSelector.GetComponent <Image>().sprite = invSelectorZ;
                        }

                        audioSource.PlayOneShot(selectSound);
                    }
                    else if (selectedOption == 1)
                    {
                        currentState    = PauseMenuState.SKILLS;
                        hoveredSkillNum = 0;
                        selectedOption  = 0;

                        audioSource.PlayOneShot(selectSound);
                    }
                    else if (selectedOption == 2)
                    {
                        //currentState = PauseMenuState.OPTIONS;
                        audioSource.PlayOneShot(cancelSound);
                    }
                    else
                    {
                        audioSource.PlayOneShot(selectSound);

                        if (SceneManager.GetActiveScene().name == "MainLab")
                        {
                            GetComponent <SceneTransitioner>().TransitionWithFade("TitleScreen", Color.black);
                        }
                        else
                        {
                            GetComponent <SceneTransitioner>().TransitionWithFade("MainLab", Color.black);
                        }
                    }
                }

                #endregion
            }
            else if (currentState == PauseMenuState.INVENTORY)
            {
                #region inventory

                UpdateItemStats();

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    currentState = PauseMenuState.PAUSED;
                    UpdatePausedUIStates();

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
                {
                    if (hoveredItemNum == 0)
                    {
                        if (InventoryHolder.cookies.Count > 0)
                        {
                            InventoryHolder.cookies.RemoveAt(InventoryHolder.cookies.Count - 1);
                            hoveredItem.OnUse(GetComponent <DimensionManager>().GetCurrentCharacter().GetComponent <PlayableCharacter>());
                            GetComponent <AudioSource>().PlayOneShot(Resources.Load <AudioClip>("Sound/SFX/Misc/heal"), 0.8f);
                        }
                    }
                    else if (hoveredItemNum == 1)
                    {
                        if (InventoryHolder.iceCreams.Count > 0)
                        {
                            InventoryHolder.iceCreams.RemoveAt(InventoryHolder.iceCreams.Count - 1);
                            hoveredItem.OnUse(GetComponent <DimensionManager>().GetCurrentCharacter().GetComponent <PlayableCharacter>());
                            GetComponent <AudioSource>().PlayOneShot(Resources.Load <AudioClip>("Sound/SFX/Misc/heal"), 0.8f);
                        }
                    }
                    else if (hoveredItemNum == 2)
                    {
                        if (InventoryHolder.sandwiches.Count > 0)
                        {
                            InventoryHolder.sandwiches.RemoveAt(InventoryHolder.sandwiches.Count - 1);
                            hoveredItem.OnUse(GetComponent <DimensionManager>().GetCurrentCharacter().GetComponent <PlayableCharacter>());
                            GetComponent <AudioSource>().PlayOneShot(Resources.Load <AudioClip>("Sound/SFX/Misc/heal"), 0.8f);
                        }
                    }
                    else if (hoveredItemNum == 3)
                    {
                        if (InventoryHolder.soups.Count > 0)
                        {
                            InventoryHolder.soups.RemoveAt(InventoryHolder.soups.Count - 1);
                            hoveredItem.OnUse(GetComponent <DimensionManager>().GetCurrentCharacter().GetComponent <PlayableCharacter>());
                            GetComponent <AudioSource>().PlayOneShot(Resources.Load <AudioClip>("Sound/SFX/Misc/heal"), 0.8f);
                        }
                    }
                    else
                    {
                    }
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    hoveredItemNum++;
                    hoveredItemNum = hoveredItemNum % 8;

                    if (hoveredItemNum == 4)
                    {
                        hoveredItemNum = 0;
                    }
                    else if (hoveredItemNum == 0)
                    {
                        hoveredItemNum = 4;
                    }

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    if (hoveredItemNum == 0)
                    {
                        hoveredItemNum = 3;
                    }
                    else if (hoveredItemNum == 4)
                    {
                        hoveredItemNum = 7;
                    }
                    else
                    {
                        hoveredItemNum--;
                    }

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    hoveredItemNum += 4;
                    hoveredItemNum  = hoveredItemNum % 8;

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    hoveredItemNum += 4;
                    hoveredItemNum  = hoveredItemNum % 8;

                    audioSource.PlayOneShot(navigateSound);
                }


                #endregion
            }
            else if (currentState == PauseMenuState.SKILLS)
            {
                #region skills
                UpdateSkillStats();

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    currentState = PauseMenuState.PAUSED;
                    UpdatePausedUIStates();

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
                {
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    hoveredSkillNum++;
                    if (hoveredSkillNum % 3 == 0)
                    {
                        hoveredSkillNum -= 3;
                    }

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    hoveredSkillNum--;
                    if (hoveredSkillNum == -1)
                    {
                        hoveredSkillNum = 2;
                    }
                    else if (hoveredSkillNum == 2)
                    {
                        hoveredSkillNum = 5;
                    }

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    hoveredSkillNum += 3;
                    if (hoveredSkillNum > 5)
                    {
                        hoveredSkillNum -= 6;
                    }

                    audioSource.PlayOneShot(navigateSound);
                }
                else if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    hoveredSkillNum += 3;
                    if (hoveredSkillNum > 5)
                    {
                        hoveredSkillNum -= 6;
                    }

                    audioSource.PlayOneShot(navigateSound);
                }
                #endregion
            }
            else if (currentState == PauseMenuState.OPTIONS)
            {
                #region options
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                }
                else if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
                {
                }
                else if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                }
                else if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                }
                else if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                }
                #endregion
            }
        }
        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (!GetComponent <EventIssuer>().EventsAreOn() && !manualPaused && !gameIsPaused)
            {
                TogglePause();
            }
        }

        foreach (GameObject g in options)
        {
            g.GetComponent <Animator>().SetBool("DimensionA", GetComponent <DimensionManager>().currentDimension == Dimension.DIMENSION_A);
        }

        UpdatePanels();
    }
Exemplo n.º 21
0
    public void Update()
    {
        if (playGame)
        {
            return;
        }
        float deltaTime = Time.realtimeSinceStartup - lastTime;

        lastTime = Time.realtimeSinceStartup;

        analogTimer.Update(deltaTime);
        int   direction     = 0;
        float verticalInput = Input.GetAxisRaw("L_Vertical");

        if (verticalInput > 0)
        {
            direction = -1;
        }
        else if (verticalInput < 0)
        {
            direction = 1;
        }

        float horizontalInput = Input.GetAxisRaw("L_Vertical");

        if (horizontalInput < -.50 || Input.GetKeyDown("left"))
        {
            selected = 0;

            guiFocus = "Null";
        }
        else if (horizontalInput > .50f || Input.GetKeyDown("right"))
        {
            selected = -1;
            guiFocus = "backText";
        }

        if (Input.GetKeyDown("down"))
        {
            direction = 1;
        }
        else if (Input.GetKeyDown("up"))
        {
            direction = -1;
        }

        if (direction != 0 && selected != -1)
        {
            //the rotating menues
            if (pauseMenustate == PauseMenuState.Inventory_Blueprints ||
                pauseMenustate == PauseMenuState.Equipment_Weapons)
            {
                if (analogTimer.CheckDone())
                {
                    selected += direction;

                    if (selected < 0)                 //if you go up
                    {
                        if (pauseMenustate == PauseMenuState.Inventory_Blueprints)
                        {
                            if (buttonIndex == 0 && bluePrints.Count > pauseButtons.Length)                       //top of the list
                            {
                                selected = pauseButtons.Length - 1;

                                //blue print rotating menu
                                buttonIndex = bluePrints.Count - pauseButtons.Length;

                                for (int i = 0; i < bluePrints.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = bluePrints[buttonIndex + i].name.ToString();
                                }
                            }
                            else                             //not top of the list
                            {
                                buttonIndex--;
                                selected++;
                                for (int i = 0; i < bluePrints.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = bluePrints[buttonIndex + i].name.ToString();
                                }
                            }
                        }
                        //weapon rotating menu
                        else if (pauseMenustate == PauseMenuState.Equipment_Weapons)
                        {
                            if (buttonIndex == 0 && weaponInventory.Count > pauseButtons.Length)                     //top of the list
                            {
                                selected = pauseButtons.Length - 1;


                                buttonIndex = weaponInventory.Count - pauseButtons.Length;
                                for (int i = 0; i < weaponInventory.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = weaponInventory[buttonIndex + i];
                                }
                            }
                            else                             //not top
                            {
                                buttonIndex--;
                                selected++;
                                for (int i = 0; i < weaponInventory.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = weaponInventory[buttonIndex + i];
                                }
                            }
                        }
                    }

                    else if (selected > pauseButtons.Length - 1)               //go down
                    {
                        Debug.Log("go down");
                        if (pauseMenustate == PauseMenuState.Inventory_Blueprints)
                        {
                            if (buttonIndex + pauseButtons.Length > bluePrints.Count - 1)
                            {
                                selected    = 0;
                                buttonIndex = 0;
                                for (int i = 0; i < bluePrints.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = bluePrints[i].name.ToString();
                                }
                            }
                            else
                            {
                                buttonIndex++;
                                selected--;
                                for (int i = 0; i < bluePrints.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = bluePrints[buttonIndex + i].name.ToString();
                                }
                            }
                        }

                        else if (pauseMenustate == PauseMenuState.Equipment_Weapons)
                        {
                            if (buttonIndex + weaponInventory.Count > weaponInventory.Count - 1)
                            {
                                selected    = 0;
                                buttonIndex = 0;
                                for (int i = 0; i < weaponInventory.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = weaponInventory[i];
                                }
                            }
                            else
                            {
                                buttonIndex++;
                                selected--;
                                for (int i = 0; i < weaponInventory.Count && i < 4; i++)
                                {
                                    visibleButtons[i] = weaponInventory[buttonIndex + i];
                                }
                            }
                        }
                    }                    //	else if(selected>pauseButtons.Length-1)


                    helpText = "";
                    if (pauseMenustate == PauseMenuState.Inventory_Blueprints)
                    {
                        Hashtable resourceHash;
                        if (bluePrints.Count > 0)
                        {
                            Debug.Log("selected" + selected + "buttonindex" + buttonIndex + "count" + bluePrints.Count);
                            if (selected + buttonIndex < bluePrints.Count)
                            {
                                resourceHash = bluePrints[selected + buttonIndex].required_resources;
                                foreach (RESOURCE_NAMES key in resourceHash.Keys)
                                {
                                    helpText += key.ToString() + "\n ";
                                    if (resources.ContainsKey(key))
                                    {
                                        helpText += resources[key].ToString();
                                    }
                                    else
                                    {
                                        helpText += "0";
                                    }
                                    helpText += " / ";
                                    helpText += resourceHash[key].ToString() + "\n";
                                }
                            }
                        }
                    }                    //if blueprints
                    else if (pauseMenustate == PauseMenuState.Equipment_Weapons)
                    {
                        GameObject[] myWeapons = myControls.myWeapons;
                        for (int i = 0; i < myWeapons.Length; i++)
                        {
                            equipedWeapons[i] = myWeapons[i].name;
                            equipedWeapons[i] = equipedWeapons[i].Remove(equipedWeapons[i].Length - 7);                        //remove clone from name
                            helpText         += equipedWeapons[i] + " " + i + "\n";
                        }
                    }
                }
            }

            else            //not rotating menu
            {
                if (analogTimer.CheckDone())
                {
                    selected += direction;
                    if (selected < 0)
                    {
                        selected = pauseButtons.Length - 1;
                    }
                    else if (selected > pauseButtons.Length - 1)
                    {
                        selected = 0;
                    }
                }
            }            //not inventory->blueprints
        }

        if (pauseMenustate == PauseMenuState.Equipment_Weapons &&     //if in the equip menu and a button is pressed
            weaponInventory.Count > selected &&
            selected >= 0 &&
            (
                Input.GetButtonDown("X") ||
                Input.GetButtonDown("Circle") ||
                Input.GetButtonDown("Triangle") ||
                Input.GetButtonDown("Square")
            )
            )
        {
            int weaponKey = buttonIndex + selected;
            int wepNum    = 0;

            if (Input.GetButton("X"))
            {
                wepNum = 0;
            }
            else if (Input.GetButtonDown("Circle"))
            {
                wepNum = 1;
            }
            else if (Input.GetButtonDown("Triangle"))
            {
                wepNum = 2;
            }
            else if (Input.GetButtonDown("Square"))
            {
                wepNum = 3;
            }

            myControls.EquipWeapon(weaponInventory[weaponKey], wepNum);

            weaponInventory = myControls.weaponInventory;
            GameObject[] myWeapons = myControls.myWeapons;
            helpText = "";
            for (int i = 0; i < myWeapons.Length; i++)
            {
                equipedWeapons[i] = myWeapons[i].name;
                equipedWeapons[i] = equipedWeapons[i].Remove(equipedWeapons[i].Length - 7);            //remove clone from name
                helpText         += equipedWeapons[i] + " " + i + "\n";
            }

            for (int i = 0; i < weaponInventory.Count && i < 4; i++)
            {
                visibleButtons[i] = weaponInventory[i];
            }
        }        //end if in the equip menu and a button is pressed



        if (Input.GetButtonDown("X") || Input.GetKeyDown("space"))
        {
            if (selected == -1)
            {
                if (pauseMenustate == PauseMenuState.Main)
                {
                    SetPlayGame(true);
                    myControls.ResetCanAttack();
                }
                else
                {
                    pauseMenustate = lastState;
                    selected       = 0;
                }
            }
            else
            {
                switch (pauseMenustate)
                {
                case PauseMenuState.Main:
                    switch (selected)
                    {
                    case 0:
                        pauseMenustate = PauseMenuState.Equipment;
                        break;

                    case 1:
                        pauseMenustate = PauseMenuState.Inventory;
                        break;

                    case 2:
                        pauseMenustate = PauseMenuState.Options;
                        break;

                    case 3:
                        pauseMenustate = PauseMenuState.ManageData;
                        break;

                    case 4:
                        pauseMenustate = PauseMenuState.Main;
                        break;
                    }
                    break;

                //equipment menu
                case PauseMenuState.Equipment:
                    switch (selected)
                    {
                    case 0:            //equipment->weapons button
                        pauseMenustate  = PauseMenuState.Equipment_Weapons;
                        weaponInventory = myControls.weaponInventory;
                        GameObject[] myWeapons = myControls.myWeapons;
                        helpText = "";
                        for (int i = 0; i < myWeapons.Length; i++)
                        {
                            equipedWeapons[i] = myWeapons[i].name;
                            equipedWeapons[i] = equipedWeapons[i].Remove(equipedWeapons[i].Length - 7);                        //remove clone from name
                            helpText         += equipedWeapons[i] + " " + i + "\n";
                        }


                        for (int i = 0; i < pauseButtons.Length; i++)
                        {
                            if (weaponInventory.Count > i)
                            {
                                visibleButtons[i] = weaponInventory[i];
                            }
                            else
                            {
                                visibleButtons[i] = "";
                            }
                        }



                        break;

                    case 1:                    //equipment->tools button
                        pauseMenustate = PauseMenuState.Equipment_Tools;
                        helpText       = "";
                        toolInventory  = myControls.toolInventory;
                        for (int i = 0; i < toolInventory.Count; i++)
                        {
                            helpText += toolInventory[i] + "\n";
                        }

                        break;
                    }            //end switch selected
                    break;



                //inventory menu
                case PauseMenuState.Inventory:

                    switch (selected)
                    {
                    case 0:                            //inventory->blueprints button
                        bluePrints = myControls.bluePrintInventory;
                        resources  = myControls.resourceHash;

                        for (int i = 0; i < pauseButtons.Length; i++)
                        {
                            if (i < bluePrints.Count)
                            {
                                visibleButtons[i] = bluePrints[i].name.ToString();
                            }
                            else
                            {
                                visibleButtons[i] = "";
                            }
                        }

                        if (bluePrints.Count > 0)
                        {
                            helpText = "";
                            Hashtable resourceHash;
                            resourceHash = bluePrints[0].required_resources;
                            foreach (RESOURCE_NAMES key in resourceHash.Keys)
                            {
                                helpText += key.ToString() + "\n ";
                                if (resources.ContainsKey(key))
                                {
                                    helpText += resources[key].ToString();
                                }
                                else
                                {
                                    helpText += "0";
                                }
                                helpText += " / ";
                                helpText += resourceHash[key].ToString() + "\n";
                            }
                        }

                        pauseMenustate = PauseMenuState.Inventory_Blueprints;
                        break;

                    case 1:                     //inventory->Resources
                        resources      = myControls.resourceHash;
                        pauseMenustate = PauseMenuState.Inventory_Resources;
                        helpText       = "";
                        foreach (RESOURCE_NAMES key in resources.Keys)
                        {
                            helpText += key.ToString();
                            helpText += "\n " + resources[key].ToString() + "\n";
                        }

                        break;
                    }
                    break;

                //inventory->blueprints menu
                case PauseMenuState.Inventory_Blueprints:

                    if (!(bluePrints.Count > selected))
                    {
                        break;
                    }
                    int       bluePrintKey      = buttonIndex + selected;
                    Hashtable requiredResources = bluePrints[bluePrintKey].required_resources;

                    Hashtable ownedResources = resources;
                    bool      use            = true;

                    foreach (RESOURCE_NAMES key in requiredResources.Keys) //determine if you have enough resources to use the blueprint
                    {
                        if (!use)                                          //if it's already been determined you can't use it stop the loop short
                        {
                            break;
                        }

                        if (ownedResources.ContainsKey(key))                             //if you have at least 1 resource continue, else exit
                        {
                            if ((int)ownedResources[key] >= (int)requiredResources[key]) //if you have enough resources, use them, else exit
                            {
                                ownedResources[key] = (int)ownedResources[key] - (int)requiredResources[key];
                            }
                            else
                            {
                                use = false;
                            }
                        }
                        else
                        {
                            use = false;
                        }
                    }                    //end of foreachloop

                    if (use)
                    {
                        myControls.resourceHash = ownedResources;
                        resources = ownedResources;

                        switch (bluePrints[bluePrintKey].type)
                        {
                        case BLUEPRINT_TYPE.WEAPON:
                            myControls.AddWeapon(bluePrints[bluePrintKey].name.ToString());
                            break;

                        case BLUEPRINT_TYPE.TOOLS:
                            myControls.AddTool(bluePrints[bluePrintKey].name.ToString());
                            break;
                        }

                        //set up the help text again
                        helpText = "";
                        Hashtable resourceHash;
                        resourceHash = bluePrints[bluePrintKey].required_resources;

                        foreach (RESOURCE_NAMES key in resourceHash.Keys)
                        {
                            helpText += key.ToString() + "\n ";
                            if (resources.ContainsKey(key))
                            {
                                helpText += resources[key].ToString();
                            }
                            else
                            {
                                helpText += "0";
                            }
                            helpText += " / ";
                            helpText += resourceHash[key].ToString() + "\n";
                        }
                    }

                    break;

                case PauseMenuState.Inventory_Resources:
                    break;

                case PauseMenuState.ManageData:
                    break;

                case PauseMenuState.Options:
                    break;
                }
            }
        } //if get button
    }     //end update
Exemplo n.º 22
0
    public void OnGUI()
    {
        if (playGame)
        {
            return;
        }
        string backText = "Back";

        switch (pauseMenustate)
        {
        case PauseMenuState.Main:
            pauseButtons = mainPauseMenuButtons;
            backText     = "Exit";
            break;

        case PauseMenuState.Inventory:
            lastState    = PauseMenuState.Main;
            pauseButtons = inventoryPauseMenuButtons;
            break;

        case PauseMenuState.ManageData:
            lastState    = PauseMenuState.Main;
            pauseButtons = manageDataPauseMenuButtons;
            break;

        case PauseMenuState.Options:
            lastState    = PauseMenuState.Main;
            pauseButtons = tempButtons;
            break;

        case PauseMenuState.Equipment:
            lastState    = PauseMenuState.Main;
            pauseButtons = equipmentPauseMenuButtons;
            break;

        case PauseMenuState.Equipment_Weapons:
            lastState    = PauseMenuState.Equipment;
            pauseButtons = visibleButtons;
            break;

        case PauseMenuState.Equipment_Tools:
            lastState    = PauseMenuState.Equipment;
            pauseButtons = tempButtons;
            break;

        case PauseMenuState.Inventory_Blueprints:
            lastState    = PauseMenuState.Inventory;
            pauseButtons = visibleButtons;
            break;

        case PauseMenuState.Inventory_Resources:
            lastState    = PauseMenuState.Inventory;
            pauseButtons = tempButtons;
            break;
        }

        selected = GUI.SelectionGrid(menuPosition, selected, pauseButtons, 1);
        GUI.TextArea(helpTextposition, helpText);

        GUI.SetNextControlName("backText");
        GUI.Button(backPosition, backText);
        GUI.FocusControl(guiFocus);
    }
Exemplo n.º 23
0
 public void OpenPauseMenu()
 {
     pausePanel.SetActive(true);
     pauseState     = PauseMenuState.Open;
     Time.timeScale = 0f;
 }
Exemplo n.º 24
0
 /*
  * The int value of the state in the PauseMenuState enum
  */
 public void ChangeState(int _newState)
 {
     CurrentState = (PauseMenuState)_newState;
 }
Exemplo n.º 25
0
 public void ClosePauseMenu()
 {
     pausePanel.SetActive(false);
     pauseState     = PauseMenuState.Closed;
     Time.timeScale = 1f;
 }
Exemplo n.º 26
0
        private static void Main()
        {
            var missingfiles = new[] {
                ".\\world.dat",
                ".\\fonts\\toxica.ttf",
                ".\\fonts\\pixelmix.ttf",
                ".\\fonts\\pixelmix_bold.ttf",
                ".\\fonts\\pixelmix_micro.ttf"
            }.Where(file => !File.Exists(file)).ToList();

            foreach (var file in missingfiles)
            {
                MessageBox.Show(
                    $"The file {Environment.NewLine}{new FileInfo(file).FullName}{Environment.NewLine}could not be found.",
                    "A required file is missing!");
            }
            if (missingfiles.Any())
            {
                return;
            }

            using (var game = new GameWindow(1280, 720, new GraphicsMode(32, 24, 0, 8))) {
                var           fsm               = new GameFiniteStateMachine();
                GameStateBase mainMenuState     = new MainMenuState(game, fsm);
                GameStateBase ingameState       = new IngameState(game, fsm);
                GameStateBase settingsMenuState = new SettingMenuState(game, fsm);
                GameStateBase pauseMenuState    = new PauseMenuState(game, fsm);

                fsm.States.Add(mainMenuState);
                fsm.States.Add(ingameState);
                fsm.States.Add(settingsMenuState);
                fsm.States.Add(pauseMenuState);

                fsm.AddTransition(new Transition <GameStateBase>("init", null, mainMenuState));
                fsm.AddTransition(new Transition <GameStateBase>("start", mainMenuState, ingameState));
                fsm.AddTransition(new Transition <GameStateBase>("settings", mainMenuState, settingsMenuState));
                fsm.AddTransition(new Transition <GameStateBase>("settings", pauseMenuState, settingsMenuState));
                fsm.AddTransition(new Transition <GameStateBase>("pause", ingameState, pauseMenuState));
                fsm.AddTransition(new Transition <GameStateBase>("main menu", pauseMenuState, mainMenuState, Mode.Pop));

                fsm.AddTransition(new Transition <GameStateBase>("return", settingsMenuState, mainMenuState, Mode.Pop));
                fsm.AddTransition(new Transition <GameStateBase>("return", settingsMenuState, pauseMenuState, Mode.Pop));
                fsm.AddTransition(new Transition <GameStateBase>("return", pauseMenuState, ingameState, Mode.Pop));

                fsm.AddTransition(new Transition <GameStateBase>("exit", mainMenuState, null));
                fsm.AddTransition(new Transition <GameStateBase>("exit", pauseMenuState, null));

                fsm.Transitioned += t => { if (t.To == null)
                                           {
                                               game.Exit();
                                           }
                };

                fsm.Transition("init");

                game.Load   += (sender, args) => fsm.Load();
                game.Unload += (sender, args) => fsm.UnLoad();

                game.KeyDown  += (sender, args) => fsm.KeyDown(args);
                game.KeyUp    += (sender, args) => fsm.KeyUp(args);
                game.KeyPress += (sender, args) => fsm.KeyPress(args);

                game.MouseMove  += (sender, args) => fsm.MouseMove(args);
                game.MouseDown  += (sender, args) => fsm.MouseDown(args);
                game.MouseUp    += (sender, args) => fsm.MouseUp(args);
                game.MouseEnter += (sender, args) => fsm.MouseEnter();
                game.MouseLeave += (sender, args) => fsm.MouseLeave();
                game.MouseWheel += (sender, args) => fsm.MouseWheel(args);

                game.Resize      += (sender, args) => fsm.Resize();
                game.RenderFrame += (sender, args) => fsm.RenderFrame(args);
                game.UpdateFrame += (sender, args) => fsm.UpdateFrame(args);

                game.Title = "Apoplexy";
                game.Icon  = new Icon("Grim Reaper.ico");

                game.Run(30, 60);
            }
        }
Exemplo n.º 27
0
 public MenuResult Update(GameTime gameTime)
 {
     cooldown -= gameTime.ElapsedGameTime.Milliseconds;
     if (cooldown < 0)
     {
         cooldown = 0;
     }
     if (state == PauseMenuState.NURSEIN || state == PauseMenuState.NURSEOUT)
     {
         animateTime += gameTime.ElapsedGameTime.Milliseconds;
     }
     if (state == PauseMenuState.NURSEIN && animateTime > 250)
     {
         state = PauseMenuState.READY;
     }
     if (state == PauseMenuState.NURSEOUT && animateTime > 250)
     {
         animateTime = 0;
         state       = PauseMenuState.NURSEIN;
         return(result);
     }
     if (state == PauseMenuState.READY && cooldown == 0)
     {
         GamePadState gamePadState = GamePad.GetState(Game.playerIndex);
         Vector2      leftStick    = gamePadState.ThumbSticks.Left;
         Vector2      rightStick   = gamePadState.ThumbSticks.Right;
         if (Keyboard.GetState().IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A) || gamePadState.IsButtonDown(Buttons.Start))
         {
             result      = optionList[selectedOption].result;
             animateTime = 0;
             state       = PauseMenuState.NURSEOUT;
             SoundEffects.PlayMove();
         }
         if (gamePadState.IsButtonDown(Buttons.DPadRight) || gamePadState.IsButtonDown(Buttons.DPadRight) || Keyboard.GetState().IsKeyDown(Keys.Right) || leftStick.X > Game.gameSettings.controlStickTrigger || rightStick.X > Game.gameSettings.controlStickTrigger)
         {
             selectedOption++;
             SoundEffects.PlayClick();
             if (selectedOption >= optionList.Count())
             {
                 selectedOption = optionList.Count() - 1;
             }
             cooldown = 250;
         }
         if (gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.IsButtonDown(Buttons.DPadLeft) || Keyboard.GetState().IsKeyDown(Keys.Left) || leftStick.X < -Game.gameSettings.controlStickTrigger || rightStick.X < -Game.gameSettings.controlStickTrigger)
         {
             selectedOption--;
             SoundEffects.PlayClick();
             if (selectedOption < 0)
             {
                 selectedOption = 0;
             }
             cooldown = 250;
         }
         if (gamePadState.IsButtonDown(Buttons.B))
         {
             result      = MenuResult.ResumeGame;
             animateTime = 0;
             state       = PauseMenuState.NURSEOUT;
             SoundEffects.PlayMove();
         }
     }
     return(MenuResult.None);
 }