Ejemplo n.º 1
0
        public Flag(Vector3 position)
            : base("Flag", PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(position), new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture);
            List<Point> frames = new List<Point>
            {
                new Point(0, 2),
                new Point(1, 2),
                new Point(2, 2)
            };
            Animation lampAnimation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture), "Flag", 32, 32, frames, true, Color.White, 5.0f + MathFunctions.Rand(), 1f, 1.0f, false);

            Sprite sprite = new Sprite(PlayState.ComponentManager, "sprite", this, Matrix.Identity, spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.YAxis
            };
            sprite.AddAnimation(lampAnimation);

            Voxel voxelUnder = new Voxel();

            if (PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder))
            {
                VoxelListener listener = new VoxelListener(PlayState.ComponentManager, this, PlayState.ChunkManager, voxelUnder);
            }

            lampAnimation.Play();
            Tags.Add("Flag");

            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 2
0
        public static Body CreateBalloon(Vector3 target, Vector3 position, ComponentManager componentManager, ContentManager content, GraphicsDevice graphics, ShipmentOrder order, Faction master)
        {
            Body balloon = new Body("Balloon", componentManager.RootComponent,
                                    Matrix.CreateTranslation(position), new Vector3(0.5f, 1, 0.5f), new Vector3(0, -2, 0));

            SpriteSheet  tex    = new SpriteSheet(ContentPaths.Entities.Balloon.Sprites.balloon);
            List <Point> points = new List <Point>
            {
                new Point(0, 0)
            };
            Animation balloonAnimation = new Animation(graphics, new SpriteSheet(ContentPaths.Entities.Balloon.Sprites.balloon), "balloon", points, false, Color.White, 0.001f, false);
            Sprite    sprite           = new Sprite(componentManager, "sprite", balloon, Matrix.Identity, tex, false)
            {
                OrientationType = Sprite.OrientMode.Spherical
            };

            sprite.AddAnimation(balloonAnimation);

            Matrix    shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);
            Shadow    shadow          = new Shadow(componentManager, "shadow", balloon, shadowTransform, new SpriteSheet(ContentPaths.Effects.shadowcircle));
            BalloonAI balloonAI       = new BalloonAI(balloon, target, order, master);

            MinimapIcon minimapIcon = new MinimapIcon(balloon, new ImageFrame(TextureManager.GetTexture(ContentPaths.GUI.map_icons), 16, 2, 0));

            return(balloon);
        }
Ejemplo n.º 3
0
        public Flag(ComponentManager componentManager, Vector3 position) :
            base(componentManager, "Flag", componentManager.RootComponent, Matrix.CreateTranslation(position), new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            SpriteSheet  spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture);
            List <Point> frames      = new List <Point>
            {
                new Point(0, 2),
                new Point(1, 2),
                new Point(2, 2)
            };
            Animation lampAnimation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture), "Flag", 32, 32, frames, true, Color.White, 5.0f + MathFunctions.Rand(), 1f, 1.0f, false);

            Sprite sprite = new Sprite(componentManager, "sprite", this, Matrix.Identity, spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.YAxis
            };

            sprite.AddAnimation(lampAnimation);



            Voxel voxelUnder = new Voxel();

            if (Manager.World.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder))
            {
                VoxelListener listener = new VoxelListener(componentManager, this, Manager.World.ChunkManager, voxelUnder);
            }

            lampAnimation.Play();
            Tags.Add("Flag");

            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 4
0
        public override void CreateCosmeticChildren(ComponentManager manager)
        {
            AddChild(new Shadow(manager));

            var spriteSheet = new SpriteSheet(ContentPaths.Entities.DwarfObjects.beartrap);

            Sprite = AddChild(new AnimatedSprite(Manager, "Sprite", Matrix.Identity, false)) as AnimatedSprite;

            Sprite.AddAnimation(AnimationLibrary.CreateAnimation(spriteSheet, new List <Point> {
                Point.Zero
            }, IdleAnimation));

            var sprung = AnimationLibrary.CreateAnimation
                             (spriteSheet, new List <Point>
            {
                new Point(0, 1),
                new Point(1, 1),
                new Point(2, 1),
                new Point(3, 1)
            }, TriggerAnimation);

            sprung.FrameHZ = 6.6f;

            Sprite.AddAnimation(sprung);

            Sprite.SetFlag(Flag.ShouldSerialize, false);
            base.CreateCosmeticChildren(manager);
        }
