Esempio n. 1
0
        private void CreateSpriteStanding()
        {
            var spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32);

            List <Point> frames = new List <Point>
            {
                new Point(0, 1),
                new Point(2, 1),
                new Point(1, 1),
                new Point(2, 1)
            };

            var lampAnimation = AnimationLibrary.CreateAnimation(spriteSheet, frames, "LampAnimation");

            var sprite = AddChild(new AnimatedSprite(Manager, "sprite", Matrix.Identity, false)
            {
                LightsWithVoxels = false,
                OrientationType  = AnimatedSprite.OrientMode.YAxis,
            }) as AnimatedSprite;

            sprite.AddAnimation(lampAnimation);
            sprite.AnimPlayer.Loop(lampAnimation);
            sprite.SetFlag(Flag.ShouldSerialize, false);

            // This is a hack to make the animation update at least once even when the object is created inactive by the craftbuilder.
            sprite.AnimPlayer.Update(new DwarfTime());
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public override void CreateCosmeticChildren(ComponentManager Manager)
        {
            base.CreateCosmeticChildren(Manager);

            var spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.conveyor, 32);

            var frames = new List <Point>
            {
                new Point(0, 0),
                new Point(1, 0),
                new Point(2, 0),
                new Point(3, 0)
            };

            var forgeAnimation = AnimationLibrary.CreateAnimation(spriteSheet, frames, "ConveyorAnimation");

            forgeAnimation.Loops = true;

            var sprite = AddChild(new AnimatedSprite(Manager, "sprite", Matrix.CreateRotationX((float)Math.PI * 0.5f) * Matrix.CreateTranslation(0.0f, -0.4f, 0.0f))
            {
                OrientationType = AnimatedSprite.OrientMode.Fixed
            }) as AnimatedSprite;

            sprite.AddAnimation(forgeAnimation);
            sprite.AnimPlayer.Play(forgeAnimation);


            AddChild(new GenericVoxelListener(Manager, Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.0f, -1.0f, 0.0f), (changeEvent) =>
            {
                if (changeEvent.Type == VoxelChangeEventType.VoxelTypeChanged && changeEvent.NewVoxelType == 0)
                {
                    Die();
                }
            })).SetFlag(Flag.ShouldSerialize, false);
        }
Esempio n. 4
0
        public override void CreateCosmeticChildren(ComponentManager Manager)
        {
            base.CreateCosmeticChildren(Manager);

            var spriteSheet = new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32);

            var frames = new List <Point>
            {
                new Point(1, 3),
                new Point(3, 3),
                new Point(2, 3),
                new Point(3, 3)
            };

            var forgeAnimation = AnimationLibrary.CreateAnimation(spriteSheet, frames, "ForgeLightAnimation");

            var sprite = AddChild(new AnimatedSprite(Manager, "sprite", Matrix.Identity, false)
            {
                LightsWithVoxels = false
            }) as AnimatedSprite;

            sprite.AddAnimation(forgeAnimation);
            sprite.AnimPlayer.Loop(forgeAnimation);
            sprite.SetFlag(Flag.ShouldSerialize, false);

            AddChild(new LightEmitter(Manager, "light", Matrix.Identity, new Vector3(0.1f, 0.1f, 0.1f), Vector3.Zero, 50, 4)
            {
                HasMoved = true
            }).SetFlag(Flag.ShouldSerialize, false);

            // This is a hack to make the animation update at least once even when the object is created inactive by the craftbuilder.
            sprite.AnimPlayer.Update(new DwarfTime());
        }
Esempio n. 5
0
        public override void CreateCosmeticChildren(ComponentManager manager)
        {
            AddChild(new Shadow(manager));

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

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

            sprite.AddAnimation(AnimationLibrary.CreateAnimation(spriteSheet, new List <Point> {
                Point.Zero
            }, "BearTrapIdle"));

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

            sprung.FrameHZ = 6.6f;

            sprite.AddAnimation(sprung);

            sprite.SetFlag(Flag.ShouldSerialize, false);
            sprite.SetCurrentAnimation("BearTrapIdle", false);

            AddChild(new GenericVoxelListener(manager, Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.0f, -1.0f, 0.0f), (changeEvent) =>
            {
                if (changeEvent.Type == VoxelChangeEventType.VoxelTypeChanged && changeEvent.NewVoxelType == 0)
                {
                    Die();
                }
            })).SetFlag(Flag.ShouldSerialize, false);


            var sensor = AddChild(new Sensor(manager, "Sensor", Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), Vector3.Zero)
            {
                FireTimer = new Timer(0.5f, false, Timer.TimerMode.Real)
            }) as Sensor;

            sensor.OnSensed += Sensor_OnSensed;
            sensor.SetFlag(Flag.ShouldSerialize, false);

            AddChild(new ParticleTrigger("explode", Manager, "DeathParticles",
                                         Matrix.Identity, new Vector3(0.5f, 0.5f, 0.5f), Vector3.Zero)
            {
                SoundToPlay = ContentPaths.Audio.Oscar.sfx_trap_destroyed
            }).SetFlag(Flag.ShouldSerialize, false);

            base.CreateCosmeticChildren(manager);
        }
Esempio n. 6
0
        public void SetPortrait(String Gfx, int FrameWidth, int FrameHeight, float Speed, List <int> Frames)
        {
            SpeakerAnimation = AnimationLibrary.CreateAnimation(new Animation.SimpleDescriptor
            {
                AssetName = Gfx,
                Speed     = 1.0f / Speed,
                Frames    = Frames,
                Width     = FrameWidth,
                Height    = FrameHeight
            });

            SpeakerAnimation.Loops = true;

            SpeakerAnimationPlayer = new AnimationPlayer(SpeakerAnimation);
            SpeakerAnimationPlayer.Play();
        }