public void AddDecoration(Decoration decoration)
        {
            if (decoration == null)
            {
                throw new ArgumentException($"Decoration cannot be empty", nameof(decoration));
            }

            Decorations.Add(decoration);
        }
Esempio n. 2
0
        public ActiveDecoration CreateDecoration(Player owner, string nativeName, Tile target, TagSynergy[] armor, string visualization, float?z, int?health, float?mod)
        {
            if (target.TempObject != null)
            {
                return(null);
            }

            ActiveDecoration decoration = new ActiveDecoration(this, owner, target, visualization, z, health, armor, NativeManager.GetDecorationNative(nativeName), mod);

            Decorations.Add(decoration);
            target.ChangeTempObject(decoration, true);
            return(decoration);
        }
Esempio n. 3
0
        public Entity CreateDecoration(IRectangle hitBox)
        {
            var body = _physics.CreateBody(new BoxCollider(hitBox),
                                           new PhysicalMaterial
            {
                Absorption        = 0.1,
                Restoring         = 0.5,
                Viscosity         = 0.1,
                Density           = 690,
                Friction          = 0.1,
                MovementEmitter   = false,
                MovementRecipient = false,
            });
            var entity = new Entity(this, body);

            Decorations.Add(entity);
            return(entity);
        }
Esempio n. 4
0
        public static Decorations GetDecorations()
        {
            var decorations = new Decorations();

            foreach (var t in typeof(TileType).GetMembers())
            {
                var attrs = t.GetCustomAttributes(typeof(DecorationAttribute), false);
                if (attrs != null && attrs.Any())
                {
                    var variant = (TileType)Enum.Parse(typeof(TileType), t.Name);
                    decorations.Add(variant, new List <DecorationAttribute>());
                    foreach (var attr in attrs.Cast <DecorationAttribute>())
                    {
                        decorations[variant].Add(attr);
                    }
                }
            }
            return(decorations);
        }
Esempio n. 5
0
File: Tile.cs Progetto: evad1n/TBoS
        /// <summary>
        /// Randomly generates tile decorations.
        /// </summary>
        public void GenerateDecorations()
        {
            //Determine whether a decoration spawns
            switch (ID)
            {
            //Ground tiles spawn grasses, rocks, and vines where applicable.
            case 1:
            case 3:
            case 4:
            case 5:
                //If this tile has nothing above it, have a chance to spawn a grass or rock.
                if (Adjacents[0] == false)
                {
                    if (Game1.RandomObject.Next(10) <= 3)
                    {
                        Decorations.Add(new TileDecoration(new Rectangle(Rect.X, Rect.Y - (Rect.Height - Rect.Height / Game1.TILE_PIXEL_SIZE), Rect.Width, Rect.Height), 0));
                    }
                }

                //If this tile has nothing under it, have a chance to spawn a vine.
                if (Adjacents[3] == false)
                {
                    if (Game1.RandomObject.Next(10) <= 1)
                    {
                        Decorations.Add(new TileDecoration(new Rectangle(Rect.X, Rect.Y + (Rect.Height - Rect.Height / Game1.TILE_PIXEL_SIZE), Rect.Width, Rect.Height), 1));
                    }
                }

                //If this tile has something above, below, and to either side, have a chance to spawn a different stone texture.
                if (Adjacents[0] && Adjacents[1] && Adjacents[2] && Adjacents[3] && ID != 3)
                {
                    if (Game1.RandomObject.Next(10) <= 1)
                    {
                        Decorations.Add(new TileDecoration(new Rectangle(Rect.X, Rect.Y, Rect.Width, Rect.Height), 4));
                    }
                }

                if (ID == 3)
                {
                    if (Game1.RandomObject.Next(10) == 0)
                    {
                        Decorations.Add(new TileDecoration(new Rectangle(Rect.X, Rect.Y, Rect.Width, Rect.Height), 5));
                    }
                }
                break;

            //Background tiles spawn rocky bits and rough bottoms where applicable.
            case 2:
                //Have a chance to spawn middle roughness.
                if (Game1.RandomObject.Next(10) == 0)
                {
                    Decorations.Add(new TileDecoration(Rect, 2));
                }

                //If there's nothing below this tile, have a chance to spawn bottom roughness.
                if (Adjacents[3] == false)
                {
                    if (Game1.RandomObject.Next(10) <= 1)
                    {
                        Decorations.Add(new TileDecoration(new Rectangle(Rect.X, Rect.Y + (Rect.Height - Rect.Height / Game1.TILE_PIXEL_SIZE), Rect.Width, Rect.Height), 3));
                    }
                }
                break;
            }
        }
Esempio n. 6
0
        public void AddDecoration(IDecoration decoration)
        {
            Decorations.Add(decoration);

            this.Comfort += decoration.Comfort;
        }