Example #1
0
        public Projectile(Vector3 position, Vector3 initialVelocity, Health.DamageAmount damage, float size, string asset, string hitParticles, string hitNoise, Body target) :
            base("Projectile", PlayState.ComponentManager.RootComponent, Matrix.CreateTranslation(position), new Vector3(size, size, size), Vector3.One, 1.0f, 1.0f, 1.0f, 1.0f, new Vector3(0, -10, 0))
        {
            Target                = target;
            HitAnimation          = null;
            IsSleeping            = false;
            Velocity              = initialVelocity;
            Orientation           = OrientMode.LookAt;
            AddToCollisionManager = false;
            CollideMode           = Physics.CollisionMode.None;
            Sprite                = new Sprite(PlayState.ComponentManager, "Sprite", this, Matrix.CreateRotationY((float)Math.PI * 0.5f),
                                               new SpriteSheet(asset), false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            Sprite.SetSingleFrameAnimation(new Point(0, 0));
            Sprite2 = new Sprite(PlayState.ComponentManager, "Sprite2", Sprite, Matrix.CreateRotationX((float)Math.PI * 0.5f),
                                 new SpriteSheet(asset), false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            Sprite2.SetSingleFrameAnimation(new Point(0, 0));

            Damage       = damage;
            HitParticles = new ParticleTrigger(hitParticles, PlayState.ComponentManager, "Hit Particles", this,
                                               Matrix.Identity, new Vector3(size * 0.5f, size * 0.5f, size * 0.5f), Vector3.Zero)
            {
                TriggerOnDeath  = true,
                SoundToPlay     = hitNoise,
                BoxTriggerTimes = 2
            };
            DamageRadius = (float)Math.Pow(size * 4, 2);
        }
Example #2
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);
        }
Example #3
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("Projectile", manager.RootComponent, Matrix.CreateTranslation(position), new Vector3(size, size, size), Vector3.One, 1.0f, 1.0f, 1.0f, 1.0f, new Vector3(0, -10, 0))
        {
            Target                = target;
            HitAnimation          = null;
            IsSleeping            = false;
            Velocity              = initialVelocity;
            Orientation           = OrientMode.LookAt;
            AddToCollisionManager = false;
            CollideMode           = Physics.CollisionMode.None;
            var spriteSheet = new SpriteSheet(asset);

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

            Sprite = new Sprite(manager, "Sprite", this, Matrix.CreateRotationY((float)Math.PI * 0.5f),
                                spriteSheet, false)
            {
                OrientationType = Sprite.OrientMode.Fixed
            };
            if (animated)
            {
                Sprite.SetSimpleAnimation();
                Sprite.CurrentAnimation.Play();
            }
            else
            {
                Sprite.SetSingleFrameAnimation();
            }

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

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

                if (animated)
                {
                    Sprite2.SetSimpleAnimation();
                }
                else
                {
                    Sprite2.SetSingleFrameAnimation();
                }
            }
            Damage       = damage;
            HitParticles = new ParticleTrigger(hitParticles, manager, "Hit Particles", this,
                                               Matrix.Identity, new Vector3(size * 0.5f, size * 0.5f, size * 0.5f), Vector3.Zero)
            {
                TriggerOnDeath  = true,
                SoundToPlay     = hitNoise,
                BoxTriggerTimes = 2
            };
            DamageRadius = (float)Math.Pow(size * 4, 2);
        }
Example #4
0
        public Projectile(ComponentManager manager, Vector3 position, Vector3 initialVelocity, Health.DamageAmount damage, float size, string asset, string hitParticles, string hitNoise, GameComponent 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)
        {
            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;
            }

            // Todo: Needs the cosmetic children treatement.
            if (animated)
            {
                Sprite = AddChild(new AnimatedSprite(Manager, "Sprite", Matrix.CreateRotationY((float)Math.PI * 0.5f))
                {
                    OrientationType = AnimatedSprite.OrientMode.Fixed
                }) as AnimatedSprite;

                var anim = Library.CreateSimpleAnimation(asset);
                anim.Loops = true;
                (Sprite as AnimatedSprite).AddAnimation(anim);

                if (singleSprite)
                {
                    (Sprite as AnimatedSprite).OrientationType = AnimatedSprite.OrientMode.Spherical;
                }
            }
            else
            {
                Sprite = AddChild(new SimpleSprite(Manager, "Sprite", Matrix.CreateRotationY((float)Math.PI * 0.5f), spriteSheet, new Point(0, 0))
                {
                    OrientationType = SimpleSprite.OrientMode.Fixed
                }) as SimpleSprite;
                (Sprite as SimpleSprite).AutoSetWorldSize();
                if (singleSprite)
                {
                    (Sprite as SimpleSprite).OrientationType = SimpleSprite.OrientMode.Spherical;
                }
            }

            Sprite.SetFlag(Flag.ShouldSerialize, false);

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

                    var anim = Library.CreateSimpleAnimation(asset);
                    anim.Loops = true;
                    (Sprite2 as AnimatedSprite).AddAnimation(anim);
                }
                else
                {
                    Sprite2 = AddChild(new SimpleSprite(Manager, "Sprite", Matrix.CreateRotationY((float)Math.PI * 0.5f) * Matrix.CreateRotationZ((float)Math.PI * 0.5f), spriteSheet, new Point(0, 0))
                    {
                        OrientationType = SimpleSprite.OrientMode.Fixed
                    }) as SimpleSprite;
                    (Sprite2 as SimpleSprite).AutoSetWorldSize();
                }
                Sprite2.SetFlag(Flag.ShouldSerialize, false);
            }

            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);
        }