Пример #1
0
    public void Load()
    {
        GUIPanel.Pannels.Clear();

        InventoryWindow = new InventoryScreen();
        InventoryWindow.Init();

        SkillScreen = new CharcterScreen();
        SkillScreen.Init();

        StatusWindow = new PlayerStatus();
        StatusWindow.Init();

        Selector = new TargetSelection();
        Selector.Init();
        Selector.Enabled = false;

        Loot = new LootScreen();
        Loot.Init();
        Loot.Enabled = false;

        GameMenu = new InGameMenu();
        GameMenu.Init();
        GameMenu.Enabled = false;
        InMenu = false;

        SetPlayer(GameState.Instance.PlayerObject);
    }
Пример #2
0
        /* The PokemonEngine() constructor initializes all of the important parts of the engine, including managers and screens. */
        public PokemonEngine()
        {
            /* The GraphicsDeviceManager is initialized, and the PreferredBackBuffer properties are set to the constants screenWidth and screenHeight.
             * This means that the engine window will have these dimensions, if possible.
             * The ScreenRectangle is also initialized with a position of zero and the screen width and height. */
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = screenWidth;
            graphics.PreferredBackBufferHeight = screenHeight;
            ScreenRectangle = new Rectangle(0, 0, screenWidth, screenHeight);

            /* The two vital components of the engine, the InputHandler and the GameStateManager, are initialized and added to the engine's master component list.
             * Whenever base.Update() and base.Draw() are called from this class, everything on the component list is updated and drawn.
             * Since these classes contain all code for handling input and for drawing the game states, everything will now be updated and drawn properly. */
            Components.Add(new InputHandler(this));
            stateManager = new GameStateManager(this);
            Components.Add(stateManager);

            /* Every screen is initialized. Each has a reference to the engine and the state manager passed in. */
            SplashScreen          = new SplashScreen(this, stateManager);
            StartScreen           = new StartScreen(this, stateManager);
            WorldScreen           = new WorldScreen(this, stateManager);
            CharacterSelectScreen = new CharacterSelectScreen(this, stateManager);
            LoadGameScreen        = new LoadGameScreen(this, stateManager);
            StarterSelectScreen   = new StarterSelectScreen(this, stateManager);
            InventoryScreen       = new InventoryScreen(this, stateManager);
            BattleScreen          = new BattleScreen(this, stateManager);
            SwitchScreen          = new SwitchScreen(this, stateManager);

            /* The state stack is reset and the SplashScreen is pushed on. This means the first thing to appear when the engine is run will be the SplashScreen. */
            stateManager.ChangeState(SplashScreen);

            /* The content root directory is set to the "/Content/" folder, meaning every filename string passed to Content.Load<T>() will start in this folder. */
            Content.RootDirectory = "Content";

            /* Type matchups are initialized in the PkmnUtils class, which creates the type advantage lookup table. */
            PkmnUtils.InitTypeMatchups();

            /* These two settings make the game run as many times per second as it can.
            * They could be changed later depending on how well the engine performs. */
            IsFixedTimeStep = false;
            graphics.SynchronizeWithVerticalRetrace = false;
        }
Пример #3
0
    void UpdateInventoryItemUI(InventoryPickupDestination pickupType, int slot)
    {
        InventoryScreen invScreen = (InventoryScreen)UIManager.instance.GetScreenInstance(ScreenName.Inventory);

        if (pickupType == InventoryPickupDestination.backpack)
        {
            if (invScreen != null)
            {
                invScreen.UpdateSlot(slot, false);
            }
        }
        else if (pickupType == InventoryPickupDestination.equipped)
        {
            if (invScreen != null)
            {
                invScreen.UpdateSlot(slot, true);
            }
            GameManager.instance.UpdateHudSlot(slot);
        }
    }
    // Use this for initialization
    void Start()
    {
        myHotbar    = hotbar.GetComponent <ItemBar>();
        myInventory = inventory.GetComponent <InventoryScreen>();
        myLoadout   = loadoutPrefab.GetComponent <Loadout>();

        int i = 0;

        foreach (GameObject obj in myLoadout.GetHotbar())
        {
            myHotbar.AddItemAtSpot(obj, "h" + i);
            i++;
        }

        i = 0;
        foreach (GameObject obj in myLoadout.GetInventory())
        {
            myInventory.AddItemAtSpot(obj, "i" + i);
            i++;
        }
    }
