Esempio n. 1
0
        private bool IsPanelForRequestedState(IHudPanel hudPanel, InGameStates newState)
        {
            switch (newState)
            {
            case InGameStates.Inventory: return(hudPanel is InventoryPanel);

            case InGameStates.ActiveSpells: return(hudPanel is ActiveSpellsPanel);

            case InGameStates.PassiveSpells: return(hudPanel is PassiveSpellsPanel);

            case InGameStates.Chat: return(hudPanel is ChatPanel);

            case InGameStates.Stats: return(hudPanel is StatsPanel);

            case InGameStates.OnlineList: return(hudPanel is OnlineListPanel);

            case InGameStates.Party: return(hudPanel is PartyPanel);

            case InGameStates.Settings: return(hudPanel is SettingsPanel);

            case InGameStates.Help: return(hudPanel is HelpPanel);

            default: throw new ArgumentOutOfRangeException(nameof(newState), newState, null);
            }
        }
Esempio n. 2
0
        private IXNAButton CreateStateChangeButton(InGameStates whichState)
        {
            if (whichState == InGameStates.News)
            {
                throw new ArgumentOutOfRangeException(nameof(whichState), "News state does not have a button associated with it");
            }
            var buttonIndex = (int)whichState;

            var mainButtonTexture = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 25);
            var widthDelta        = mainButtonTexture.Width / 2;
            var heightDelta       = mainButtonTexture.Height / 11;

            var xPosition = buttonIndex < 6 ? 62 : 590;
            var yPosition = (buttonIndex < 6 ? 330 : 350) + (buttonIndex < 6 ? buttonIndex : buttonIndex - 6) * 20;

            var retButton = new XNAButton(
                mainButtonTexture,
                new Vector2(xPosition, yPosition),
                new Rectangle(0, heightDelta * buttonIndex, widthDelta, heightDelta),
                new Rectangle(widthDelta, heightDelta * buttonIndex, widthDelta, heightDelta))
            {
                DrawOrder = HUD_CONTROL_LAYER
            };

            retButton.OnClick      += (o, e) => DoHudStateChangeClick(whichState);
            retButton.OnMouseEnter += (o, e) => _statusLabelSetter.SetStatusLabel(
                EOResourceID.STATUS_LABEL_TYPE_BUTTON,
                EOResourceID.STATUS_LABEL_HUD_BUTTON_HOVER_FIRST + buttonIndex);
            return(retButton);
        }
	void EnableObjects(InGameStates p_futureState)
	{
		if (currentState == InGameStates.TUTORIAL)
			tutorialManager.ChangeTutorialMode(false);

		panelsList [(int)currentState].SetActive (false);
		statesGOList [(int)currentState].SetActive (false);
		currentState = p_futureState;
		panelsList [(int)currentState].SetActive (true);
		statesGOList [(int)currentState].SetActive (true);

		if (pauseManager.isPaused)
		{
			if (currentState == InGameStates.GAME)
				pauseManager.PauseGame(false);
		}
		else
		{
			if (currentState == InGameStates.PAUSE || currentState == InGameStates.TUTORIAL || currentState == InGameStates.FINISHED || currentState == InGameStates.OVERVIEW)
				pauseManager.PauseGame(true);
		}

		if (currentState == InGameStates.TUTORIAL)
		{
			tutorialManager.ChangeTutorialMode(true);
			shootUIAnchor.transform.parent = tutorialPanel.transform;
		}
		else
			shootUIAnchor.transform.parent = gamePanel.transform;
	}
	public void ChangeToState (InGameStates p_futureState)
	{
		if (currentState == p_futureState)
			return;

		EnableObjects (p_futureState);
	}
Esempio n. 5
0
        public void SwitchToState(InGameStates newState)
        {
            if (!_hudControlProvider.IsInGame)
            {
                return;
            }

            _hudControlProvider.HudPanels.Single(x => x.Visible).Visible = false;
            _hudControlProvider.HudPanels.Single(x => IsPanelForRequestedState(x, newState)).Visible = true;
        }
Esempio n. 6
0
        private void DoHudStateChangeClick(InGameStates whichState)
        {
            switch (whichState)
            {
            case InGameStates.Inventory: _hudButtonController.ClickInventory(); break;

            case InGameStates.ViewMapToggle: _hudButtonController.ClickViewMapToggle(); break;

            case InGameStates.ActiveSpells: _hudButtonController.ClickActiveSpells(); break;

            case InGameStates.PassiveSpells: _hudButtonController.ClickPassiveSpells(); break;

            case InGameStates.Chat:
                _hudButtonController.ClickChat();
                _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_CHAT_PANEL_NOW_VIEWED);
                break;

            case InGameStates.Stats:
                _hudButtonController.ClickStats();
                _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_STATS_PANEL_NOW_VIEWED);
                break;

            case InGameStates.OnlineList:
                _hudButtonController.ClickOnlineList();
                _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_ONLINE_PLAYERS_NOW_VIEWED);
                break;

            case InGameStates.Party: _hudButtonController.ClickParty(); break;

            case InGameStates.Macro: break;

            case InGameStates.Settings: _hudButtonController.ClickSettings(); break;

            case InGameStates.Help:
                _hudButtonController.ClickHelp();
                _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_HUD_BUTTON_HOVER_LAST);
                break;

            default: throw new ArgumentOutOfRangeException(nameof(whichState), whichState, null);
            }
        }
