Exemplo n.º 1
0
        public Cannon(Game game)
            : base(game, game.GraphicsMode == Game.GRAPHICSMODE_NORMAL ? Graphics.GetSprite("assets/sprites/cannon.png") : Graphics.GetSprite("assets/sprites/blueprint/cannon.png"))
        {
            Model.Scale = new Vector2f(0.5f, 0.5f);
            Model.Origin = new Vector2f(26, 30);
            CanMove = false;
            RemoveOnDeath = false;

            HealthMax = 1000;
            Health = UpgradeLevels[0];

            PowerupEffect = new DisplayObject();
            AddChildAt(PowerupEffect, 0);
        }
Exemplo n.º 2
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);
 }
        public void Debug_ShowWaypoints(bool value = true)
        {
            Debug_ShowingWaypoints = value;
            if (Debug_ShowingWaypoints)
            {
                Debug_Waypoints = new DisplayObject();
                Game.Layer_Other.AddChild(Debug_Waypoints);

                Debug_ShowWaypointsUpdate();
            }
            else if (Debug_Waypoints != null)
            {
                if (Debug_Waypoints.Parent != null)
                    Debug_Waypoints.Parent.RemoveChild(Debug_Waypoints);
                Debug_Waypoints = null;
            }
        }
Exemplo n.º 4
0
        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);
        }
 /// <summary>Additonal Setup for buttons (made to be overridden)</summary>
 protected virtual void SetupButtonAdditional(int i, DisplayObject button, RectangleShape button_back, bool pickable)
 {
 }
        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);
        }
Exemplo n.º 7
0
        // 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);
                }
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 /// <summary>Additonal Setup for buttons (made to be overridden)</summary>
 protected virtual void SetupButtonAdditional(int i, DisplayObject button, RectangleShape button_back, bool pickable)
 {
 }