Esempio n. 1
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. 2
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. 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
        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());
        }
        public FireballProjectile(ComponentManager manager, Vector3 position, Vector3 initialVelocity, Body target) :
            base(manager, position, initialVelocity, new Health.DamageAmount() { Amount = 15.0f, DamageType = Health.DamageType.Fire }, 0.25f, ContentPaths.Particles.fireball, "flame", ContentPaths.Audio.Oscar.sfx_ic_demon_fire_hit_1, target)
        {
            Sprite.LightsWithVoxels  = false;
            Sprite2.LightsWithVoxels = false;

            HitAnimation = AnimationLibrary.CreateSimpleAnimation(ContentPaths.Effects.pierce);
        }
Esempio n. 6
0
 public AnimationPlayer GetAnimationPlayer(LayeredSprites.LayerStack stack)
 {
     foreach (Animation animation in AnimationLibrary.LoadNewLayeredAnimationFormat(ContentPaths.dwarf_animations))
     {
         if (animation.Name == "IdleFORWARD")
         {
             return(new AnimationPlayer(stack.ProxyAnimation(animation)));
         }
     }
     return(null);
 }
Esempio n. 7
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. 8
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);
        }
Esempio n. 9
0
 public Attack(string name, float damage, float time, float range, SoundSource noise, string animation)
 {
     Name           = name;
     DamageAmount   = damage;
     RechargeTimer  = new Timer(time + MathFunctions.Rand(-0.2f, 0.2f), false);
     Range          = range;
     HitNoise       = noise;
     Mode           = AttackMode.Melee;
     Knockback      = 0.0f;
     HitAnimation   = null;
     HitColor       = Color.White;
     HitParticles   = "";
     ProjectileType = "";
     AnimationAsset = animation;
     HitAnimation   = AnimationLibrary.CreateSimpleAnimation(AnimationAsset);
 }
Esempio n. 10
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();
        }
Esempio n. 11
0
        public EmployeeClass(EmployeeClassDef definition)
        {
            Name   = definition.Name;
            Levels = definition.Levels;
            foreach (string s in definition.Actions)
            {
                var value = Task.TaskCategory.None;
                if (Enum.TryParse(s, true, out value))
                {
                    Actions |= value;
                }
            }

            Animations = AnimationLibrary.LoadCompositeAnimationSet(definition.Animations, Name);
            Attacks    = definition.Attacks;
        }
Esempio n. 12
0
        protected CharacterSprite CreateSprite(string animations, ComponentManager manager, float VerticalOffset = 0.5f, bool AddToPhysics = true)
        {
            var sprite = new CharacterSprite(manager, "Sprite", Matrix.CreateTranslation(0, VerticalOffset, 0));

            if (AddToPhysics)
            {
                Physics.AddChild(sprite);
            }

            foreach (var animation in AnimationLibrary.LoadCompositeAnimationSet(animations, Name))
            {
                sprite.AddAnimation(animation);
            }

            sprite.SetFlag(Flag.ShouldSerialize, false);

            return(sprite);
        }
Esempio n. 13
0
        protected void CreateDwarfSprite(EmployeeClass employeeClass, ComponentManager manager)
        {
            if (Physics == null)
            {
                Physics = GetRoot().GetComponent <Physics>();
                if (Physics == null)
                {
                    return;
                }
            }

            var sprite = Physics.AddChild(new LayeredSprites.LayeredCharacterSprite(manager, "Sprite", Matrix.CreateTranslation(new Vector3(0, 0.15f, 0)))) as LayeredSprites.LayeredCharacterSprite;

            var random = new Random(Stats.RandomSeed);

            var hairPalette = LayeredSprites.LayerLibrary.EnumeratePalettes().Where(p => p.Layer.Contains("hair")).SelectRandom(random);
            var skinPalette = LayeredSprites.LayerLibrary.EnumeratePalettes().Where(p => p.Layer.Contains("face")).SelectRandom(random);

            AddLayerOrDefault(sprite, random, "body", skinPalette);
            AddLayerOrDefault(sprite, random, "face", skinPalette);
            AddLayerOrDefault(sprite, random, "nose", skinPalette);
            AddLayerOrDefault(sprite, random, "beard", hairPalette);
            AddLayerOrDefault(sprite, random, "hair", hairPalette);
            AddLayerOrDefault(sprite, random, "tool");
            AddLayerOrDefault(sprite, random, "hat", hairPalette);

            AttackMode = Stats.CurrentClass.AttackMode;

            foreach (Animation animation in AnimationLibrary.LoadNewLayeredAnimationFormat(ContentPaths.dwarf_animations))
            {
                sprite.AddAnimation(animation);
            }

            sprite.SetCurrentAnimation(Sprite.Animations.First().Value);
            sprite.SetFlag(Flag.ShouldSerialize, false);
        }