Esempio n. 7
0
        private IGameComponent CreateStatePanel(InGameStates whichState)
        {
            IHudPanel retPanel;

            switch (whichState)
            {
            case InGameStates.Inventory: retPanel = _hudPanelFactory.CreateInventoryPanel(); break;

            case InGameStates.ActiveSpells: retPanel = _hudPanelFactory.CreateActiveSpellsPanel(); break;

            case InGameStates.PassiveSpells: retPanel = _hudPanelFactory.CreatePassiveSpellsPanel(); break;

            case InGameStates.Chat: retPanel = _hudPanelFactory.CreateChatPanel(); break;

            case InGameStates.Stats: retPanel = _hudPanelFactory.CreateStatsPanel(); break;

            case InGameStates.OnlineList: retPanel = _hudPanelFactory.CreateOnlineListPanel(); break;

            case InGameStates.Party: retPanel = _hudPanelFactory.CreatePartyPanel(); break;

            case InGameStates.Settings: retPanel = _hudPanelFactory.CreateSettingsPanel(); break;

            case InGameStates.Help: retPanel = _hudPanelFactory.CreateHelpPanel(); break;

            case InGameStates.News: retPanel = _hudPanelFactory.CreateNewsPanel(); break;

            default: throw new ArgumentOutOfRangeException(nameof(whichState), whichState, "Panel specification is out of range.");
            }

            //news is visible by default when loading the game
            if (whichState != InGameStates.News)
            {
                retPanel.Visible = false;
            }

            return(retPanel);
        }