Ejemplo n.º 5
0
        public Chair(Vector3 position) :
            base("Chair", PlayState.ComponentManager.RootComponent, Matrix.Identity, new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            ComponentManager componentManager = PlayState.ComponentManager;
            Matrix           matrix           = Matrix.CreateRotationY((float)Math.PI * 0.5f);

            matrix.Translation = position - new Vector3(0, 0.22f, 0);
            LocalTransform     = matrix;

            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture);
            Point       topFrame    = new Point(2, 6);
            Point       sideFrame   = new Point(3, 6);

            List <Point> frames = new List <Point>
            {
                topFrame
            };

            List <Point> sideframes = new List <Point>
            {
                sideFrame
            };

            Animation tableTop       = new Animation(GameState.Game.GraphicsDevice, spriteSheet, "tableTop", 32, 32, frames, false, Color.White, 0.01f, 1.0f, 1.0f, false);
            Animation tableAnimation = new Animation(GameState.Game.GraphicsDevice, spriteSheet, "tableTop", 32, 32, sideframes, false, Color.White, 0.01f, 1.0f, 1.0f, false);

            Sprite tabletopSprite = new Sprite(componentManager, "sprite1", this, Matrix.CreateRotationX((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            tabletopSprite.AddAnimation(tableTop);

            Sprite sprite = new Sprite(componentManager, "sprite", this, Matrix.CreateTranslation(0.0f, -0.05f, -0.0f) * Matrix.Identity, spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            sprite.AddAnimation(tableAnimation);

            Sprite sprite2 = new Sprite(componentManager, "sprite2", this, Matrix.CreateTranslation(0.0f, -0.05f, -0.0f) * Matrix.CreateRotationY((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            sprite2.AddAnimation(tableAnimation);

            Voxel voxelUnder = new Voxel();

            if (PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder))
            {
                VoxelListener listener = new VoxelListener(componentManager, this, PlayState.ChunkManager, voxelUnder);
            }


            tableAnimation.Play();
            Tags.Add("Chair");
            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 6
0
 public Fixture(Vector3 position, SpriteSheet asset, Point frame, GameComponent parent)
     : base("Fixture", parent, Matrix.CreateTranslation(position), Vector3.One * 0.45f, Vector3.Zero, true)
 {
     Sprite = new Sprite(Manager, "Sprite", this, Matrix.Identity, asset, false);
     Sprite.AddAnimation(new Animation(asset.GenerateFrame(frame)));
     AddToCollisionManager = false;
     CollisionType = CollisionManager.CollisionType.Static;
 }
Ejemplo n.º 7
0
 public Fixture(Vector3 position, SpriteSheet asset, Point frame, GameComponent parent) :
     base("Fixture", parent, Matrix.CreateTranslation(position), new Vector3(asset.FrameWidth * (1.0f / 32.0f), asset.Height * (1.0f / 32.0f), asset.FrameWidth * (1.0f / 32.0f)), Vector3.Zero, true)
 {
     Sprite = new Sprite(Manager, "Sprite", this, Matrix.Identity, asset, false);
     Sprite.AddAnimation(new Animation(asset.GenerateFrame(frame)));
     AddToCollisionManager = false;
     CollisionType         = CollisionManager.CollisionType.Static;
 }
Ejemplo n.º 8
0
        public Wheat(Vector3 position)
            : base("Wheat", PlayState.ComponentManager.RootComponent, Matrix.Identity, new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            Matrix matrix = Matrix.CreateRotationY(MathFunctions.Rand(-0.1f, 0.1f));
            matrix.Translation = position + new Vector3(0.5f, -0.25f, 0.5f);
            LocalTransform = matrix;

            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Plants.wheat);

            List<Point> frames = new List<Point>
            {
                new Point(0, 0)
            };
            Animation tableAnimation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Plants.wheat), "Wheat", 32, 32, frames, false, Color.White, 0.01f, 1.0f, 1.0f, false);

            Sprite sprite = new Sprite(PlayState.ComponentManager, "sprite", this, Matrix.Identity, spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            sprite.AddAnimation(tableAnimation);

            Sprite sprite2 = new Sprite(PlayState.ComponentManager, "sprite2", this, Matrix.CreateRotationY((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            sprite2.AddAnimation(tableAnimation);

            Voxel voxelUnder = new Voxel();
            bool success = PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder);

            if (success)
            {
                VoxelListener listener = new VoxelListener(PlayState.ComponentManager, this, PlayState.ChunkManager, voxelUnder);
            }

            Inventory inventory = new Inventory("Inventory", this)
            {
                Resources = new ResourceContainer()
                {
                    MaxResources = 1,
                    Resources = new Dictionary<ResourceLibrary.ResourceType, ResourceAmount>()
                    {
                        {
                            ResourceLibrary.ResourceType.Grain,
                            new ResourceAmount(ResourceLibrary.ResourceType.Grain)
                        }
                    }
                }
            };

            Health health = new Health(PlayState.ComponentManager, "HP", this, 30, 0.0f, 30);
            new Flammable(PlayState.ComponentManager, "Flames", this, health);

            tableAnimation.Play();
            Tags.Add("Wheat");
            Tags.Add("Vegetation");
            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 9
0
        public Projectile(ComponentManager manager, Vector3 position, Vector3 initialVelocity, Health.DamageAmount damage, float size, string asset, string hitParticles, string hitNoise, Body target, bool animated = false, bool singleSprite = false) :
            base(manager, "Projectile", Matrix.CreateTranslation(position), new Vector3(size, size, size), Vector3.One, 1.0f, 1.0f, 1.0f, 1.0f, new Vector3(0, -10, 0), OrientMode.Fixed, false)
        {
            this.AllowPhysicsSleep = false;
            Target       = target;
            HitAnimation = null;
            IsSleeping   = false;
            Velocity     = initialVelocity;
            Orientation  = OrientMode.LookAt;
            CollideMode  = Physics.CollisionMode.None;
            var spriteSheet = new SpriteSheet(asset);

            if (animated)
            {
                spriteSheet.FrameWidth  = Math.Min(spriteSheet.FrameWidth, spriteSheet.FrameHeight);
                spriteSheet.FrameHeight = spriteSheet.FrameWidth;
            }

            Sprite = AddChild(new AnimatedSprite(Manager, "Sprite", Matrix.CreateRotationY((float)Math.PI * 0.5f),
                                                 false)
            {
                OrientationType = AnimatedSprite.OrientMode.Fixed
            }) as AnimatedSprite;

            Sprite.AddAnimation(AnimationLibrary.CreateSimpleAnimation(asset));

            if (singleSprite)
            {
                this.Sprite.OrientationType = AnimatedSprite.OrientMode.Spherical;
            }

            if (!singleSprite)
            {
                Sprite2 = Sprite.AddChild(new AnimatedSprite(Manager, "Sprite2",
                                                             Matrix.CreateRotationX((float)Math.PI * 0.5f),
                                                             false)
                {
                    OrientationType = AnimatedSprite.OrientMode.Fixed
                }) as AnimatedSprite;

                Sprite2.AddAnimation(AnimationLibrary.CreateSimpleAnimation(asset));
            }
            Damage       = damage;
            HitParticles = AddChild(new ParticleTrigger(hitParticles, manager, "Hit Particles",
                                                        Matrix.Identity, new Vector3(size * 0.5f, size * 0.5f, size * 0.5f), Vector3.Zero)
            {
                TriggerOnDeath  = true,
                SoundToPlay     = hitNoise,
                BoxTriggerTimes = 2
            }) as ParticleTrigger;
            DamageRadius = (float)Math.Pow(size * 4, 2);
        }
Ejemplo n.º 10
0
        public BearTrap(Vector3 pos) :
            base(
                "BearTrap", PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(pos),
                new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero, true)
        {
            Allies = "Dwarf";
            Sensor = new Sensor("Sensor", this, Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), Vector3.Zero)
            {
                FireTimer = new Timer(0.5f, false)
            };
            Sensor.OnSensed += Sensor_OnSensed;
            DeathTimer       = new Timer(0.6f, true);
            DeathParticles   = new ParticleTrigger("puff", PlayState.ComponentManager, "DeathParticles", this,
                                                   Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), Vector3.Zero)
            {
                SoundToPlay = ""
            };

            DamageAmount = 200;
            Voxel voxUnder = new Voxel();

            PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(pos, ref voxUnder);
            VoxListener = new VoxelListener(PlayState.ComponentManager, this, PlayState.ChunkManager, voxUnder);
            Sprite      = new Sprite(PlayState.ComponentManager, "Sprite", this, Matrix.Identity, new SpriteSheet(ContentPaths.Entities.DwarfObjects.beartrap), false);
            Sprite.AddAnimation(new Animation(0, ContentPaths.Entities.DwarfObjects.beartrap, 32, 32, 0)
            {
                Name = IdleAnimation
            });
            Sprite.AddAnimation(new Animation(1, ContentPaths.Entities.DwarfObjects.beartrap, 32, 32, 0, 1, 2, 3)
            {
                Name = TriggerAnimation, Speeds = new List <float>()
                {
                    6.6f
                }, Loops = true
            });
        }
Ejemplo n.º 11
0
        public Lamp(Vector3 position) :
            base("Lamp", PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(position), new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture);

            List <Point> frames = new List <Point>
            {
                new Point(0, 1),
                new Point(2, 1),
                new Point(1, 1),
                new Point(2, 1)
            };
            Animation lampAnimation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture), "Lamp", 32, 32, frames, true, Color.White, 3.0f, 1f, 1.0f, false);

            Sprite sprite = new Sprite(PlayState.ComponentManager, "sprite", this, Matrix.Identity, spriteSheet, false)
            {
                LightsWithVoxels = false,
                OrientationType  = Sprite.OrientMode.YAxis
            };

            sprite.AddAnimation(lampAnimation);


            lampAnimation.Play();
            Tags.Add("Lamp");



            Voxel voxelUnder = new Voxel();

            if (PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder))
            {
                new VoxelListener(PlayState.ComponentManager, this, PlayState.ChunkManager, voxelUnder);
            }


            new LightEmitter("light", this, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero, 255, 8)
            {
                HasMoved = true
            };
            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 12
0
        public ResourceEntity(ResourceLibrary.ResourceType resourceType, Vector3 position) :
            base(ResourceLibrary.Resources[resourceType].ResourceName, PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(position), new Vector3(0.25f, 0.25f, 0.25f), Vector3.Zero, 0.5f, 0.5f, 0.999f, 0.999f, new Vector3(0, -10, 0))
        {
            Restitution = 0.1f;
            Friction    = 0.1f;
            Resource    type        = ResourceLibrary.Resources[resourceType];
            SpriteSheet spriteSheet = new SpriteSheet(type.Image.AssetName);

            int frameX = type.Image.SourceRect.X / 32;
            int frameY = type.Image.SourceRect.Y / 32;

            List <Point> frames = new List <Point>
            {
                new Point(frameX, frameY)
            };
            Animation animation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(type.Image.AssetName), "Animation", 32, 32, frames, false, type.Tint, 0.01f, 0.75f, 0.75f, false);

            Sprite sprite = new Sprite(PlayState.ComponentManager, "Sprite", this, Matrix.CreateTranslation(Vector3.UnitY * 0.25f), spriteSheet, false)
            {
                OrientationType  = Sprite.OrientMode.Spherical,
                LightsWithVoxels = !type.SelfIlluminating
            };

            sprite.AddAnimation(animation);


            animation.Play();

            Tags.Add(type.ResourceName);
            Tags.Add("Resource");
            Bobber bobber = new Bobber(0.05f, 2.0f, MathFunctions.Rand() * 3.0f, sprite);


            if (type.IsFlammable)
            {
                Health health = new Health(PlayState.ComponentManager, "health", this, 10.0f, 0.0f, 10.0f);
                new Flammable(PlayState.ComponentManager, "Flames", this, health);
            }
        }
Ejemplo n.º 13
0
        public ResourceEntity(ResourceLibrary.ResourceType resourceType, Vector3 position)
            : base(ResourceLibrary.ResourceNames[resourceType], PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(position), new Vector3(0.25f, 0.25f, 0.25f), Vector3.Zero, 0.5f, 0.5f, 0.999f, 0.999f, new Vector3(0, -10, 0))
        {
            Restitution = 0.1f;
            Friction = 0.1f;
            Resource type = ResourceLibrary.Resources[resourceType];
            SpriteSheet spriteSheet = new SpriteSheet(type.Image.AssetName);

            int frameX = type.Image.SourceRect.X / 32;
            int frameY = type.Image.SourceRect.Y / 32;

            List<Point> frames = new List<Point>
            {
                new Point(frameX, frameY)
            };
            Animation animation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(type.Image.AssetName), "Animation", 32, 32, frames, false, Color.White, 0.01f, 0.75f, 0.75f, false);

            Sprite sprite = new Sprite(PlayState.ComponentManager, "Sprite", this, Matrix.CreateTranslation(Vector3.UnitY * 0.25f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Spherical,
                LightsWithVoxels = !type.SelfIlluminating
            };
            sprite.AddAnimation(animation);

            animation.Play();

            Tags.Add(type.ResourceName);
            Tags.Add("Resource");
            Bobber bobber = new Bobber(0.05f, 2.0f, MathFunctions.Rand() * 3.0f, sprite);

            if (type.IsFlammable)
            {
                Health health = new Health(PlayState.ComponentManager, "health", this, 10.0f, 0.0f, 10.0f);
                new Flammable(PlayState.ComponentManager, "Flames", this, health);

            }
        }
Ejemplo n.º 14
0
        public Forge(Vector3 position)
            : base("Forge", PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(position), new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture);

            List<Point> frames = new List<Point>
            {
                new Point(1, 3),
                new Point(3, 3),
                new Point(2, 3),
                new Point(3, 3)
            };
            Animation lampAnimation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture), "Forge", 32, 32, frames, true, Color.White, 3.0f, 1f, 1.0f, false);

            Sprite sprite = new Sprite(PlayState.ComponentManager, "sprite", this, Matrix.Identity, spriteSheet, false)
            {
                LightsWithVoxels = false
            };
            sprite.AddAnimation(lampAnimation);

            lampAnimation.Play();
            Tags.Add("Forge");

            Voxel voxelUnder = new Voxel();

            if (PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder))
            {
                new VoxelListener(PlayState.ComponentManager, this, PlayState.ChunkManager, voxelUnder);
            }

            new LightEmitter("light", this, Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero, 50, 4)
            {
                HasMoved = true
            };
            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 15
