Esempio n. 1
0
        private void AddUI(ShipEngineData shipEngineData)
        {
            Vector2 size = Vector2.Zero;

            // For now don't set the position of this label, because we do not know the size yet
            // However, with correct parenting we will only need to set this position at the very end when the size is calculated
            // And everything else will be correctly position
            Label name = new Label(shipEngineData.DisplayName, Vector2.Zero, Color.Yellow, this);

            size = name.TextDimensions;
            AddUIObject(name, "Engine Name");

            ImageAndLabel health = new ImageAndLabel("Sprites\\UI\\Icons\\Health", "Health: " + shipEngineData.Health.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, name);

            AddUIObject(health, "Engine Health", true);
            size = new Vector2(Math.Max(size.X, health.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);

            Label thrust = new Label("Thrust: " + shipEngineData.Thrust.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, health);

            size = new Vector2(Math.Max(size.X, thrust.TextDimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(thrust, "Engine Thrust");

            ImageAndLabel price = new ImageAndLabel("Sprites\\UI\\Icons\\MoneyIcon", shipEngineData.Price.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), thrust);

            size = new Vector2(Math.Max(size.X, price.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(price, "Engine Price");

            Size           = size + new Vector2(padding, padding) * 2;
            LocalPosition += new Vector2(0, -Size.Y * 0.5f);

            // Position the first UI element correctly
            name.LocalPosition = new Vector2(0, -Size.Y * 0.5f + SpriteFont.LineSpacing * 0.5f + padding);
        }
        private void AddUI(ShipShieldData shipShieldData)
        {
            Vector2 size = Vector2.Zero;

            // For now don't set the position of this label, because we do not know the size yet
            // However, with correct parenting we will only need to set this position at the very end when the size is calculated
            // And everything else will be correctly position
            Label name = new Label(shipShieldData.DisplayName, Vector2.Zero, Color.Cyan, this);

            size = name.TextDimensions;
            AddUIObject(name, "Shield Name");

            ImageAndLabel health = new ImageAndLabel("Sprites\\UI\\Icons\\Health", "Health: " + shipShieldData.Health.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, name);

            AddUIObject(health, "Shield Health", true);
            size = new Vector2(Math.Max(size.X, health.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);

            Label range = new Label("Range: " + shipShieldData.ShieldRange.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, health);

            size = new Vector2(Math.Max(size.X, range.TextDimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(range, "Shield Range");

            ImageAndLabel strength = new ImageAndLabel("Sprites\\UI\\Icons\\ShieldStrength", "Strength: " + shipShieldData.ShieldStrength.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, range);

            AddUIObject(strength, "Shield Strength", true);
            size = new Vector2(Math.Max(size.X, strength.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);

            Label depletedRechargeDelay = new Label("Depleted Recharge Delay: " + shipShieldData.ShieldDepletedRechargeDelay.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, strength);

            size = new Vector2(Math.Max(size.X, depletedRechargeDelay.TextDimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(depletedRechargeDelay, "Shield Depleted Recharge Delay");

            Label damagedRechargeDelay = new Label("Damaged Recharge Delay: " + shipShieldData.ShieldDamagedRechargeDelay.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, depletedRechargeDelay);

            size = new Vector2(Math.Max(size.X, damagedRechargeDelay.TextDimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(damagedRechargeDelay, "Shield Damaged Recharge Delay");

            ImageAndLabel rechargePerSecond = new ImageAndLabel("Sprites\\UI\\Icons\\RepairRate", "Recharge Per Second: " + shipShieldData.ShieldRechargePerSecond.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, damagedRechargeDelay);

            AddUIObject(rechargePerSecond, "Recharge Per Second", true);
            size = new Vector2(Math.Max(size.X, rechargePerSecond.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);

            ImageAndLabel price = new ImageAndLabel("Sprites\\UI\\Icons\\MoneyIcon", shipShieldData.Price.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), rechargePerSecond);

            size = new Vector2(Math.Max(size.X, price.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(price, "Shield Price");

            Size           = size + new Vector2(padding, padding) * 2;
            LocalPosition += new Vector2(0, -Size.Y * 0.5f);

            // Position the first UI element correctly
            name.LocalPosition = new Vector2(0, -Size.Y * 0.5f + SpriteFont.LineSpacing * 0.5f + padding);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds UI to represent the weapon's damage and shots left
        /// </summary>
        public override void LoadContent()
        {
            Vector2 textSize = new Vector2(20, 40);

            CheckShouldLoad();

            CurrentDamage            = AddChild(new ImageAndLabel("", new Vector2(-Size.X * 0.5f, Size.Y * 0.5f), "UI\\CardStatThumbnails\\DamageThumbnail"));
            CurrentDamage.Colour     = Color.Red;
            CurrentDamage.Label.Size = textSize;

            CurrentShotsLeft            = AddChild(new ImageAndLabel("", Size * 0.5f, "UI\\CardStatThumbnails\\ShotsLeftThumbnail"));
            CurrentShotsLeft.Colour     = Color.LightGray;
            CurrentShotsLeft.Label.Size = textSize;

            base.LoadContent();
        }
Esempio n. 4
0
        /// <summary>
        /// Adds UI to represent the shield's current strength and shots left.
        /// </summary>
        public override void LoadContent()
        {
            Vector2 textSize = new Vector2(20, 40);

            CheckShouldLoad();

            CurrentShieldStrength            = AddChild(new ImageAndLabel("", new Vector2(-Size.X * 0.5f, Size.Y * 0.5f), "UI\\CardStatThumbnails\\DefenceThumbnail"));
            CurrentShieldStrength.Colour     = Color.LightGreen;
            CurrentShieldStrength.Label.Size = textSize;

            CurrentRechargeRate            = AddChild(new ImageAndLabel("", Size * 0.5f, "UI\\CardStatThumbnails\\ShieldRechargeThumbnail"));
            CurrentRechargeRate.Colour     = Color.Red;
            CurrentRechargeRate.Label.Size = textSize;

            base.LoadContent();
        }
Esempio n. 5
0
        /// <summary>
        /// Adds UI to represent the ship's current attack, defence, speed, shield and turret status.
        /// </summary>
        public override void LoadContent()
        {
            Vector2 textSize = new Vector2(20, 40);

            CheckShouldLoad();

            CurrentAttack            = AddChild(new ImageAndLabel("", new Vector2(-Size.X * 0.5f, Size.Y * 0.5f), "UI\\CardStatThumbnails\\DamageThumbnail"));
            CurrentAttack.Colour     = Color.Red;
            CurrentAttack.Label.Size = textSize;

            CurrentDefence            = AddChild(new ImageAndLabel("", new Vector2(0, Size.Y * 0.5f), "UI\\CardStatThumbnails\\DefenceThumbnail"));
            CurrentDefence.Colour     = Color.LightGreen;
            CurrentDefence.Label.Size = textSize;

            CurrentSpeed            = AddChild(new ImageAndLabel("", Size * 0.5f, "UI\\CardStatThumbnails\\SpeedThumbnail"));
            CurrentSpeed.Colour     = Color.White;
            CurrentSpeed.Label.Size = textSize;

            base.LoadContent();
        }
        private void AddUI(ShipTurretData shipTurretData)
        {
            Vector2 size = Vector2.Zero;

            // For now don't set the position of this label, because we do not know the size yet
            // However, with correct parenting we will only need to set this position at the very end when the size is calculated
            // And everything else will be correctly position

            Label name = new Label(shipTurretData.DisplayName, Vector2.Zero, Color.Red, this);

            size = name.TextDimensions;
            AddUIObject(name, "Turret Name");

            ImageAndLabel health = new ImageAndLabel("Sprites\\UI\\Icons\\Health", "Health: " + shipTurretData.Health.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, name);

            AddUIObject(health, "Turret Health", true);
            size = new Vector2(Math.Max(size.X, health.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);

            string turretTypeIconAsset = "";

            switch (shipTurretData.TurretType)
            {
            case "Kinetic":
                turretTypeIconAsset = "Sprites\\UI\\Icons\\KineticType";
                break;

            case "Missile":
                turretTypeIconAsset = "Sprites\\UI\\Icons\\MissileType";
                break;

            case "Beam":
                turretTypeIconAsset = "Sprites\\UI\\Icons\\BeamType";
                break;
            }

            ImageAndLabel type = new ImageAndLabel(turretTypeIconAsset, "Type: " + shipTurretData.TurretType, new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, health);

            AddUIObject(type, "Turret Type", true);
            size = new Vector2(Math.Max(size.X, type.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);

            Label range = new Label("Range: " + shipTurretData.Range.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, type);

            size = new Vector2(Math.Max(size.X, range.TextDimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(range, "Turret Range");

            ImageAndLabel damage = new ImageAndLabel("Sprites\\UI\\Icons\\Damage", "Damage: " + shipTurretData.Damage.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), Color.White, range);

            AddUIObject(damage, "Turret Damage", true);
            size = new Vector2(Math.Max(size.X, damage.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);

            ImageAndLabel price = new ImageAndLabel("Sprites\\UI\\Icons\\MoneyIcon", shipTurretData.Price.ToString(), new Vector2(0, SpriteFont.LineSpacing + padding), damage);

            size = new Vector2(Math.Max(size.X, price.Dimensions.X), size.Y + SpriteFont.LineSpacing + padding);
            AddUIObject(price, "Turret Price");

            Size           = size + new Vector2(padding, padding) * 2;
            LocalPosition += new Vector2(0, -Size.Y * 0.5f);

            // Position the first UI element correctly
            name.LocalPosition = new Vector2(0, -Size.Y * 0.5f + SpriteFont.LineSpacing * 0.5f + padding);
        }