Esempio n. 8
0
        public HUD(Game g, PacketAPI api)
            : base(g)
        {
            if (!api.Initialized)
            {
                throw new ArgumentException("Need to initialize connection before the in-game stuff will work");
            }
            m_packetAPI = api;

            DrawOrder = 5;

            mainFrame = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 1, true);
            topLeft   = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 21, true);
            sidebar   = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 22, true);
            topBar    = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 23, true);
            filler    = new Texture2D(g.GraphicsDevice, 1, 1);
            filler.SetData(new[] { Color.FromNonPremultiplied(8, 8, 8, 255) });

            Texture2D mainButtonTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 25);

            mainBtn = new XNAButton[NUM_BTN];

            //set up panels
            Texture2D invBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 44);

            pnlInventory = new XNAPanel(new Rectangle(102, 330, invBG.Width, invBG.Height))
            {
                BackgroundImage = invBG,
                Visible         = false
            };

            Texture2D spellsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 62);

            pnlActiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height))
            {
                BackgroundImage = spellsBG,
                Visible         = false
            };

            pnlPassiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height))
            {
                BackgroundImage = spellsBG,
                Visible         = false
            };

            Texture2D chatBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 28);

            pnlChat = new XNAPanel(new Rectangle(102, 330, chatBG.Width, chatBG.Height))
            {
                BackgroundImage = chatBG,
                Visible         = false
            };

            Texture2D statsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 34);

            pnlStats = new XNAPanel(new Rectangle(102, 330, statsBG.Width, statsBG.Height))
            {
                BackgroundImage = statsBG,
                Visible         = false
            };

            Texture2D onlineBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 36);

            pnlOnline = new XNAPanel(new Rectangle(102, 330, onlineBG.Width, onlineBG.Height))
            {
                BackgroundImage = onlineBG,
                Visible         = false
            };

            Texture2D partyBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 42);

            pnlParty = new XNAPanel(new Rectangle(102, 330, partyBG.Width, partyBG.Height))
            {
                BackgroundImage = partyBG,
                Visible         = false
            };

            Texture2D settingsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 47);

            pnlSettings = new XNAPanel(new Rectangle(102, 330, settingsBG.Width, settingsBG.Height))
            {
                BackgroundImage = settingsBG,
                Visible         = false
            };

            Texture2D helpBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 63);

            pnlHelp = new XNAPanel(new Rectangle(102, 330, helpBG.Width, helpBG.Height))
            {
                BackgroundImage = helpBG,
                Visible         = false
            };

            Texture2D newsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 48);

            pnlNews = new XNAPanel(new Rectangle(102, 330, newsBG.Width, newsBG.Height))
            {
                BackgroundImage = newsBG
            };

            //for easy update of all panels via foreach
            List <XNAPanel> pnlCollection = new List <XNAPanel>(10)
            {
                pnlInventory,
                pnlActiveSpells,
                pnlPassiveSpells,
                pnlChat,
                pnlStats,
                pnlOnline,
                pnlParty,
                pnlSettings,
                pnlHelp,
                pnlNews
            };

            //pnlCollection.Add(pnlMacro); //if this ever happens...

            pnlCollection.ForEach(_pnl => World.IgnoreDialogs(_pnl));

            for (int i = 0; i < NUM_BTN; ++i)
            {
                Texture2D _out = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN);
                Texture2D _ovr = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN);

                Rectangle _outRec = new Rectangle(0, i * _out.Height, _out.Width, _out.Height);
                Rectangle _ovrRec = new Rectangle(_ovr.Width, i * _ovr.Height, _ovr.Width, _ovr.Height);

                Color[] _outBuf = new Color[_outRec.Width * _outRec.Height];
                Color[] _ovrBuf = new Color[_ovrRec.Width * _ovrRec.Height];

                mainButtonTexture.GetData(0, _outRec, _outBuf, 0, _outBuf.Length);
                _out.SetData(_outBuf);

                mainButtonTexture.GetData(0, _ovrRec, _ovrBuf, 0, _ovrBuf.Length);
                _ovr.SetData(_ovrBuf);

                //0-5: left side, starting at 59, 327 with increments of 20
                //6-10: right side, starting at 587, 347
                Vector2 btnLoc = new Vector2(i < 6 ? 62 : 590, (i < 6 ? 330 : 350) + ((i < 6 ? i : i - 6) * 20));

                mainBtn[i] = new XNAButton(new [] { _out, _ovr }, btnLoc);
                World.IgnoreDialogs(mainBtn[i]);
            }

            //left button onclick events
            mainBtn[0].OnClick += (s, e) => _doStateChange(InGameStates.Inventory);
            mainBtn[1].OnClick += (s, e) => World.Instance.ActiveMapRenderer.ToggleMapView();
            mainBtn[2].OnClick += (s, e) => _doStateChange(InGameStates.Active);
            mainBtn[3].OnClick += (s, e) => _doStateChange(InGameStates.Passive);
            mainBtn[4].OnClick += (s, e) => _doStateChange(InGameStates.Chat);
            mainBtn[5].OnClick += (s, e) => _doStateChange(InGameStates.Stats);

            //right button onclick events
            mainBtn[6].OnClick += (s, e) => _doStateChange(InGameStates.Online);
            mainBtn[7].OnClick += (s, e) => _doStateChange(InGameStates.Party);
            //mainBtn[8].OnClick += OnViewMacro; //not implemented in EO client
            mainBtn[9].OnClick  += (s, e) => _doStateChange(InGameStates.Settings);
            mainBtn[10].OnClick += (s, e) => _doStateChange(InGameStates.Help);

            SpriteBatch = new SpriteBatch(g.GraphicsDevice);

            state = InGameStates.News;

            chatRenderer = new EOChatRenderer();
            chatRenderer.SetParent(pnlChat);
            chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
                                      World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1),
                                      ChatType.Note, ChatColor.Server);
            chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
                                      World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2),
                                      ChatType.Note, ChatColor.Server);

            newsTab = new ChatTab(pnlNews);

            chatTextBox = new ChatTextBox(new Rectangle(124, 308, 440, 19), g.Content.Load <Texture2D>("cursor"), "Microsoft Sans Serif", 8.0f)
            {
                Selected = true,
                Visible  = true,
                MaxChars = 140
            };
            World.IgnoreDialogs(chatTextBox);
            chatTextBox.OnEnterPressed += _doTalk;
            chatTextBox.OnClicked      += (s, e) =>
            {
                //make sure clicking on the textarea selects it (this is an annoying problem in the original client)
                if (((EOGame)g).Dispatcher.Subscriber != null)
                {
                    ((XNATextBox)(g as EOGame).Dispatcher.Subscriber).Selected = false;
                }

                (g as EOGame).Dispatcher.Subscriber = chatTextBox;
                chatTextBox.Selected = true;
            };
            chatTextBox.OnTextChanged += (s, e) =>
            {
                if (chatTextBox.Text.Length <= 0)
                {
                    if (modeTextureLoaded && modeTexture != null)
                    {
                        modeTextureLoaded = false;
                        modeTexture.Dispose();
                        modeTexture = null;

                        currentChatMode = ChatMode.NoText;
                    }
                    return;
                }

                if (chatTextBox.Text.Length == 1 && chatTextBox.Text[0] == '~' &&
                    World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap)
                {
                    chatTextBox.Text = "";
                    SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.JAIL_WARNING_CANNOT_USE_GLOBAL);
                    return;
                }

                switch (chatTextBox.Text[0])
                {
                case '!': currentChatMode = ChatMode.Private; break;

                case '@':                         //should show global if admin, otherwise, public/normal chat
                    if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                    {
                        goto default;
                    }
                    currentChatMode = ChatMode.Global;
                    break;

                case '~': currentChatMode = ChatMode.Global; break;

                case '+':
                {
                    if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                    {
                        goto default;
                    }
                    currentChatMode = ChatMode.Admin;
                }
                break;

                case '\'': currentChatMode = ChatMode.Group; break;

                case '&':
                {
                    if (World.Instance.MainPlayer.ActiveCharacter.GuildName == "")
                    {
                        goto default;
                    }
                    currentChatMode = ChatMode.Guild;
                }
                break;

                default: currentChatMode = ChatMode.Public; break;
                }
            };

            ((EOGame)g).Dispatcher.Subscriber = chatTextBox;

            m_muteTimer = new Timer(s =>
            {
                chatTextBox.IgnoreAllInput = false;
                currentChatMode            = ChatMode.NoText;
                m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite);
            }, null, Timeout.Infinite, Timeout.Infinite);

            statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), "Microsoft Sans Serif", 7f);
            clockLabel  = new XNALabel(new Rectangle(558, 455, 1, 1), "Microsoft Sans Serif", 7f);

            StatusBars[0] = new HudElementHP();
            StatusBars[1] = new HudElementTP();
            StatusBars[2] = new HudElementSP();
            StatusBars[3] = new HudElementTNL();

            m_whoIsOnline = new EOOnlineList(pnlOnline);
            m_party       = new EOPartyPanel(pnlParty);

            m_friendList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
                                         new Vector2(592, 312),
                                         new Rectangle(0, 260, 17, 15),
                                         new Rectangle(0, 276, 17, 15))
            {
                Visible = true,
                Enabled = true
            };
            m_friendList.OnClick     += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, false);
            m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST);

            m_ignoreList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
                                         new Vector2(609, 312),
                                         new Rectangle(17, 260, 17, 15),
                                         new Rectangle(17, 276, 17, 15))
            {
                Visible = true,
                Enabled = true
            };
            m_ignoreList.OnClick     += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, true);
            m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST);

            m_expInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58),
                                      new Vector2(55, 0),
                                      new Rectangle(331, 30, 22, 14),
                                      new Rectangle(331, 30, 22, 14));
            m_expInfo.OnClick += (o, e) => EOSessionExpDialog.Show();
            m_questInfo        = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58),
                                               new Vector2(77, 0),
                                               new Rectangle(353, 30, 22, 14),
                                               new Rectangle(353, 30, 22, 14));

            //no need to make this a member variable
            //it does not have any resources to dispose and it is automatically disposed by the framework
