private void Debug_ShowWaypointsUpdate() { Debug_Waypoints.Clear(); Vector2f lastPos = Obj.Position; for (int i = 0; i < WaypointPath.Count; i++) { CircleShape wp = new CircleShape(4); wp.Origin = new Vector2f(4, 4); wp.FillColor = new Color(255, 0, 0, 200); wp.Position = WaypointPath[i]; Debug_Waypoints.AddChild(wp); VertexArray line = new VertexArray(PrimitiveType.Lines, 2); line[0] = new Vertex(lastPos, new Color(255, 0, 0, 140)); line[1] = new Vertex(WaypointPath[i], new Color(255, 0, 0, 140)); Debug_Waypoints.AddChild(line); lastPos = WaypointPath[i]; } }
// Health public void SetHealth(uint health) { if (health > HealthPoints.Count) { for (int i = HealthPoints.Count; i < health; i++) { DisplayObject bar = new DisplayObject(); int barWidth = 1; if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL) { Sprite bar_sprite = Graphics.GetSprite("assets/sprites/gui/hp.png"); bar_sprite.Color = new Color(255, 255, 255, 200); barWidth = bar_sprite.TextureRect.Width; bar.AddChild(bar_sprite); } else { RectangleShape bar_rectangle = new RectangleShape(new Vector2f(28, 60)); bar_rectangle.FillColor = new Color(255, 255, 255, 50); bar_rectangle.OutlineColor = new Color(255, 255, 255, 180); bar_rectangle.OutlineThickness = 1; barWidth = (int)bar_rectangle.Size.X + 4; bar.AddChild(bar_rectangle); } bar.Position = new Vector2f(HEALTH_START.X + ((barWidth + 2) * i), HEALTH_START.Y); AddChild(bar); HealthPoints.Add(bar); } } else if (health < HealthPoints.Count) { for (int i = HealthPoints.Count - 1; i >= health; i--) { HealthPoints[i].Parent.RemoveChild(HealthPoints[i]); HealthPoints.RemoveAt(i); } } }
protected override void SetupButtonAdditional(int i, DisplayObject button, RectangleShape button_back, bool pickable) { // current level Text currentLevel = new Text("", Game.TidyHand, 45); if (pickable) currentLevel.DisplayedString = Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i]) + " -> " + Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i] + 1); else currentLevel.DisplayedString = Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i]) + " (MAX)"; FloatRect currentLevelRect = currentLevel.GetLocalBounds(); currentLevel.Origin = new Vector2f(currentLevelRect.Width / 2.0f, 0); currentLevel.Position = new Vector2f(button_back.Size.X / 2, 120); currentLevel.Color = new Color(255, 255, 255, (byte)(pickable ? 255 : 120)); button.AddChild(currentLevel); }
public AnimatedSprite(Game game, AnimatedSpriteData data) : base(game) { Data = data; TotalFrames = Data.Frames.Count; Model = new DisplayObject(); if (Data.Texture != null) { Sprite = new Sprite(Data.Texture); Sprite.Texture.Smooth = true; Model.AddChild(Sprite); } AddChild(Model); CurrentTime = 0; FrameLength = 1 / FPS; SetFrame(0); }
protected override void SetupButtonAdditional(int i, DisplayObject button, RectangleShape button_back, bool pickable) { // current level Text currentLevel = new Text("", Game.TidyHand, 45); if (pickable) { currentLevel.DisplayedString = Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i]) + " -> " + Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i] + 1); } else { currentLevel.DisplayedString = Game.Player.GetUpgradeValue(i, Game.Player.UpgradeLevels[i]) + " (MAX)"; } FloatRect currentLevelRect = currentLevel.GetLocalBounds(); currentLevel.Origin = new Vector2f(currentLevelRect.Width / 2.0f, 0); currentLevel.Position = new Vector2f(button_back.Size.X / 2, 120); currentLevel.Color = new Color(255, 255, 255, (byte)(pickable ? 255 : 120)); button.AddChild(currentLevel); }
protected virtual void Setup() { // dim game Dim = new RectangleShape(new Vector2f(Game.Size.X, Game.Size.Y)); Dim.FillColor = new Color(0, 0, 0, 100); AddChild(Dim); // title Text title = new Text(Title, Game.TidyHand, 100); FloatRect textRect = title.GetLocalBounds(); title.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f); title.Position = new Vector2f(Game.Size.X / 2, TitleY); if (StartY == 0) StartY = title.Position.Y + 200; // back Back = new RectangleShape(new Vector2f(StripWidth == 0 ? textRect.Width + 300 : StripWidth, Game.Size.Y)); Back.FillColor = new Color(0, 0, 0, 100); Back.Position = new Vector2f(title.Position.X - (Back.Size.X / 2), 0); AddChild(Back); AddChild(title); // help Text help = new Text("(tap to change selection, hold down to choose)", Game.TidyHand, 28); textRect = help.GetLocalBounds(); help.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f); help.Position = new Vector2f(Game.Size.X / 2, HelpY); AddChild(help); // upgrades for (int i = 0; i < ButtonNames.Count; i++) { bool pickable = IsPickable(i); DisplayObject button = new DisplayObject(); button.Position = new Vector2f(Back.Position.X, StartY + (ButtonGap * i)); // back RectangleShape button_back = new RectangleShape(new Vector2f(Back.Size.X, ButtonHeight)); button_back.FillColor = new Color(0, 0, 0, (byte)(pickable ? 150 : 50)); button_back.OutlineThickness = 6; button_back.OutlineColor = new Color(0, 0, 0, 0); button.AddChild(button_back); // name Text button_name = new Text(ButtonNames[i], Game.TidyHand, 50); FloatRect button_nameRect = button_name.GetLocalBounds(); button_name.Origin = new Vector2f(button_nameRect.Left + button_nameRect.Width / 2.0f, 0); button_name.Position = new Vector2f(button_back.Size.X / 2, 0); if (!pickable) button_name.Color = new Color(255, 255, 255, 50); button.AddChild(button_name); // description if (ButtonDescriptions.Count > i) { Text button_description = new Text(ButtonDescriptions[i], Game.TidyHand, 30); FloatRect button_descriptionRect = button_description.GetLocalBounds(); button_description.Origin = new Vector2f(button_descriptionRect.Width / 2.0f, 0); button_description.Position = new Vector2f(button_back.Size.X / 2, 60); button_description.Color = new Color(180, 180, 180, (byte)(pickable ? 255 : 120)); button.AddChild(button_description); } SetupButtonAdditional(i, button, button_back, pickable); AddChild(button); if (pickable) Buttons.Add(button); else Buttons.Add(null); } SelectButton(CurrentSelection); }
// Health public void SetHealth(uint health) { if (health > HealthPoints.Count) { for (int i = HealthPoints.Count; i < health; i++) { DisplayObject bar = new DisplayObject(); int barWidth = 1; if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL) { Sprite bar_sprite = Graphics.GetSprite("assets/sprites/gui/hp.png"); bar_sprite.Color = new Color(255, 255, 255, 200); barWidth = bar_sprite.TextureRect.Width; bar.AddChild(bar_sprite); } else { RectangleShape bar_rectangle = new RectangleShape(new Vector2f(28, 60)); bar_rectangle.FillColor = new Color(255, 255, 255, 50); bar_rectangle.OutlineColor = new Color(255, 255, 255, 180); bar_rectangle.OutlineThickness = 1; barWidth = (int)bar_rectangle.Size.X + 4; bar.AddChild(bar_rectangle); } bar.Position = new Vector2f(HEALTH_START.X + ((barWidth + 2) * i), HEALTH_START.Y); AddChild(bar); HealthPoints.Add(bar); } } else if (health < HealthPoints.Count) { for (int i = HealthPoints.Count-1; i >= health; i--) { HealthPoints[i].Parent.RemoveChild(HealthPoints[i]); HealthPoints.RemoveAt(i); } } }
protected virtual void Setup() { // dim game Dim = new RectangleShape(new Vector2f(Game.Size.X, Game.Size.Y)); Dim.FillColor = new Color(0, 0, 0, 100); AddChild(Dim); // title Text title = new Text(Title, Game.TidyHand, 100); FloatRect textRect = title.GetLocalBounds(); title.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f); title.Position = new Vector2f(Game.Size.X / 2, TitleY); if (StartY == 0) { StartY = title.Position.Y + 200; } // back Back = new RectangleShape(new Vector2f(StripWidth == 0 ? textRect.Width + 300 : StripWidth, Game.Size.Y)); Back.FillColor = new Color(0, 0, 0, 100); Back.Position = new Vector2f(title.Position.X - (Back.Size.X / 2), 0); AddChild(Back); AddChild(title); // help Text help = new Text("(tap to change selection, hold down to choose)", Game.TidyHand, 28); textRect = help.GetLocalBounds(); help.Origin = new Vector2f(textRect.Left + textRect.Width / 2.0f, textRect.Top + textRect.Height / 2.0f); help.Position = new Vector2f(Game.Size.X / 2, HelpY); AddChild(help); // upgrades for (int i = 0; i < ButtonNames.Count; i++) { bool pickable = IsPickable(i); DisplayObject button = new DisplayObject(); button.Position = new Vector2f(Back.Position.X, StartY + (ButtonGap * i)); // back RectangleShape button_back = new RectangleShape(new Vector2f(Back.Size.X, ButtonHeight)); button_back.FillColor = new Color(0, 0, 0, (byte)(pickable ? 150 : 50)); button_back.OutlineThickness = 6; button_back.OutlineColor = new Color(0, 0, 0, 0); button.AddChild(button_back); // name Text button_name = new Text(ButtonNames[i], Game.TidyHand, 50); FloatRect button_nameRect = button_name.GetLocalBounds(); button_name.Origin = new Vector2f(button_nameRect.Left + button_nameRect.Width / 2.0f, 0); button_name.Position = new Vector2f(button_back.Size.X / 2, 0); if (!pickable) { button_name.Color = new Color(255, 255, 255, 50); } button.AddChild(button_name); // description if (ButtonDescriptions.Count > i) { Text button_description = new Text(ButtonDescriptions[i], Game.TidyHand, 30); FloatRect button_descriptionRect = button_description.GetLocalBounds(); button_description.Origin = new Vector2f(button_descriptionRect.Width / 2.0f, 0); button_description.Position = new Vector2f(button_back.Size.X / 2, 60); button_description.Color = new Color(180, 180, 180, (byte)(pickable ? 255 : 120)); button.AddChild(button_description); } SetupButtonAdditional(i, button, button_back, pickable); AddChild(button); if (pickable) { Buttons.Add(button); } else { Buttons.Add(null); } } SelectButton(CurrentSelection); }