Exemplo n.º 1
0
 public void Pause()
 {
     AudioController.PlaySFX("Pause");
     PauseMenuUI.SetActive(true);
     Time.timeScale = 0f;
     GameIsPaused   = true;
 }
Exemplo n.º 2
0
        public override void Update()
        {
            if (Input.GetKey(KeyCode.UpArrow))
            {
                ClientController.CameraController.Move(new Vector2(0, 1));
            }
            if (Input.GetKey(KeyCode.RightArrow))
            {
                ClientController.CameraController.Move(new Vector2(1, 0));
            }
            if (Input.GetKey(KeyCode.DownArrow))
            {
                ClientController.CameraController.Move(new Vector2(0, -1));
            }
            if (Input.GetKey(KeyCode.LeftArrow))
            {
                ClientController.CameraController.Move(new Vector2(-1, 0));
            }

            if (Input.GetKey(KeyCode.Escape))
            {
                PauseMenuUI.Show();
            }

            ClientController.CameraController.Zoom(Input.GetAxis("Mouse ScrollWheel"));
        }
Exemplo n.º 3
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 4
0
    private void Awake()
    {
        Time.timeScale = 1f;
        planetArray    = GetComponentsInChildren <Planet>();
        foreach (Planet p in planetArray)
        {
            if (p.faction.ToLower() == "player")
            {
                friendlyPlanetTotal += 1;
            }
            else if (p.faction.ToLower() == "enemy")
            {
                enemyPlanetTotal += 1;
            }
            else if (p.faction.ToLower() == "neutral")
            {
                neutralPlanetTotal += 1;
            }
        }

        pauseMenuScript = pauseMenuUI.GetComponent <PauseMenuUI>();

        DebugDisplayCameraInfo();

        // Uncomment below to use the one that starts in MainMenu
        // MakeSingleton();
    }
Exemplo n.º 5
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);
    }
Exemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        //KEY INPUT SECTION

        if (EndScreenScript.gameEnd == false)
        {
            if (Input.GetKeyDown(KeyCode.Escape) && PauseMenuUI.canPause == true) //Checks to see if the player has pressed down Escape and if the Pause UI is OFF
            {
                PauseMenuUI.OpenPauseMenu();                                      //Opens the Pause Menu
            }
            else
            if (Input.GetKeyDown(KeyCode.Escape) && PauseMenuUI.canPause == false) //Checks to see if the player has pressed down Escape and if the Pause UI is ON
            {
                PauseMenuUI.ContinueGame();                                        //Continues the Game
            }
        }

        /*
         * if (Input.GetKeyDown(KeyCode.P)) //USED FOR DEBUGGING PURPOSES ONLY, REMOVE LINE OF CODE ONCE PROPER SYSTEM IS IMPLEMENTED AND HAVE THIS RUN IN EndScreenScript.cs
         * {
         *  UIInitialiserScript.GetEndScreenObj.SetActive(true); //Sets the End Screen to True
         *  UIInitialiserScript.GetPauseMenuObj.SetActive(false); //Turns off Pause Menu if it's on
         *  UIInitialiserScript.GetPlayerUI.SetActive(false); //Sets the Pause Menu object to active so it can be interacted with
         *
         *  EndScreenScript.gameEnd = true;
         *  PauseMenuUI.canPause = false; //Stops the player from being able to pause
         *  Time.timeScale = 0; //Freezes time so game freezes
         *
         *  Cursor.lockState = CursorLockMode.Confined; //Locks cursor to the game view (Cannot move mouse outside of it, only works in BUILD, not EDITOR)
         *  Cursor.visible = true; //Shows Cursor
         * }*/

        //INPUT SECTION
        Vector2 input    = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); //Keyboard Inputs
        Vector2 inputDir = input.normalized;                                                          //Takes input Vector2 and turns it into a direction
        bool    running  = Input.GetKey(KeyCode.LeftShift);                                           //Will only turn running bool to True if Key is being pressed

        Move(inputDir, running);                                                                      //Calls the Move fucntion to let the player move (Passes in inputDir and running)

        if (Input.GetKeyDown(KeyCode.Space))                                                          //Checks to see if the Space Key has been pushed down
        {
            Jump();
        }

        //ANIMATION SECTION
        //ADD ANIMATION CONTROL HERE ONCE ANIMATIONS ARE IMPLEMENTED
    }
Exemplo n.º 7
0
 private void Awake()
 {
     Instance = this;
     m_input  = InputHandler.Instance;
 }