// ReSharper disable once UnusedVariable
            EOSettingsPanel settings = new EOSettingsPanel(pnlSettings);
        }
Esempio n. 9
0
        private void _doStateChange(InGameStates newGameState)
        {
            state = newGameState;

            pnlNews.Visible = false;

            pnlInventory.Visible     = false;
            pnlActiveSpells.Visible  = false;
            pnlPassiveSpells.Visible = false;
            pnlChat.Visible          = false;
            pnlStats.Visible         = false;

            pnlOnline.Visible   = false;
            pnlParty.Visible    = false;
            pnlSettings.Visible = false;
            pnlHelp.Visible     = false;

            switch (state)
            {
            case InGameStates.Inventory:
                pnlInventory.Visible = true;
                break;

            case InGameStates.Active:
                pnlActiveSpells.Visible = true;
                break;

            case InGameStates.Passive:
                pnlPassiveSpells.Visible = true;
                break;

            case InGameStates.Chat:
                pnlChat.Visible = true;
                SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_CHAT_PANEL_NOW_VIEWED);
                break;

            case InGameStates.Stats:
                stats.Refresh();
                pnlStats.Visible = true;
                SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_STATS_PANEL_NOW_VIEWED);
                break;

            case InGameStates.Online:
                List <OnlineEntry> onlineList;
                if (!m_packetAPI.RequestOnlinePlayers(true, out onlineList))
                {
                    EOGame.Instance.LostConnectionDialog();
                }
                m_whoIsOnline.SetOnlinePlayerList(onlineList);
                pnlOnline.Visible = true;
                SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_ONLINE_PLAYERS_NOW_VIEWED);
                break;

            case InGameStates.Party:
                pnlParty.Visible = true;
                break;

            case InGameStates.Settings:
                pnlSettings.Visible = true;
                break;

            case InGameStates.Help:
                pnlHelp.Visible = true;
                SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_HUD_BUTTON_HOVER_LAST);
                break;
            }
        }
