Esempio n. 1
0
        public void Update(GameTime gameTime)
        {
            // Switch statement needed for on the fly texture loading
            // OTF texture loading will only be done for game generated textures, they will not be loaded from files!
            // Things that are loaded from texture files are found in spriteDicitionary.
            // (one exception is Font files, this will be fixed later on)
            switch (Game1.state)
            {
            case GameState.Menu:
                //Controls.guiElements["mainMenu"].Update(gameTime);
                break;

            case GameState.Pause:
                //Controls.guiElements["pauseMenu"].Update(gameTime);
                break;

            // START FROM HERE

            case GameState.Inventory:
                InventoryMenu inventoryMenu = Controls.guiElements["inventoryMenu"] as InventoryMenu;
                if (!inventoryMenu.IsInventoryLoaded)
                {
                    inventoryMenu.Load(player.inventory);
                    //inventoryMenu.LoadVisuals(mainGame.Content, graphics);
                    //inventoryMenu.Update(gameTime);
                }

                //Controls.guiElements["inventoryMenu"].Update(gameTime);
                break;

            case GameState.FastTravel:
                break;

            case GameState.Game:
                // casting takes a lot of time, a way to check if user changed weapon??
                // UI (health, current wep, other stuff)
                //Controls.guiElements["livingEntityInfoUI"].Update(gameTime);

                // WHAT IF PLAYER CHANGES WORLD (?) -Fixed?(Sean)
                player = mainGame.worldManager.CurrentWorld.manager.GetPlayer();

                // VV Very Slow VV
                (Controls.guiElements["livingEntityInfoUI"] as LivingEntityInfoUI).LivingEntity = player;

                if (player.inventory.ActiveWeapon >= 0)
                {
                    (Controls.guiElements["weaponInfoUI"] as WeaponInfoUI).Item = player.inventory.EntityInventory[player.inventory.ActiveWeapon];
                    //Controls.guiElements["weaponInfoUI"].LoadVisuals(mainGame.Content, graphics);
                    Controls.guiElements["weaponInfoUI"].Update(gameTime);
                }
                else
                {
                    (Controls.guiElements["weaponInfoUI"] as WeaponInfoUI).Item = null;
                }


                // PARTICLES
                for (int i = 0; i < particles.Count; i++)
                {
                    if (particles[i].CurrentTime <= 0)     // possible problems (?)
                    {
                        particles.Remove(particles[i]);
                    }
                    else
                    {
                        particles[i].Update(gameTime);
                    }
                }


                //Controls.guiElements["weaponInfoUI"].Update(gameTime);
                //Controls.guiElements["livingEntityInfoUI"].Update(gameTime);
                break;

            case GameState.QuestLog:

                QuestLogUI questLogUI = Controls.guiElements["questLog"] as QuestLogUI;
                if (!questLogUI.IsQuestLogLoaded)
                {
                    questLogUI.Load(player.log);
                    //questLogUI.LoadVisuals(mainGame.Content, graphics);
                    //questLogUI.Update(gameTime);
                }
                //Controls.guiElements["questLog"]

                /*
                 * if(tempQuest == null)
                 * {
                 *  tempQuest = new QuestUI();
                 *  tempQuest.Load(player.log.GetByStatus(1)[0]);
                 *  tempQuest.LoadVisuals(mainGame.Content, graphics);
                 *  tempQuest.Update(gameTime);
                 * }
                 * */
                break;

            case GameState.Shop:
                break;

            case GameState.WeaponWheel:

                WeaponWheelUIV2 weaponWheelUI = Controls.guiElements["weaponWheel"] as WeaponWheelUIV2;
                if (!weaponWheelUI.IsInventoryLoaded)
                {
                    weaponWheelUI.Load(player.inventory);
                    //weaponWheelUI.LoadVisuals(mainGame.Content, graphics);
                    //weaponWheelUI.Update(gameTime);
                }
                //Controls.guiElements["weaponWheel"].Update(gameTime);
                //weapons come from holster
                break;
            }

            // DO THIS FOR SPRITES AND OTHER MOVING THINGS
            // if the GUI is not visible, dont update it.
            foreach (KeyValuePair <string, Control> c in Controls.guiElements)
            {
                if (c.Value.IsVisible) // or just loaded.
                {
                    c.Value.Update(gameTime);
                }
            }

            for (int i = 0; i < dialogs.Count; i++)
            {
                if (dialogs[i].EventsCompleted == true) // possible problems (?)
                {
                    dialogs.Remove(dialogs[i]);
                }
                else
                {
                    dialogs[i].Update(gameTime);
                }
            }
        }