Esempio n. 1
0
        public static void Update()
        {
            if (Input.SpecialKeys[Glut.GLUT_KEY_F1])
            {
                RenderDebugText.Toggle();
            }

            if (Input.SpecialKeys[Glut.GLUT_KEY_F2])
            {
                RenderHitboxes.Toggle();
            }

            if (Input.Keys['e'])
            {
                if (State == GameState.Normal)
                {
                    PlayerInventory.Instance.InventoryOpen.val = true;
                    State = GameState.Inventory;
                }
            }
            if (Input.Keys[13])
            {
                if (!StateChanged_Enter)
                {
                    if (State == GameState.Normal)
                    {
                        GameGuiRenderer.TxtInput.disabled = false;
                        State = GameState.Text;
                    }
                    else if (State == GameState.Text)
                    {
                        GameGuiRenderer.TxtInput.Execute();
                        GameGuiRenderer.TxtInput.disabled = true;
                        State = GameState.Normal;
                    }
                    StateChanged_Enter = true;
                }
            }
            else
            {
                StateChanged_Enter = false;
            }

            if (Input.Keys[27])
            {
                if (!StateChanged_Escape)
                {
                    switch (State)
                    {
                    case GameState.Normal:
                        State = GameState.Paused;
                        break;

                    case GameState.Paused:
                        State = GameState.Normal;
                        break;

                    case GameState.Inventory:
                        PlayerInventory.Instance.InventoryOpen.val = false;
                        State = GameState.Normal;
                        break;

                    case GameState.Text:
                        GameGuiRenderer.TxtInput.disabled = true;
                        State = GameState.Normal;
                        break;
                    }
                    StateChanged_Escape = true;
                }
            }
            else
            {
                StateChanged_Escape = false;
            }

            GameGuiRenderer.SetDebugText(DebugText());

            switch (State)
            {
            case GameState.Inventory:
                EntityManager.UpdateAll();
                Terrain.Update();
                PlayerInventory.Instance.UpdateHotbar();
                PlayerInventory.Instance.UpdateInventory();
                break;

            case GameState.Normal:
                EntityManager.UpdateAll();
                Terrain.Update();
                PlayerInventory.Instance.UpdateHotbar();
                PlayerInventory.Instance.UpdateInventory();
                break;

            case GameState.Paused:
            case GameState.Text:
                break;
            }
        }