Esempio n. 10
0
    /// <summary>
    /// Changes the current game state to the passed in game state.
    /// Uses the AdditiveSceneManager to Load/Unload scenes.
    /// </summary>
    /// <param name="state">The InGameStates state to transition to</param>
    public void ChangeInGameState(InGameStates state)
    {
        // Checks if the passed in state is the same as the current state.
        if (state == currentGameState)
        {
            return;
        }
        // Otherwise it sets the current state to the passed state.
        currentGameState = state;
        // Handles what scenes to Load/Unload using the AdditiveSceneManager, along with additional scene cleanup.
        switch (state)
        {
        case InGameStates.GameIntro:
            additiveSceneManager.LoadSceneSeperate("Event_NoChoices");
            additiveSceneManager.LoadSceneSeperate("Game_Intro");
            break;

        case InGameStates.JobSelect:     // Loads Jobpicker for the player to pick their job
            // unload game intro
            additiveSceneManager.UnloadScene("Event_NoChoices");
            additiveSceneManager.UnloadScene("Game_Intro");

            // unload normal
            additiveSceneManager.UnloadScene("Interface_Runtime");
            additiveSceneManager.UnloadScene("Interface_GameOver");
            additiveSceneManager.UnloadScene("Interface_CrewPaymentScreen");
            additiveSceneManager.UnloadScene("Interface_RoomUnlockScreen");

            // save game stuffs (moved from crew payment)
            SaveGameState();
            ship.SaveShipStats();
            MoraleManager.instance.SaveMorale();
            ship.cStats.SaveCharacterStats();
            SavingLoadingManager.instance.SaveRooms();

            additiveSceneManager.LoadSceneSeperate("Interface_JobList");
            additiveSceneManager.LoadSceneSeperate("Starport BG");
            jobManager.RefreshJobList();
            break;

        case InGameStates.ShipBuilding:     // Loads ShipBuilding for the player to edit their ship
            additiveSceneManager.UnloadScene("Interface_JobList");
            additiveSceneManager.UnloadScene("Interface_Runtime");
            additiveSceneManager.UnloadScene("Interface_GameOver");

            additiveSceneManager.LoadSceneSeperate("Starport BG");
            additiveSceneManager.LoadSceneSeperate("ShipBuilding");
            additiveSceneManager.LoadSceneSeperate("CrewManagement");
            SaveGameState();
            break;

        case InGameStates.Events:     // Unloads ShipBuilding and starts the Travel coroutine for the event system.
            additiveSceneManager.UnloadScene("Starport BG");
            additiveSceneManager.UnloadScene("ShipBuilding");
            additiveSceneManager.UnloadScene("CrewManagement");
            additiveSceneManager.UnloadScene("Interface_GameOver");

            // if loading from continue
            if (!FindObjectOfType <SpotChecker>())
            {
                StartCoroutine(LoadSpotCheckerInShipBuilding());
            }
            else     // if coming from crew management
            {
                SaveGameState();
                MoraleManager.instance.SaveMorale();
                ship.cStats.SaveCharacterStats();
                ship.SaveShipStats();
                SavingLoadingManager.instance.SaveRooms();
            }

            additiveSceneManager.LoadSceneSeperate("Interface_Runtime");

            StartCoroutine(EventSystem.instance.PlayJobIntro());
            break;

        case InGameStates.Mutiny:    // Loads the when the player reaches a mutiny.
        case InGameStates.Death:     // Loads the when the player reaches a death.
            additiveSceneManager.UnloadScene("Event_General");
            additiveSceneManager.UnloadScene("Event_CharacterFocused");
            additiveSceneManager.UnloadScene("Interface_Runtime");

            additiveSceneManager.LoadSceneSeperate("Interface_GameOver");
            break;

        case InGameStates.JobPayment:
            additiveSceneManager.UnloadScene("Event_General");
            additiveSceneManager.UnloadScene("Event_CharacterFocused");
            additiveSceneManager.UnloadScene("Interface_Runtime");

            additiveSceneManager.LoadSceneSeperate("Interface_JobPaycheckScreen");
            break;

        case InGameStates.CrewPayment:
            additiveSceneManager.UnloadScene("Interface_JobPaycheckScreen");

            additiveSceneManager.LoadSceneSeperate("Interface_CrewPaymentScreen");
            break;

        case InGameStates.RoomUnlock:
            additiveSceneManager.UnloadScene("Interface_CrewPaymentScreen");

            additiveSceneManager.LoadSceneSeperate("Interface_RoomUnlockScreen");
            break;

        case InGameStates.MoneyEnding:     // Loads the PromptScreen_Money_End when the player reaches a narrative ending.
            additiveSceneManager.UnloadScene("Interface_CrewPaymentScreen");
            additiveSceneManager.UnloadScene("Interface_RoomUnlockScreen");

            additiveSceneManager.LoadSceneSeperate("Event_NoChoices");
            additiveSceneManager.LoadSceneSeperate("PromptScreen_Money_End");
            break;

        case InGameStates.MoraleEnding:     // Loads the PromptScreen_Morale_End after the PromptScreen_Money_End.
            additiveSceneManager.UnloadScene("PromptScreen_Money_End");

            additiveSceneManager.LoadSceneSeperate("PromptScreen_Morale_End");
            break;

        case InGameStates.EndingStats:     // Keeping only to not have errors, load into ending credits instead
        case InGameStates.EndingCredits:   // Loads the Credits after the Interface_EndScreen_Stats.
            additiveSceneManager.UnloadScene("Event_NoChoices");
            additiveSceneManager.UnloadScene("PromptScreen_Morale_End");

            additiveSceneManager.LoadSceneSeperate("Credits");
            break;

        default:     // Output Warning when the passed in game state doesn't have a transition setup.
            Debug.LogWarning($"The passed in game state, {state.ToString()}, doesn't have a transition setup.");
            break;
        }
    }