0
        public Table(ComponentManager manager, Vector3 position, SpriteSheet fixtureAsset, Point fixtureFrame) :
            base(manager, "Table", manager.RootComponent, Matrix.Identity, new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            Matrix matrix = Matrix.CreateRotationY((float)Math.PI * 0.5f);

            matrix.Translation = position;
            LocalTransform     = matrix;

            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture);
            Point       topFrame    = new Point(0, 6);
            Point       sideFrame   = new Point(1, 6);

            List <Point> frames = new List <Point>
            {
                topFrame
            };

            List <Point> sideframes = new List <Point>
            {
                sideFrame
            };

            Animation tableTop       = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture), "tableTop", 32, 32, frames, false, Color.White, 0.01f, 1.0f, 1.0f, false);
            Animation tableAnimation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture), "tableTop", 32, 32, sideframes, false, Color.White, 0.01f, 1.0f, 1.0f, false);

            Sprite tabletopSprite = new Sprite(manager, "sprite1", this, Matrix.CreateRotationX((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            tabletopSprite.AddAnimation(tableTop);

            Sprite sprite = new Sprite(manager, "sprite", this, Matrix.CreateTranslation(0.0f, -0.05f, -0.0f) * Matrix.Identity, spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            sprite.AddAnimation(tableAnimation);

            Sprite sprite2 = new Sprite(manager, "sprite2", this, Matrix.CreateTranslation(0.0f, -0.05f, -0.0f) * Matrix.CreateRotationY((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            sprite2.AddAnimation(tableAnimation);

            Voxel voxelUnder = new Voxel();

            if (manager.World.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder))
            {
                VoxelListener listener = new VoxelListener(manager, this, manager.World.ChunkManager, voxelUnder);
            }


            tableAnimation.Play();
            Tags.Add("Table");
            CollisionType = CollisionManager.CollisionType.Static;

            if (fixtureAsset != null)
            {
                new Fixture(new Vector3(0, 0.3f, 0), fixtureAsset, fixtureFrame, this);
            }
        }
Ejemplo n.º 16
0
        public Wheat(Vector3 position) :
            base("Wheat", PlayState.ComponentManager.RootComponent, Matrix.Identity, new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            Matrix matrix = Matrix.CreateRotationY(MathFunctions.Rand(-0.1f, 0.1f));

            matrix.Translation = position + new Vector3(0.5f, -0.25f, 0.5f);
            LocalTransform     = matrix;

            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Plants.wheat);

            List <Point> frames = new List <Point>
            {
                new Point(0, 0)
            };
            Animation tableAnimation = new Animation(GameState.Game.GraphicsDevice, new SpriteSheet(ContentPaths.Entities.Plants.wheat), "Wheat", 32, 32, frames, false, Color.White, 0.01f, 1.0f, 1.0f, false);

            Sprite sprite = new Sprite(PlayState.ComponentManager, "sprite", this, Matrix.Identity, spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            sprite.AddAnimation(tableAnimation);

            Sprite sprite2 = new Sprite(PlayState.ComponentManager, "sprite2", this, Matrix.CreateRotationY((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };

            sprite2.AddAnimation(tableAnimation);

            Voxel voxelUnder = new Voxel();
            bool  success    = PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder);

            if (success)
            {
                VoxelListener listener = new VoxelListener(PlayState.ComponentManager, this, PlayState.ChunkManager, voxelUnder);
            }

            Inventory inventory = new Inventory("Inventory", this)
            {
                Resources = new ResourceContainer()
                {
                    MaxResources = 4,
                    Resources    = new Dictionary <ResourceLibrary.ResourceType, ResourceAmount>()
                    {
                        {
                            ResourceLibrary.ResourceType.Grain,
                            new ResourceAmount(ResourceLibrary.ResourceType.Grain, MathFunctions.RandInt(1, 5))
                        }
                    }
                }
            };

            Health health = new Health(PlayState.ComponentManager, "HP", this, 30, 0.0f, 30);

            new Flammable(PlayState.ComponentManager, "Flames", this, health);

            tableAnimation.Play();
            Tags.Add("Wheat");
            Tags.Add("Vegetation");
            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 17
0
        public BearTrap(Vector3 pos)
            : base("BearTrap", PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(pos),
            new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero, true)
        {
            Allies = PlayState.PlayerFaction;
            Sensor = new Sensor("Sensor", this, Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), Vector3.Zero)
            {
                FireTimer = new Timer(0.5f, false)
            };
            Sensor.OnSensed += Sensor_OnSensed;
            DeathTimer = new Timer(0.6f, true);
            DeathParticles = new ParticleTrigger("puff", PlayState.ComponentManager, "DeathParticles", this,
                Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), Vector3.Zero)
            {
                SoundToPlay = ""
            };

            DamageAmount = 200;
            Voxel voxUnder = new Voxel();
            PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(pos, ref voxUnder);
            VoxListener = new VoxelListener(PlayState.ComponentManager, this, PlayState.ChunkManager, voxUnder);
            Sprite = new Sprite(PlayState.ComponentManager, "Sprite", this, Matrix.Identity, new SpriteSheet(ContentPaths.Entities.DwarfObjects.beartrap), false);
            Sprite.AddAnimation(new Animation(0, ContentPaths.Entities.DwarfObjects.beartrap, 32, 32,  0) {Name = IdleAnimation});
            Sprite.AddAnimation(new Animation(1, ContentPaths.Entities.DwarfObjects.beartrap, 32, 32,  0, 1, 2, 3) {Name = TriggerAnimation, Speeds =  new List<float>() {6.6f}, Loops = true});
        }
Ejemplo n.º 18
0
        public Chair(Vector3 position)
            : base("Chair", PlayState.ComponentManager.RootComponent, Matrix.Identity, new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            ComponentManager componentManager = PlayState.ComponentManager;
            Matrix matrix = Matrix.CreateRotationY((float)Math.PI * 0.5f);
            matrix.Translation = position - new Vector3(0, 0.22f, 0);
            LocalTransform = matrix;

            SpriteSheet spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture);
            Point topFrame = new Point(2, 6);
            Point sideFrame = new Point(3, 6);

            List<Point> frames = new List<Point>
            {
                topFrame
            };

            List<Point> sideframes = new List<Point>
            {
                sideFrame
            };

            Animation tableTop = new Animation(GameState.Game.GraphicsDevice, spriteSheet, "tableTop", 32, 32, frames, false, Color.White, 0.01f, 1.0f, 1.0f, false);
            Animation tableAnimation = new Animation(GameState.Game.GraphicsDevice, spriteSheet, "tableTop", 32, 32, sideframes, false, Color.White, 0.01f, 1.0f, 1.0f, false);

            Sprite tabletopSprite = new Sprite(componentManager, "sprite1", this, Matrix.CreateRotationX((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            tabletopSprite.AddAnimation(tableTop);

            Sprite sprite = new Sprite(componentManager, "sprite", this, Matrix.CreateTranslation(0.0f, -0.05f, -0.0f) * Matrix.Identity, spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            sprite.AddAnimation(tableAnimation);

            Sprite sprite2 = new Sprite(componentManager, "sprite2", this, Matrix.CreateTranslation(0.0f, -0.05f, -0.0f) * Matrix.CreateRotationY((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            sprite2.AddAnimation(tableAnimation);

            Voxel voxelUnder = new Voxel();

            if (PlayState.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder))
            {
                VoxelListener listener = new VoxelListener(componentManager, this, PlayState.ChunkManager, voxelUnder);
            }

            tableAnimation.Play();
            Tags.Add("Chair");
            CollisionType = CollisionManager.CollisionType.Static;
        }
Ejemplo n.º 19
0
        public Mushroom(ComponentManager componentManager,
                        Vector3 position,
                        string asset,
                        ResourceLibrary.ResourceType resource,
                        int numRelease, bool selfIlluminate) :
            base("Mushroom", componentManager.RootComponent, Matrix.Identity, new Vector3(1.0f, 1.0f, 1.0f), Vector3.Zero)
        {
            Seedlingsheet = new SpriteSheet(ContentPaths.Entities.Plants.deadbush, 32, 32);
            SeedlingFrame = new Point(0, 0);
            Matrix matrix = Matrix.CreateRotationY(MathFunctions.Rand(-0.1f, 0.1f));

            matrix.Translation = position + new Vector3(0.5f, -0.25f, 0.5f);
            LocalTransform     = matrix;

            SpriteSheet spriteSheet = new SpriteSheet(asset);

            List <Point> frames = new List <Point>
            {
                new Point(0, 0)
            };
            Animation animation = new Animation(GameState.Game.GraphicsDevice, spriteSheet, "Mushroom", 32, 32, frames, false, Color.White, 0.01f, 1.0f, 1.0f, false);

            Sprite sprite = new Sprite(componentManager, "sprite", this, Matrix.Identity, spriteSheet, false)
            {
                OrientationType  = Sprite.OrientMode.Fixed,
                LightsWithVoxels = !selfIlluminate
            };

            sprite.AddAnimation(animation);

            Sprite sprite2 = new Sprite(componentManager, "sprite2", this, Matrix.CreateRotationY((float)Math.PI * 0.5f), spriteSheet, false)
            {
                OrientationType  = Sprite.OrientMode.Fixed,
                LightsWithVoxels = !selfIlluminate
            };

            sprite2.AddAnimation(animation);

            Voxel voxelUnder = new Voxel();
            bool  success    = componentManager.World.ChunkManager.ChunkData.GetFirstVoxelUnder(position, ref voxelUnder);

            if (success)
            {
                VoxelListener listener = new VoxelListener(componentManager.World.ComponentManager, this, componentManager.World.ChunkManager, voxelUnder);
            }

            Inventory inventory = new Inventory("Inventory", this)
            {
                Resources = new ResourceContainer()
                {
                    MaxResources = 2,
                    Resources    = new Dictionary <ResourceLibrary.ResourceType, ResourceAmount>()
                    {
                        {
                            resource,
                            new ResourceAmount(resource, numRelease)
                        }
                    }
                }
            };

            Health health = new Health(componentManager.World.ComponentManager, "HP", this, 30, 0.0f, 30);

            new Flammable(componentManager.World.ComponentManager, "Flames", this, health);

            animation.Play();
            Tags.Add("Mushroom");
            Tags.Add("Vegetation");
            CollisionType = CollisionManager.CollisionType.Static;
        }