private void InitalizeInterface() { var loadingIndicatorTexture2D = this.ContentManager.LoadTexture2D(Constants.FILEPATH_GFX + "Interface/loadingIndicator.png"); var loadingFont = this.ContentManager.Load <SpriteFont>(Constants.FILEPATH_GFX + "Fonts/loadingFont"); var picLoadingIndicator = new AnimatedPicture(loadingIndicatorTexture2D, 25, new Vector2(loadingIndicatorTexture2D.Width, loadingIndicatorTexture2D.Height)) { Position = new Vector2(Settings.ResolutionX / 2f, (Settings.ResolutionY / 2f) - 100), Visible = true, FrameRotation = 1f, ZOrder = 1 }; this.GuiManager.AddWidget(picLoadingIndicator, "picLoadingIndicator"); var lblLoading = new Label(loadingFont) { Text = $"Loading {Settings.GameName} ...", Visible = true, ZOrder = 1 }; lblLoading.Position = new Vector2(Settings.ResolutionX / 2f - (loadingFont.MeasureString(lblLoading.Text).X / 2f), picLoadingIndicator.Position.Y + 200 + (loadingFont.MeasureString(lblLoading.Text).Y)); this.GuiManager.AddWidget(lblLoading, "lblLoading"); }
private void _worldManager_EventOccured(object sender, Core.Utilities.SubjectEventArgs e) { if (e.EventName == "playerUpdated") { Player player = (Player)e.Args[0]; if ((Player)e.Args[0] == ((WorldManager)sender).Player) { this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Value = (player.Health / player.MaximumHealth) * 100; this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Text = $"HP {player.Health}/{player.MaximumHealth}"; this.GuiManager.GetWidget <StatusBar>("healthStatusBar").TextOffset = new Vector2(this.GuiManager.GetWidget <StatusBar>("healthStatusBar").FillSprite.Width - this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Font.MeasureString(this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Text).X, this.GuiManager.GetWidget <StatusBar>("healthStatusBar").FillSprite.Height / 2f); this.GuiManager.GetWidget <StatusBar>("experienceBar").Value = (player.Experience / player.NextLevelExperience) * 100; this.GuiManager.GetWidget <Label>("lblExperience").Text = $"{player.Experience}/{player.NextLevelExperience}"; var characterWindow = this.GuiManager.GetWidget <WidgetContainer>("characterWindow"); characterWindow.GetWidget <Label>("charWindowNameLabel").Text = player.Name; characterWindow.GetWidget <Label>("charHealthLabel").Text = "Health: " + player.Health + "/" + player.MaximumHealth; characterWindow.GetWidget <Label>("charStrengthLabel").Text = "Strength: " + player.Strength; characterWindow.GetWidget <Label>("charIntLabel").Text = "Intelligence: " + player.Intelligence; characterWindow.GetWidget <Label>("charDexLabel").Text = "Dexterity: " + player.Dexterity; characterWindow.GetWidget <Label>("charDefLabel").Text = "Defence: " + player.Strength; characterWindow.GetWidget <Label>("charLevelLabel").Text = "Level: " + player.Level; if (!characterWindow.WidgetExists("characterPicture")) { AnimatedPicture characterPicture = new AnimatedPicture(player.SpriteSheet.Sprite.Texture, (int)((72 / player.Speed) / (player.SpriteSheet.Sprite.Texture.Width / 52f)), new Vector2(player.SpriteSheet.FrameSize.X, player.SpriteSheet.FrameSize.Y)) { Position = new Vector2(characterWindow.Position.X + 210, characterWindow.Position.Y + 150), Visible = true }; characterWindow.AddWidget(characterPicture, "characterPicture"); } else { characterWindow.GetWidget <AnimatedPicture>("characterPicture").Sprite = player.SpriteSheet.Sprite.Texture; characterWindow.GetWidget <AnimatedPicture>("characterPicture").FrameTime = (int)((72 / player.Speed) / (player.SpriteSheet.Sprite.Texture.Width / 52f)); } } } else if (e.EventName == "loadingMap") { _loadingScreen = true; Client.ServiceLocator.GetService <SceneManager>().SetActiveScene("loadingScene"); } else if (e.EventName == "finishedLoadingMap") { Client.ServiceLocator.GetService <SceneManager>().GetScene <LoadingScene>("loadingScene").OnFinishedLoading(); } }
private void Player_StatsChanged(object sender, EventArgs e) { var player = (Player)sender; this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Value = ((float)player.Health / player.MaximumHealth) * 100; this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Text = $"HP {player.Health}/{player.MaximumHealth}"; this.GuiManager.GetWidget <StatusBar>("healthStatusBar").TextOffset = new Vector2(this.GuiManager.GetWidget <StatusBar>("healthStatusBar").FillSprite.Width - this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Font.MeasureString(this.GuiManager.GetWidget <StatusBar>("healthStatusBar").Text).X, this.GuiManager.GetWidget <StatusBar>("healthStatusBar").FillSprite.Height / 2f); this.GuiManager.GetWidget <StatusBar>("experienceBar").Value = (player.Experience / player.NextLevelExperience) * 100; this.GuiManager.GetWidget <Label>("lblExperience").Text = $"{this.GuiManager.GetWidget<StatusBar>("experienceBar").Value:P2}"; var characterWindow = this.GuiManager.GetWidget <WidgetContainer>("characterWindow"); characterWindow.GetWidget <Label>("charWindowNameLabel").Text = player.Name; characterWindow.GetWidget <Label>("charHealthLabel").Text = "Health: " + player.Health + "/" + player.MaximumHealth; characterWindow.GetWidget <Label>("charStrengthLabel").Text = "Strength: " + player.Strength; characterWindow.GetWidget <Label>("charIntLabel").Text = "Intelligence: " + player.Intelligence; characterWindow.GetWidget <Label>("charDexLabel").Text = "Dexterity: " + player.Dexterity; characterWindow.GetWidget <Label>("charDefLabel").Text = "Defence: " + player.Strength; characterWindow.GetWidget <Label>("charLevelLabel").Text = "Level: " + player.Level; if (!characterWindow.WidgetExists("characterPicture")) { AnimatedPicture characterPicture = new AnimatedPicture(player.SpriteSheet.Sprite.Texture, (int)((72 / player.Speed) / (player.SpriteSheet.Sprite.Texture.Width / 52f)), new Vector2(player.SpriteSheet.FrameSize.X, player.SpriteSheet.FrameSize.Y)) { Position = new Vector2(characterWindow.Position.X + 210, characterWindow.Position.Y + 150), Visible = true }; characterWindow.AddWidget(characterPicture, "characterPicture"); } else { characterWindow.GetWidget <AnimatedPicture>("characterPicture").Sprite = player.SpriteSheet.Sprite.Texture; characterWindow.GetWidget <AnimatedPicture>("characterPicture").FrameTime = (int)((72 / player.Speed) / (player.SpriteSheet.Sprite.Texture.Width / 52f)); } }