Esempio n. 11
0
        public HUD(Game g, PacketAPI api)
            : base(g)
        {
            if(!api.Initialized)
                throw new ArgumentException("Need to initialize connection before the in-game stuff will work");
            m_packetAPI = api;

            DrawOrder = 5;

            mainFrame = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 1, true);
            topLeft = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 21, true);
            sidebar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 22, true);
            topBar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 23, true);
            filler = new Texture2D(g.GraphicsDevice, 1, 1);
            filler.SetData(new[] {Color.FromNonPremultiplied(8, 8, 8, 255)});

            Texture2D mainButtonTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 25);
            mainBtn = new XNAButton[NUM_BTN];

            //set up panels
            Texture2D invBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 44);
            pnlInventory = new XNAPanel(new Rectangle(102, 330, invBG.Width, invBG.Height))
            {
                BackgroundImage = invBG,
                Visible = false
            };

            Texture2D spellsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 62);
            pnlActiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height))
            {
                BackgroundImage = spellsBG,
                Visible = false
            };

            pnlPassiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height))
            {
                BackgroundImage = spellsBG,
                Visible = false
            };

            Texture2D chatBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 28);
            pnlChat = new XNAPanel(new Rectangle(102, 330, chatBG.Width, chatBG.Height))
            {
                BackgroundImage = chatBG,
                Visible = false
            };

            Texture2D statsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 34);
            pnlStats = new XNAPanel(new Rectangle(102, 330, statsBG.Width, statsBG.Height))
            {
                BackgroundImage = statsBG,
                Visible = false
            };

            Texture2D onlineBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 36);
            pnlOnline = new XNAPanel(new Rectangle(102, 330, onlineBG.Width, onlineBG.Height))
            {
                BackgroundImage = onlineBG,
                Visible = false
            };

            Texture2D partyBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 42);
            pnlParty = new XNAPanel(new Rectangle(102, 330, partyBG.Width, partyBG.Height))
            {
                BackgroundImage = partyBG,
                Visible = false
            };

            Texture2D settingsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 47);
            pnlSettings = new XNAPanel(new Rectangle(102, 330, settingsBG.Width, settingsBG.Height))
            {
                BackgroundImage = settingsBG,
                Visible = false
            };

            Texture2D helpBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 63);
            pnlHelp = new XNAPanel(new Rectangle(102, 330, helpBG.Width, helpBG.Height))
            {
                BackgroundImage = helpBG,
                Visible = false
            };

            Texture2D newsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 48);
            pnlNews = new XNAPanel(new Rectangle(102, 330, newsBG.Width, newsBG.Height)) {BackgroundImage = newsBG};

            //for easy update of all panels via foreach
            List<XNAPanel> pnlCollection = new List<XNAPanel>(10)
            {
                pnlInventory,
                pnlActiveSpells,
                pnlPassiveSpells,
                pnlChat,
                pnlStats,
                pnlOnline,
                pnlParty,
                pnlSettings,
                pnlHelp,
                pnlNews
            };
            //pnlCollection.Add(pnlMacro); //if this ever happens...

            pnlCollection.ForEach(_pnl => World.IgnoreDialogs(_pnl));

            for (int i = 0; i < NUM_BTN; ++i)
            {
                Texture2D _out = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN);
                Texture2D _ovr = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN);

                Rectangle _outRec = new Rectangle(0, i * _out.Height, _out.Width, _out.Height);
                Rectangle _ovrRec = new Rectangle(_ovr.Width, i * _ovr.Height, _ovr.Width, _ovr.Height);

                Color[] _outBuf = new Color[_outRec.Width * _outRec.Height];
                Color[] _ovrBuf = new Color[_ovrRec.Width * _ovrRec.Height];

                mainButtonTexture.GetData(0, _outRec, _outBuf, 0, _outBuf.Length);
                _out.SetData(_outBuf);

                mainButtonTexture.GetData(0, _ovrRec, _ovrBuf, 0, _ovrBuf.Length);
                _ovr.SetData(_ovrBuf);

                //0-5: left side, starting at 59, 327 with increments of 20
                //6-10: right side, starting at 587, 347
                Vector2 btnLoc = new Vector2(i < 6 ? 62 : 590, (i < 6 ? 330 : 350) + ((i < 6 ? i : i - 6) * 20));

                mainBtn[i] = new XNAButton(new [] { _out, _ovr }, btnLoc);
                World.IgnoreDialogs(mainBtn[i]);
            }

            //left button onclick events
            mainBtn[0].OnClick += (s,e) => _doStateChange(InGameStates.Inventory);
            mainBtn[1].OnClick += (s,e) => World.Instance.ActiveMapRenderer.ToggleMapView();
            mainBtn[2].OnClick += (s,e) => _doStateChange(InGameStates.Active);
            mainBtn[3].OnClick += (s, e) => _doStateChange(InGameStates.Passive);
            mainBtn[4].OnClick += (s, e) => _doStateChange(InGameStates.Chat);
            mainBtn[5].OnClick += (s, e) => _doStateChange(InGameStates.Stats);

            //right button onclick events
            mainBtn[6].OnClick += (s, e) => _doStateChange(InGameStates.Online);
            mainBtn[7].OnClick += (s, e) => _doStateChange(InGameStates.Party);
            //mainBtn[8].OnClick += OnViewMacro; //not implemented in EO client
            mainBtn[9].OnClick += (s, e) => _doStateChange(InGameStates.Settings);
            mainBtn[10].OnClick += (s, e) => _doStateChange(InGameStates.Help);

            SpriteBatch = new SpriteBatch(g.GraphicsDevice);

            state = InGameStates.News;

            chatRenderer = new EOChatRenderer();
            chatRenderer.SetParent(pnlChat);
            chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
                World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1),
                ChatType.Note, ChatColor.Server);
            chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
                World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2),
                ChatType.Note, ChatColor.Server);

            newsTab = new ChatTab(pnlNews);

            chatTextBox = new ChatTextBox(new Rectangle(124, 308, 440, 19), g.Content.Load<Texture2D>("cursor"), "Microsoft Sans Serif", 8.0f)
            {
                Selected = true,
                Visible = true,
                MaxChars = 140
            };
            World.IgnoreDialogs(chatTextBox);
            chatTextBox.OnEnterPressed += _doTalk;
            chatTextBox.OnClicked += (s, e) =>
            {
                //make sure clicking on the textarea selects it (this is an annoying problem in the original client)
                if (((EOGame)g).Dispatcher.Subscriber != null)
                    ((XNATextBox) (g as EOGame).Dispatcher.Subscriber).Selected = false;

                (g as EOGame).Dispatcher.Subscriber = chatTextBox;
                chatTextBox.Selected = true;
            };
            chatTextBox.OnTextChanged += (s, e) =>
            {
                if (chatTextBox.Text.Length <= 0)
                {
                    if (modeTextureLoaded && modeTexture != null)
                    {
                        modeTextureLoaded = false;
                        modeTexture.Dispose();
                        modeTexture = null;

                        currentChatMode = ChatMode.NoText;
                    }
                    return;
                }

                if (chatTextBox.Text.Length == 1 && chatTextBox.Text[0] == '~' &&
                    World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap)
                {
                    chatTextBox.Text = "";
                    SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.JAIL_WARNING_CANNOT_USE_GLOBAL);
                    return;
                }

                switch (chatTextBox.Text[0])
                {
                    case '!': currentChatMode = ChatMode.Private; break;
                    case '@': //should show global if admin, otherwise, public/normal chat
                        if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                            goto default;
                        currentChatMode = ChatMode.Global;
                        break;
                    case '~': currentChatMode = ChatMode.Global; break;
                    case '+':
                    {
                        if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                            goto default;
                        currentChatMode = ChatMode.Admin;
                    }
                        break;
                    case '\'': currentChatMode = ChatMode.Group; break;
                    case '&':
                    {
                        if (World.Instance.MainPlayer.ActiveCharacter.GuildName == "")
                            goto default;
                        currentChatMode = ChatMode.Guild;
                    }
                        break;
                    default: currentChatMode = ChatMode.Public; break;
                }
            };

            ((EOGame)g).Dispatcher.Subscriber = chatTextBox;

            m_muteTimer = new Timer(s =>
            {
                chatTextBox.IgnoreAllInput = false;
                currentChatMode = ChatMode.NoText;
                m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite);
            }, null, Timeout.Infinite, Timeout.Infinite);

            statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), "Microsoft Sans Serif", 7f);
            clockLabel = new XNALabel(new Rectangle(558, 455, 1, 1), "Microsoft Sans Serif", 7f);

            StatusBars[0] = new HudElementHP();
            StatusBars[1] = new HudElementTP();
            StatusBars[2] = new HudElementSP();
            StatusBars[3] = new HudElementTNL();

            m_whoIsOnline = new EOOnlineList(pnlOnline);
            m_party = new EOPartyPanel(pnlParty);

            m_friendList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
                new Vector2(592, 312),
                new Rectangle(0, 260, 17, 15),
                new Rectangle(0, 276, 17, 15))
            {
                Visible = true,
                Enabled = true
            };
            m_friendList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, false);
            m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST);

            m_ignoreList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
                new Vector2(609, 312),
                new Rectangle(17, 260, 17, 15),
                new Rectangle(17, 276, 17, 15))
            {
                Visible = true,
                Enabled = true
            };
            m_ignoreList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, true);
            m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST);

            m_expInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58),
                new Vector2(55, 0),
                new Rectangle(331, 30, 22, 14),
                new Rectangle(331, 30, 22, 14));
            m_expInfo.OnClick += (o, e) => EOSessionExpDialog.Show();
            m_questInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58),
                new Vector2(77, 0),
                new Rectangle(353, 30, 22, 14),
                new Rectangle(353, 30, 22, 14));

            //no need to make this a member variable
            //it does not have any resources to dispose and it is automatically disposed by the framework
            // ReSharper disable once UnusedVariable
            EOSettingsPanel settings = new EOSettingsPanel(pnlSettings);
        }