Пример #5
0
        public Game1()
        {
            _graphics       = new GraphicsDeviceManager(this);
            ScreenRectangle = new Rectangle(
                0,
                0,
                ScreenWidth,
                ScreenHeight);
            IsMouseVisible = true;

            Content.RootDirectory = "Content";

            Components.Add(new InputHandler(this));

            _gameStateManager = new GameStateManager(this);
            Components.Add(_gameStateManager);

            _ = new TextureManager();

            TitleScreen              = new TitleScreen(this, _gameStateManager);
            StartMenuScreen          = new StartMenuScreen(this, _gameStateManager);
            GamePlayScreen           = new GamePlayScreen(this, _gameStateManager);
            CharacterGeneratorScreen = new CharacterGeneratorScreen(this, _gameStateManager);
            SkillScreen              = new SkillScreen(this, _gameStateManager);
            LoadGameScreen           = new LoadGameScreen(this, _gameStateManager);
            ConversationScreen       = new ConversationScreen(this, _gameStateManager);
            ShopScreen         = new ShopState(this, _gameStateManager);
            InventoryScreen    = new InventoryScreen(this, _gameStateManager);
            CombatScreen       = new CombatScreen(this, _gameStateManager);
            GameOverScreen     = new GameOverScreen(this, _gameStateManager);
            LootScreen         = new LootScreen(this, _gameStateManager);
            StatsScreen        = new StatsScreen(this, _gameStateManager);
            LevelScreen        = new LevelScreen(this, _gameStateManager);
            QuestCompleteState = new QuestCompleteState(this, _gameStateManager);

            _gameStateManager.ChangeState(TitleScreen);

            IsFixedTimeStep = false;
            _graphics.SynchronizeWithVerticalRetrace = false;
        }
Пример #6
0
 void Update()
 {
     if (Input.GetButtonDown("Menu"))
     {
         if (CST.activeSelf)
         {
             Screen.Reset();
             CST.SetActive(false);
             AudioSource.PlayClipAtPoint(MenuClosed, Camera.main.transform.position);
         }
         else
         {
             CST.SetActive(true);
             AudioSource.PlayClipAtPoint(MenuOpen, Camera.main.transform.position);
             if (GameObject.FindGameObjectWithTag("Equipper").GetComponent <InventoryScreen>())
             {
                 InventoryScreen screen = GameObject.FindGameObjectWithTag("Equipper").GetComponent <InventoryScreen>();
                 screen.SetInventoryVisually(Inv);
             }
         }
     }
 }
Пример #7
0
        public ScreenManager()
        {
            GraphicsDevceMgr = new GraphicsDeviceManager(this);
            GraphicsDevceMgr.PreferredBackBufferWidth  = 800;
            GraphicsDevceMgr.PreferredBackBufferHeight = 700;
            Content.RootDirectory = "Content";

            Screens              = new Dictionary <string, Screen>();
            titleScreen          = new TitleScreen();
            gameScreen           = new GameScreen();
            optionScreen         = new OptionsScreen();
            pauseScreen          = new PauseScreen();
            loadScreen           = new LoadScreen();
            inventoryScreen      = new InventoryScreen();
            battleScreen         = new BattleScreen();
            tutorialScreen       = new TutorialScreen();
            tutorialBattleScreen = new TutorialBattleScreen();
            splashScreen         = new SplashScreen("SplashScreen", "SplashScreen2");
            splashScreen2        = new SplashScreen("SplashText", "TitleScreen");
            shopScreen           = new ShopScreen();
            // LoadContent();
            //Initialize();
            CurrentScreen = splashScreen;
        }