Exemplo n.º 8
0
 private void Awake()
 {
     instance = this;
     gameObject.SetActive(false);
 }
Exemplo n.º 9
0
 public PauseMenuCommand()
 {
     this.pauseMenuUI = GameObject.Find("PauseMenu").GetComponent <PauseMenuUI> ();
 }
Exemplo n.º 10
0
 public void OnClickMenuButton()
 {
     PauseMenuUI.ToggleOn();
 }
Exemplo n.º 11
0
 static private PauseMenuUI setInstance()
 {
     instance = HUDManager.Instance.GetComponentInChildren <PauseMenuUI>(true); return(instance);
 }
Exemplo n.º 12
0
 public void ContinueGame()
 {
     PauseMenuUI.SetActive(false);
     Time.timeScale = 1f;
     IsPaused       = false;
 }
Exemplo n.º 13
0
        public void Update(double deltaTime, double totalTime, long count)
        {
            foreach (Quest quest in Quests)
            {
                quest.OnQuestTick(this);
            }

            if (!IsWalking)
            {
                if (InputMap.FindMapping(InputAction.Inventory).Pressed(World.Input))
                {
                    InventoryUI.Show(World, this);
                    return;
                }

                if (InputMap.FindMapping(InputAction.Spells).Pressed(World.Input))
                {
                    SpellsUI.Show(World);
                    return;
                }

                if (InputMap.FindMapping(InputAction.Player).Pressed(World.Input))
                {
                    PlayerUI.Show(World);
                    return;
                }

                if (InputMap.FindMapping(InputAction.Menu).Pressed(World.Input))
                {
                    PauseMenuUI.Show(World);
                    return;
                }


                Direction _lastHeading = Heading;

                if (InputMap.FindMapping(InputAction.Up).Held(World.Input))
                {
                    if (Heading != Direction.Up)
                    {
                        Heading = Direction.Up;
                    }
                    else if (_keyHeld == 0)
                    {
                        _keyHeld = 0.1;
                    }

                    _keyHeld += deltaTime;
                }
                else if (InputMap.FindMapping(InputAction.Down).Held(World.Input))
                {
                    if (Heading != Direction.Down)
                    {
                        Heading = Direction.Down;
                    }
                    else if (_keyHeld == 0)
                    {
                        _keyHeld = 0.1;
                    }

                    _keyHeld += deltaTime;
                }
                else if (InputMap.FindMapping(InputAction.Left).Held(World.Input))
                {
                    if (Heading != Direction.Left)
                    {
                        Heading = Direction.Left;
                    }
                    else if (_keyHeld == 0)
                    {
                        _keyHeld = 0.1;
                    }

                    _keyHeld += deltaTime;
                }
                else if (InputMap.FindMapping(InputAction.Right).Held(World.Input))
                {
                    if (Heading != Direction.Right)
                    {
                        Heading = Direction.Right;
                    }
                    else if (_keyHeld == 0)
                    {
                        _keyHeld = 0.1;
                    }

                    _keyHeld += deltaTime;
                }
                else
                {
                    _keyHeld -= deltaTime * 2;
                }

                _keyHeld = MathHelper.Clamp((float)_keyHeld, 0.0f, 0.1f);

                if (_keyQueued != Keys.None)
                {
                    if (_keyQueued == Keys.Up)
                    {
                        Heading = Direction.Up;
                    }
                    if (_keyQueued == Keys.Down)
                    {
                        Heading = Direction.Down;
                    }
                    if (_keyQueued == Keys.Left)
                    {
                        Heading = Direction.Left;
                    }
                    if (_keyQueued == Keys.Right)
                    {
                        Heading = Direction.Right;
                    }

                    _keyHeld   = 0.1f;
                    _keyQueued = Keys.None;
                }

                if (_lastHeading != Heading && _keyHeld < 0.1)
                {
                    _landWhen = World.Game.Time + 0.1;
                }

                if (_keyHeld >= 0.1)
                {
                    if (!World.IsPointBlocked(Position + Heading.ToPoint()))
                    {
                        MoveTo(Position + Heading.ToPoint());
                    }
                }

                if (InputMap.FindMapping(InputAction.Action).Pressed(World.Input))
                {
                    Point interactionPoint = Position + Heading.ToPoint();
                    interactionPoint.X = (int)MathHelper.Clamp(interactionPoint.X, 0, World.Map.Width - 1);
                    interactionPoint.Y = (int)MathHelper.Clamp(interactionPoint.Y, 0, World.Map.Height - 1);

                    foreach (Tile.MapLayer layer in Tile.CachedAllMapLayers)
                    {
                        TileEventBase events = World.Map[layer, interactionPoint.X, interactionPoint.Y].Events;
                        events?.OnInteract(World.Map.GetMetadata(layer, interactionPoint.X, interactionPoint.Y), World, interactionPoint);
                    }

                    foreach (NPC npc in World.NPCs)
                    {
                        if (npc.Position == interactionPoint)
                        {
                            bool isFacingPlayer =
                                Heading == Direction.Left && npc.Heading == Direction.Right ||
                                Heading == Direction.Right && npc.Heading == Direction.Left ||
                                Heading == Direction.Up && npc.Heading == Direction.Down ||
                                Heading == Direction.Down && npc.Heading == Direction.Up;

                            npc.Template.Behavior.OnInteract(npc, this, isFacingPlayer);
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
 private void Awake()
 {
     pMenuUI = GameObject.Find("PauseMenuUI").GetComponent <PauseMenuUI>();
 }
Exemplo n.º 15
0
 void Awake()
 {
     instance = this;
     canvas   = GetComponentInParent <Canvas>();
 }
Exemplo n.º 16
0
    public void ButtonSettings()
    {
        if (PauseMenuUI.activeSelf == false)
        {
            PauseMenuUI.SetActive(true);
            settingsOutline.SetActive(true);
            vjMove.SetActive(false);
            viFight.SetActive(false);
            bInteractA.SetActive(false);
            bGatherB.SetActive(false);
            bHide.SetActive(false);
            SetTools(false);
            bMainWeapon.SetActive(false);
            bSwap.SetActive(false);
            SetQuickAccessSlots(false);
            bInventory.SetActive(false);

            if (isInventoryOpen == true)
            {
                InventoryUI.SetActive(false);
            }
            if (isChestOpen == true)
            {
                ChestUI.SetActive(false);
            }
            if (isBuildModeOn == true || isRemoveModeOn == true)
            {
                bCancel.SetActive(false);
                bRotate.SetActive(false);
                stateText.SetActive(false);
            }

            Time.timeScale = 0f;
        }
        else
        {
            settingsOutline.SetActive(false);
            Time.timeScale = 1f;

            PauseMenuUI.SetActive(false);

            vjMove.SetActive(true);
            bGatherB.SetActive(true);
            bHide.SetActive(true);

            // Check if we was in remove mode
            if (isRemoveModeOn == false)
            {
                bInventory.SetActive(true);
                bInteractA.SetActive(true);
            }

            // Check if we was on Items and the tool bar wasn't hidden, also if we wasn't in build or remove mode
            if (isQuickAccessSlotsSwapped == true && isShown != false && isBuildModeOn != true && isRemoveModeOn != true)
            {
                SetTools(true);
                bMainWeapon.SetActive(true);
                bSwap.SetActive(true);
            }
            // Check if we was on QASlots and the tool bar wasn't hidden, also if we wasn't in build or remove mode
            else if (isQuickAccessSlotsSwapped == false && isShown != false && isBuildModeOn != true && isRemoveModeOn != true)
            {
                SetQuickAccessSlots(true);
                bMainWeapon.SetActive(true);
                bSwap.SetActive(true);
            }

            // Check if inventory was open
            if (isInventoryOpen == true)
            {
                InventoryUI.SetActive(true);

                viFight.SetActive(false);
                bInteractA.SetActive(false);
                bGatherB.SetActive(false);
            }

            // Check if we was in build or remove mode
            if (isBuildModeOn == true || isRemoveModeOn == true)
            {
                bCancel.SetActive(true);
                bRotate.SetActive(true);
                stateText.SetActive(true);
            }

            // Check if tools for build mode was hidden
            if (isShownBuildTools == false)
            {
                bCancel.SetActive(false);
                bRotate.SetActive(false);
            }

            // Check if we wasn't in build or remove mode and inventory closed to show Visual Icon for Fight mode
            if (isBuildModeOn == false && isRemoveModeOn == false && isInventoryOpen != true)
            {
                viFight.SetActive(true);
            }
        }
    }
Exemplo n.º 17
0
 public void PauseButton()
 {
     Time.timeScale = 0;
     InGamesScreen.SetActive(false);
     PauseMenuUI.SetActive(true);
 }
Exemplo n.º 18
0
 public void resume()
 {
     PauseMenuUI.SetActive(false);
     Time.timeScale = 1f;
     GameIsPaused   = false;
 }