Esempio n. 12
0
        private void _doStateChange(InGameStates newGameState)
        {
            state = newGameState;

            pnlNews.Visible = false;

            pnlInventory.Visible = false;
            pnlActiveSpells.Visible = false;
            pnlPassiveSpells.Visible = false;
            pnlChat.Visible = false;
            pnlStats.Visible = false;

            pnlOnline.Visible = false;
            pnlParty.Visible = false;
            pnlSettings.Visible = false;
            pnlHelp.Visible = false;

            switch(state)
            {
                case InGameStates.Inventory:
                    pnlInventory.Visible = true;
                    break;
                case InGameStates.Active:
                    pnlActiveSpells.Visible = true;
                    break;
                case InGameStates.Passive:
                    pnlPassiveSpells.Visible = true;
                    break;
                case InGameStates.Chat:
                    pnlChat.Visible = true;
                    SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_CHAT_PANEL_NOW_VIEWED);
                    break;
                case InGameStates.Stats:
                    stats.Refresh();
                    pnlStats.Visible = true;
                    SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_STATS_PANEL_NOW_VIEWED);
                    break;
                case InGameStates.Online:
                    List<OnlineEntry> onlineList;
                    if (!m_packetAPI.RequestOnlinePlayers(true, out onlineList))
                        EOGame.Instance.LostConnectionDialog();
                    m_whoIsOnline.SetOnlinePlayerList(onlineList);
                    pnlOnline.Visible = true;
                    SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_ONLINE_PLAYERS_NOW_VIEWED);
                    break;
                case InGameStates.Party:
                    pnlParty.Visible = true;
                    break;
                case InGameStates.Settings:
                    pnlSettings.Visible = true;
                    break;
                case InGameStates.Help:
                    pnlHelp.Visible = true;
                    SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_HUD_BUTTON_HOVER_LAST);
                    break;
            }
        }