Пример #8
0
        /// <summary>
        /// Handle user input to the actions menu.
        /// </summary>
        public void UpdateActionsMenu()
        {

            
            Vector2 position =startingInfoPosition;
            position.Y -= 150f;
            float height = 25f;
            bool clickedOK = false;
            // check mouse over
          //  if (InputManager.MouseMoved())
      //      {

                // action count 4
                for (int i = 0; i < 5; i++)
                {
                    Rectangle rect = new Rectangle(ActionMenuRect.X, (int)position.Y, ActionMenuRect.Width, (int)height);
                    if (InputManager.IsButtonHovered(rect))
                    {
                        highlightedAction = i;
                    }
                    if (InputManager.IsButtonClicked(rect))
                    {
                        highlightedAction = i;
                        clickedOK = true;
                      //  Session.Hud.UpdateActionsMenu();
                        //if (!clickedOK)
                        //{
                        //    clickedOK = InputManager.IsButtonClicked(rect);
                        //    //if (clickedOK)
                        //    //    // System.Diagnostics.Debug.WriteLine("Clicked");
                        //    if (clickedOK)
                        //        break;

                        //}
                        break;
                    }
                    position.Y += height;
           //     }
                
            }

            // cursor up
            if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (highlightedAction > 0)
                {
                    highlightedAction--;
                }
                return;
            }
            // cursor down
            if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                if (highlightedAction < actionList.Length - 1)
                {
                    highlightedAction++;
                }
                return;
            }
            // select an action
            if (InputManager.IsActionTriggered(InputManager.Action.Ok) || clickedOK)
            {
                InputManager.IsHubActive = false;
                switch (actionList[highlightedAction])
                {
                    case "Attack":
                        {
                            
                            ActionText = "Performing a Melee Attack";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new MeleeCombatAction(CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Target =
                                CombatEngine.FirstEnemyTarget;
                        }
                        break;

                    case "Fancy":
                        {
                            SpellbookScreen spellbookScreen = new SpellbookScreen(
                                CombatEngine.HighlightedCombatant.Character,
                                CombatEngine.HighlightedCombatant.Statistics);
                            spellbookScreen.SpellSelected +=
                                new SpellbookScreen.SpellSelectedHandler(
                                spellbookScreen_SpellSelected);
                            Session.ScreenManager.AddScreen(spellbookScreen);
                            InputManager.IsInAction = true;
                        }
                        break;

                    case "Junk":
                        {
                            InventoryScreen inventoryScreen = new InventoryScreen(true);
                            inventoryScreen.GearSelected +=
                                new InventoryScreen.GearSelectedHandler(
                                inventoryScreen_GearSelected);
                            Session.ScreenManager.AddScreen(inventoryScreen);
                            InputManager.IsInAction = true;
                        }
                        break;

                    case "Defend":
                        {
                            ActionText = "Defending";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new DefendCombatAction(
                                CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Start();
                        }
                        break;

                    case "Flee":
                        CombatEngine.AttemptFlee();
                        break;
                }
                return;
            }
        }
Пример #9
0
        /// <summary>
        /// Scans the SadConsole's Global KeyboardState and triggers behaviour
        /// based on the button pressed.
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public override bool ProcessKeyboard(Keyboard info)
        {
            if (GameLoop.World != null)
            {
                if (HandleMove(info))
                {
                    if (!GetPlayer.Bumped && GameLoop.World.CurrentMap.ControlledEntitiy is Player)
                    {
                        GameLoop.World.ProcessTurn(TimeHelper.GetWalkTime(GetPlayer), true);
                    }
                    else if (GameLoop.World.CurrentMap.ControlledEntitiy is Player)
                    {
                        GameLoop.World.ProcessTurn(TimeHelper.GetAttackTime(GetPlayer), true);
                    }

                    return(true);
                }

                if (info.IsKeyPressed(Keys.NumPad5) || info.IsKeyPressed(Keys.OemPeriod))
                {
                    GameLoop.World.ProcessTurn(TimeHelper.Wait, true);
                }

                if (info.IsKeyPressed(Keys.A))
                {
                    bool sucess = CommandManager.DirectAttack(GameLoop.World.Player);
                    GameLoop.World.ProcessTurn(TimeHelper.GetAttackTime(GameLoop.World.Player), sucess);
                }

                if (info.IsKeyPressed(Keys.G))
                {
                    Item item   = GameLoop.World.CurrentMap.GetEntityAt <Item>(GameLoop.World.Player.Position);
                    bool sucess = CommandManager.PickUp(GameLoop.World.Player, item);
                    InventoryScreen.ShowItems(GameLoop.World.Player);
                    GameLoop.World.ProcessTurn(TimeHelper.Interact, sucess);
                }
                if (info.IsKeyPressed(Keys.D))
                {
                    bool sucess = CommandManager.DropItems(GameLoop.World.Player);
                    Item item   = GameLoop.World.CurrentMap.GetEntityAt <Item>(GameLoop.World.Player.Position);
                    InventoryScreen.RemoveItemFromConsole(item);
                    InventoryScreen.ShowItems(GameLoop.World.Player);
                    GameLoop.World.ProcessTurn(TimeHelper.Interact, sucess);
                }
                if (info.IsKeyPressed(Keys.C))
                {
                    bool sucess = CommandManager.CloseDoor(GameLoop.World.Player);
                    GameLoop.World.ProcessTurn(TimeHelper.Interact, sucess);
                    MapWindow.MapConsole.IsDirty = true;
                }
                if (info.IsKeyPressed(Keys.I))
                {
                    InventoryScreen.Show();
                }

                if (info.IsKeyPressed(Keys.H))
                {
                    bool sucess = CommandManager.SacrificeLifeEnergyToMana(GameLoop.World.Player);
                    GameLoop.World.ProcessTurn(TimeHelper.MagicalThings, sucess);
                }

                if (info.IsKeyPressed(Keys.L))
                {
                    if (!(target != null))
                    {
                        target = new Target(GetPlayer.Position);
                    }

                    if (target.EntityInTarget())
                    {
                        if (target.TargetList != null)
                        {
                            LookWindow w = new LookWindow(target.TargetList[0]);
                            w.Show();

                            return(true);
                        }
                    }

                    if (GameLoop.World.CurrentMap.ControlledEntitiy is not Player &&
                        !target.EntityInTarget())
                    {
                        GameLoop.World.ChangeControlledEntity(GetPlayer);
                        GameLoop.World.CurrentMap.Remove(target.Cursor);
                        target = null;
                        return(true);
                    }

                    GameLoop.World.CurrentMap.Add(target.Cursor);

                    GameLoop.World.ChangeControlledEntity(target.Cursor);

                    return(true);
                }

                if (info.IsKeyDown(Keys.LeftShift) && info.IsKeyPressed(Keys.Z))
                {
                    var spellBase = GetPlayer.Magic.QuerySpell("magic_missile");

                    var entity = GameLoop.World.CurrentMap.GetClosestEntity(GetPlayer.Position, spellBase.SpellRange);

                    if (entity != null)
                    {
                        bool sucess = spellBase.CastSpell(
                            entity.Position,
                            GetPlayer);

                        GameLoop.World.ProcessTurn(TimeHelper.MagicalThings, sucess);
                        return(true);
                    }
                    else
                    {
                        GameLoop.UIManager.MessageLog.Add("There is no target for the spell!");
                        return(false);
                    }
                }

#if DEBUG
                if (info.IsKeyPressed(Keys.F10))
                {
                    CommandManager.ToggleFOV();
                    MapWindow.MapConsole.IsDirty = true;
                }

                if (info.IsKeyPressed(Keys.F8))
                {
                    GetPlayer.AddComponent(new Components.TestComponent(GetPlayer));
                }

                if (info.IsKeyPressed(Keys.NumPad0))
                {
                    LookWindow w = new LookWindow(GetPlayer);
                    w.Show();
                }
#endif

                if (info.IsKeyPressed(Keys.Escape) && NoPopWindow)
                {
                    //SadConsole.Game.Instance.Exit();
                    MainMenu.Show();
                    MainMenu.IsFocused = true;
                }
            }

            return(base.ProcessKeyboard(info));
        }
Пример #10
0
        /// <summary>
        /// Handle user input to the actions menu.
        /// </summary>
        public void UpdateActionsMenu()
        {
            bool isMenuItemPressed = false;
            if (firstCombatMenuPosition != Rectangle.Empty)
            {
                int x = firstCombatMenuPosition.X;
                for (int playerCount = 0; playerCount < CombatEngine.Players.Count; playerCount++)
                {
                    for (int actionIndex = 0; actionIndex < actionList.Length; actionIndex++)
                    {
                        float yPosition = firstCombatMenuPosition.Y;
                        if (actionIndex + 1 > 1)
                        {
                            yPosition = yPosition + (heightInterval * actionIndex + 1);
                        }
                        Rectangle currentActionPosition = new Rectangle(x, (int)yPosition,
                            (int)(firstCombatMenuPosition.Width * ScaledVector2.ScaleFactor),
                            (int)(firstCombatMenuPosition.Height * ScaledVector2.ScaleFactor));
                        if (InputManager.IsButtonClicked(currentActionPosition))
                        {
                            highlightedAction = actionIndex;
                            isMenuItemPressed = true;
                            break;
                        }
                    }
                    x += (int)(activeCharInfoTexture.Width * ScaledVector2.DrawFactor - 6f * ScaledVector2.ScaleFactor);
                }
            }

            // select an action
            if (isMenuItemPressed)
            {
                switch (actionList[highlightedAction])
                {
                    case "Attack":
                        {
                            ActionText = "Performing a Melee Attack";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new MeleeCombatAction(CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Target =
                                CombatEngine.FirstEnemyTarget;
                        }
                        break;

                    case "Spell":
                        {
                            SpellbookScreen spellbookScreen = new SpellbookScreen(
                                CombatEngine.HighlightedCombatant.Character,
                                CombatEngine.HighlightedCombatant.Statistics);
                            spellbookScreen.SpellSelected +=
                                new SpellbookScreen.SpellSelectedHandler(
                                spellbookScreen_SpellSelected);
                            Session.ScreenManager.AddScreen(spellbookScreen);
                        }
                        break;

                    case "Item":
                        {
                            InventoryScreen inventoryScreen = new InventoryScreen(true);
                            inventoryScreen.GearSelected +=
                                new InventoryScreen.GearSelectedHandler(
                                inventoryScreen_GearSelected);
                            Session.ScreenManager.AddScreen(inventoryScreen);
                        }
                        break;

                    case "Defend":
                        {
                            ActionText = "Defending";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new DefendCombatAction(
                                CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Start();
                        }
                        break;

                    case "Flee":
                        CombatEngine.AttemptFlee();
                        break;
                }
                return;
            }
        }
Пример #11
0
Файл: Hud.cs Проект: plhearn/pet
        /// <summary>
        /// Handle user input to the actions menu.
        /// </summary>
        public void UpdateActionsMenu()
        {
            // cursor up
            if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (highlightedAction > 0)
                {
                    highlightedAction--;
                }
                return;
            }
            // cursor down
            if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                if (highlightedAction < actionList.Length - 1)
                {
                    highlightedAction++;
                }
                return;
            }
            // select an action
            if (InputManager.IsActionTriggered(InputManager.Action.Ok))
            {
                switch (actionList[highlightedAction])
                {
                    case "Attack":
                        {
                            ActionText = "Performing a Melee Attack";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new MeleeCombatAction(CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Target =
                                CombatEngine.FirstEnemyTarget;
                        }
                        break;

                    case "Spell":
                        {
                            SpellbookScreen spellbookScreen = new SpellbookScreen(
                                CombatEngine.HighlightedCombatant.Character,
                                CombatEngine.HighlightedCombatant.Statistics);
                            spellbookScreen.SpellSelected +=
                                new SpellbookScreen.SpellSelectedHandler(
                                spellbookScreen_SpellSelected);
                            Session.ScreenManager.AddScreen(spellbookScreen);
                        }
                        break;

                    case "Item":
                        {
                            InventoryScreen inventoryScreen = new InventoryScreen(true);
                            inventoryScreen.GearSelected +=
                                new InventoryScreen.GearSelectedHandler(
                                inventoryScreen_GearSelected);
                            Session.ScreenManager.AddScreen(inventoryScreen);
                        }
                        break;

                    case "Defend":
                        {
                            ActionText = "Defending";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new DefendCombatAction(
                                CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Start();
                        }
                        break;

                    case "Flee":
                        CombatEngine.AttemptFlee();
                        break;
                }
                return;
            }
        }
Пример #12
0
 public InventoryPlayer(InventoryScreen parent, string inventoryFont) : this(parent, inventoryFont, new Point(0, 0))
 {
 }
Пример #13
0
 void Init()
 {
     gameObject.GetComponent <SpriteRenderer>().sprite = prefabToCopy.GetComponent <attackLibrary>().icon;
     iBar    = GameObject.FindGameObjectWithTag("ItemBarHolder").GetComponent <ItemBar>();
     iScreen = GameObject.FindGameObjectWithTag("UI").GetComponent <InventoryScreen>();
 }
Пример #14
0
 public void Setup(InventoryScreen control, int i)
 {
     controller = control;
     index      = i;
 }
Пример #15
0
 private void Awake()
 {
     _current = this;
 }
Пример #16
0
 public static void CreateInventoryScreen(NamelessGame game)
 {
     InventoryScreen = new InventoryScreen(game);
 }
 public InventoryController(InventoryScreen inventoryScreen)
 {
     this._inventoryScreen = inventoryScreen;
 }
Пример #18
0
 // Use this for initialization
 void Awake()
 {
     text   = gameObject.GetComponentInChildren <Text>();
     button = GetComponent <Button>();
     invScr = GetComponentInParent <InventoryScreen>();
 }