Пример #1
0
        public void CleanupGUI(Dictionary <string, object> guiState)
        {
            PlayingGUI gui = GameWorld.Find("PlayingGui") as PlayingGUI;

            gui.Remove(gui.Find("playerName" + guid.ToString()));
            if (Id == LocalPlayerName && GameWorld != null)
            {
                PlayerInventoryAndEquipment pIaE = gui.Inventory;
                StatScreen pSs = gui.CharacterScreen;

                guiState.Add("playerIaEVisibility", pIaE.Visible);
                guiState.Add("playerIaEPosition", pIaE.Position);
                guiState.Add("playerSsVisibility", pSs.Visible);
                guiState.Add("playerSsPosition", pSs.Position);

                SkillBar skillbar = gui.Find(obj => obj is SkillBar) as SkillBar;
                guiState.Add("skillBarVisibility", skillbar.Visible);
                guiState.Add("skillbarPosition", skillbar.Position);

                gui.RemoveImmediatly(gui.Find("HealthBar"));
                gui.RemoveImmediatly(gui.Find("ManaBar"));
                gui.RemoveImmediatly(gui.Find("ActionBar"));
                gui.RemoveImmediatly(gui.Find("ExpBar"));
                gui.RemoveImmediatly(pIaE);
                gui.RemoveImmediatly(pSs);
                gui.RemoveImmediatly(mouseSlot);
                gui.RemoveImmediatly(skillbar);
            }
        }
Пример #2
0
        public void InitGUI(Dictionary <string, object> guiState)
        {
            PlayingGUI gui = GameWorld.Find("PlayingGui") as PlayingGUI;

            PlayerNameTitle();
            gui.Add(playerNameTitle);
            int screenWidth  = GameEnvironment.Screen.X;
            int screenHeight = GameEnvironment.Screen.Y;

            if (Id == LocalPlayerName)
            {
                SpriteFont textfieldFont = GameEnvironment.AssetManager.GetFont("Arial26");
                const int  barX          = 150;
                const int  barY          = 10;

                //Healthbar
                Bar <Player> hpBar = new Bar <Player>(this, p => p.Health, p => p.MaxHealth, textfieldFont, Color.Red, "HP", 2, "HealthBar", 0, 2.5f);
                hpBar.Position = new Vector2(barX, barY);
                gui.Add(hpBar);
                //Manabar
                Bar <Player> mpBar = new Bar <Player>(this, p => p.Mana, p => p.MaxMana, textfieldFont, Color.Blue, "MP", 2, "ManaBar", 0, 2.5f);
                mpBar.Position = hpBar.Position + new Vector2(0, hpBar.Height + barY);
                gui.Add(mpBar);

                //Action Points
                Bar <Player> apBar = new Bar <Player>(this, p => p.ActionPoints, p => MaxActionPoints, textfieldFont, Color.GreenYellow, "AP", 2, "ActionBar", 0, 2.5f);
                apBar.Position = new Vector2(GameEnvironment.Screen.X - barX * 3, barY);
                gui.Add(apBar);

                //exp Points
                Bar <Player> expBar = new Bar <Player>(this, p => p.exp, p => p.RequiredExperience(), textfieldFont, Color.Gold, "XP", 2, "ExpBar", 0, 2.5f);
                expBar.Position = apBar.Position + new Vector2(0, apBar.Height + barY);
                gui.Add(expBar);

                PlayerInventoryAndEquipment pie = new PlayerInventoryAndEquipment(Inventory, EquipmentSlots);
                pie.Position = guiState.ContainsKey("playerIaEPosition") ? (Vector2)guiState["playerIaEPosition"] : new Vector2(screenWidth - pie.Width, 300);
                pie.Visible  = guiState.ContainsKey("playerIaEVisibility") ? (bool)guiState["playerIaEVisibility"] : false;
                gui.Add(pie);

                StatScreen ss = new StatScreen(this);
                ss.Position = guiState.ContainsKey("playerSsPosition") ? (Vector2)guiState["playerSsPosition"] : new Vector2(0, 300);
                ss.Visible  = guiState.ContainsKey("playerSsVisibility") ? (bool)guiState["playerSsVisibility"] : false;
                gui.Add(ss);

                SkillBar skillBar = new SkillBar(SkillList);
                skillBar.Position = guiState.ContainsKey("skillbarPosition") ? (Vector2)guiState["skillbarPosition"] : new Vector2((screenWidth - skillBar.Width) / 2, (gui.Find("TopBar") as SpriteGameObject).Sprite.Height);
                skillBar.Visible  = guiState.ContainsKey("skillBarVisibility") ? (bool)guiState["skillBarVisibility"] : true;
                gui.Add(skillBar);

                InitMouseSlot();
            }
        }