Esempio n. 13
0
		public HUD(Game g, PacketAPI api) : base(g)
		{
			if(!api.Initialized)
				throw new ArgumentException("Need to initialize connection before the in-game stuff will work");
			m_packetAPI = api;

			DrawOrder = 100;

			mainFrame = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 1, true);
			topLeft = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 21, true);
			sidebar = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 22, true);
			topBar = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 23, true);
			filler = new Texture2D(g.GraphicsDevice, 1, 1);
			filler.SetData(new[] {Color.FromNonPremultiplied(8, 8, 8, 255)});

			Texture2D mainButtonTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 25);
			mainBtn = new XNAButton[NUM_BTN];

			CreatePanels();
			CreateMainButtons(g, mainButtonTexture);

			SpriteBatch = new SpriteBatch(g.GraphicsDevice);

			state = InGameStates.News;

			chatRenderer = new EOChatRenderer();
			chatRenderer.SetParent(pnlChat);
			chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
				World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1),
				ChatType.Note, ChatColor.Server);
			chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
				World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2),
				ChatType.Note, ChatColor.Server);

			newsTab = new ChatTab(pnlNews);

			CreateChatTextbox();

			m_muteTimer = new Timer(s =>
			{
				chatTextBox.ToggleTextInputIgnore();
				currentChatMode = ChatMode.NoText;
				m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite);
			}, null, Timeout.Infinite, Timeout.Infinite);

			statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), Constants.FontSize07) { DrawOrder = HUD_CONTROL_DRAW_ORDER };
			clockLabel = new XNALabel(new Rectangle(558, 455, 1, 1), Constants.FontSize07) { DrawOrder = HUD_CONTROL_DRAW_ORDER };

			m_whoIsOnline = new EOOnlineList(pnlOnline);
			m_party = new EOPartyPanel(pnlParty);

			m_friendList = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
				new Vector2(592, 312),
				new Rectangle(0, 260, 17, 15),
				new Rectangle(0, 276, 17, 15))
			{
				Visible = true,
				Enabled = true,
				DrawOrder = HUD_CONTROL_DRAW_ORDER
			};
			m_friendList.OnClick += (o, e) => FriendIgnoreListDialog.Show(isIgnoreList: false, apiHandle: m_packetAPI);
			m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST);

			m_ignoreList = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
				new Vector2(609, 312),
				new Rectangle(17, 260, 17, 15),
				new Rectangle(17, 276, 17, 15))
			{
				Visible = true,
				Enabled = true,
				DrawOrder = HUD_CONTROL_DRAW_ORDER
			};
			m_ignoreList.OnClick += (o, e) => FriendIgnoreListDialog.Show(isIgnoreList: true, apiHandle: m_packetAPI);
			m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST);

			m_expInfo = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58),
				new Vector2(55, 0),
				new Rectangle(331, 30, 22, 14),
				new Rectangle(331, 30, 22, 14)) {DrawOrder = HUD_CONTROL_DRAW_ORDER};
			m_expInfo.OnClick += (o, e) => SessionExpDialog.Show();
			m_questInfo = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58),
				new Vector2(77, 0),
				new Rectangle(353, 30, 22, 14),
				new Rectangle(353, 30, 22, 14)) {DrawOrder = HUD_CONTROL_DRAW_ORDER};
			m_questInfo.OnClick += (o, e) => QuestProgressDialog.Show(m_packetAPI);

			//no need to make this a member variable
			//it does not have any resources to dispose and it is automatically disposed by the framework
			// ReSharper disable once UnusedVariable
			EOSettingsPanel settings = new EOSettingsPanel(pnlSettings);
		}