Esempio n. 1
0
        /// <summary>
        /// Adds all our UI for our weapon description
        /// </summary>
        public override void AddInitialUI()
        {
            base.AddInitialUI();

            DebugUtils.AssertNotNull(Weapon);
            DebugUtils.AssertNotNull(Weapon.WeaponData);

            WeaponImage = AddObject(new Image(new Vector2(300, 300), Vector2.Zero, Weapon.WeaponData.TextureAsset)) as Image;
            WeaponImage.Name = "Weapon Image";
            WeaponImage.UsesCollider = false;

            WeaponNameLabel = AddObject(new Label(Weapon.WeaponData.DisplayName, Vector2.Zero)) as Label;
            WeaponNameLabel.Name = "Weapon Name";

            BulletImages = new Image[Weapon.WeaponData.MagazineSize];
            for (int i = 0; i < Weapon.WeaponData.MagazineSize; i++)
            {
                // Fixup position later
                BulletImages[i] = AddObject(new Image(Vector2.Zero, Weapon.WeaponData.BulletThumbnailTextureAsset)) as Image;
                BulletImages[i].UsesCollider = false;
            }

            // Fixup position later
            ReloadingLabel = AddObject(new FlashingLabel(1.5f, "RELOADING", Vector2.Zero)) as FlashingLabel;
            ReloadingLabel.Colour = Color.Red;
            ReloadingLabel.Hide();
        }
Esempio n. 2
0
        /// <summary>
        /// Determines whether we should add an object based on our CurrentObjectExists flag.
        /// If so, we generate a possible height change using our probability and add our tile to our LevelObjects array
        /// </summary>
        /// <param name="xIndex"></param>
        /// <returns></returns>
        private UIObject Create(int xIndex)
        {
            if (!CurrentObjectExists)
            {
                LevelObjects[currentHeight, xIndex] = null;
            }
            else
            {
                float yDelta = 0;

                if (MathUtils.GenerateFloat(0, 1) <= GenerationData.HeightChangeProbability)
                {
                    int amount = MathUtils.GenerateInt(-GenerationData.MaximumHeightChange, GenerationData.MaximumHeightChange);

                    currentHeight += amount;
                    currentHeight = MathHelper.Clamp(currentHeight, 0, GenerationData.Height - 1);

                    yDelta = amount * TileDimensions.Y;
                }

                LevelObjects[currentHeight, xIndex] = new Image(new Vector2(TileDimensions.X * xIndex, TileDimensions.Y * currentHeight), QueryTextureAsset());
                LevelObjects[currentHeight, xIndex].StoredObject = QueryPositionType();

                Point thisPoint = new Point(xIndex, currentHeight);
                Debug.Assert(!walkingLayerPoints.Exists(x => x.Key == thisPoint));
                walkingLayerPoints.Add(new KeyValuePair<Point, Type>(thisPoint, Type.kWalkableLayer));
            }

            return LevelObjects[currentHeight, xIndex];
        }
Esempio n. 3
0
        public Bar(
            float minValue,
            float maxValue,
            float currentValue,
            string text,
            Vector2 size,
            Vector2 localPosition,
            string foregroundTextureAsset = AssetManager.DefaultBarForegroundTextureAsset,
            string backgroundTextureAsset = AssetManager.DefaultBarBackgroundTextureAsset,
            float lifeTime = float.MaxValue) :
            base(size, localPosition, backgroundTextureAsset, lifeTime)
        {
            FrontImage = new Image(Vector2.Zero, foregroundTextureAsset, lifeTime);
            FrontImage.Colour = Color.Blue;
            FrontImage.SetParent(this);

            // Fix up our label position after all the textures are initialised
            // Parent it to the bar
            InfoLabel = new Label(text, Vector2.Zero, AssetManager.DefaultSpriteFontAsset, lifeTime);
            InfoLabel.SetParent(this);

            // Fix up our label position after all the textures are initialised
            // Parent it to the bar
            ValueLabel = new Label(currentValue.ToString(), Vector2.Zero, AssetManager.DefaultSpriteFontAsset, lifeTime);
            ValueLabel.SetParent(this);

            MinValue = minValue;
            MaxValue = maxValue;
            CurrentValue = currentValue;
        }