Esempio n. 14
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Gremlin.gremlin_animations, "Gremlin");
 }
Esempio n. 15
0
 private void InitializeAnimations()
 {
     Animations         = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Dwarf.Sprites.musketdwarf_animations, "Dwarf");
     MinecartAnimations = ContentPaths.Entities.Dwarf.Sprites.musket_minecart;
 }
Esempio n. 16
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Goblin.Sprites.goblin_animations, "Goblin");
 }
Esempio n. 17
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Skeleton.necro_animations, "Skeleton");
 }
Esempio n. 18
0
 public SnowballProjectile(ComponentManager manager, Vector3 position, Vector3 initialVelocity, Body target) :
     base(manager, position, initialVelocity, new Health.DamageAmount() { Amount = 30.0f, DamageType = Health.DamageType.Normal }, 0.25f, ContentPaths.Entities.snowball, "snow_particle", ContentPaths.Audio.Oscar.sfx_env_voxel_snow_destroy, target, true, true)
 {
     HitAnimation = AnimationLibrary.CreateSimpleAnimation(ContentPaths.Effects.flash);
 }
Esempio n. 19
0
 public MudProjectile(ComponentManager manager, Vector3 position, Vector3 initialVelocity, Body target) :
     base(manager, position, initialVelocity, new Health.DamageAmount() { Amount = 30.0f, DamageType = Health.DamageType.Normal }, 0.25f, ContentPaths.Entities.mudball, "dirt_particle", ContentPaths.Audio.gravel, target, true, true)
 {
     HitAnimation = AnimationLibrary.CreateSimpleAnimation(ContentPaths.Effects.flash);
 }
Esempio n. 20
0
 void InitializeAnimations()
 {
     Animations         = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Dwarf.Sprites.wizard_animation, "Dwarf");
     MinecartAnimations = ContentPaths.Entities.Dwarf.Sprites.wizard_minecart;
 }
Esempio n. 21
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Moleman.moleman_animations, "Dwarf");
 }
Esempio n. 22
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Kobold.kobold_animations, "Kobold");
 }
Esempio n. 23
0
 private void OnDeserialized(StreamingContext context)
 {
     HitAnimation = AnimationLibrary.CreateSimpleAnimation(AnimationAsset);
 }
Esempio n. 24
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.snowman_animation, "Snowman");
 }
Esempio n. 25
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.mudman_animation, "MudGolem");
 }
Esempio n. 26
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Demon.demon_animations, "Demon");
 }
Esempio n. 27
0
 public ArrowProjectile(ComponentManager manager, Vector3 position, Vector3 initialVelocity, Body target) :
     base(manager, position, initialVelocity, new Health.DamageAmount() { Amount = 10.0f, DamageType = Health.DamageType.Slashing }, 0.25f, ContentPaths.Entities.Elf.Sprites.arrow, "puff", ContentPaths.Audio.Oscar.sfx_ic_elf_arrow_hit, target)
 {
     HitAnimation = AnimationLibrary.CreateSimpleAnimation(ContentPaths.Effects.pierce);
 }
Esempio n. 28
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Troll.troll_animation, "Troll");
 }
Esempio n. 29
0
 public override void CreateCosmeticChildren(ComponentManager Manager)
 {
     base.CreateCosmeticChildren(Manager);
     HitAnimation = AnimationLibrary.CreateSimpleAnimation(ContentPaths.Effects.pierce);
 }
Esempio n. 30
0
 void InitializeAnimations()
 {
     Animations = AnimationLibrary.LoadCompositeAnimationSet(ContentPaths.Entities.Dwarf.Sprites.fairy_animation, "Dwarf");
 }