예제 #1
0
파일: CrystalMan.cs 프로젝트: nemec/4Realms
        private void init()
        {
            Crystals      = new List <Crystal>();
            OuterCrystals = new List <Crystal>();

            Crystal     inner     = new Crystal("crystal_center", GroundPos, crystalHealth, this);
            SpriteFrame animation = GetAnimation();

            animation.Height = inner.GetAnimation().Height;
            animation.Width  = inner.GetAnimation().Width;
            Crystals.Add(inner);
            inner.HealthChanged += new HealthChangedHandler(updateHealth);

            for (int x = 0; x < numOuterCrystals; x++)
            {
                double  angle  = 2 * Math.PI * x / numOuterCrystals - Math.PI / 2;
                Vector2 offset = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * radius;
                Crystal outer  = new Crystal("crystal_" + x, GroundPos + offset, crystalHealth, this);
                Crystals.Add(outer);
                OuterCrystals.Add(outer);
                outer.HealthChanged += new HealthChangedHandler(updateHealth);
                outer.Direction      = -offset;
            }
        }
예제 #2
0
파일: CrystalMan.cs 프로젝트: nemec/4Realms
        private void init()
        {
            Crystals = new List<Crystal>();
            OuterCrystals = new List<Crystal>();

            Crystal inner = new Crystal("crystal_center", GroundPos, crystalHealth, this);
            SpriteFrame animation = GetAnimation();
            animation.Height = inner.GetAnimation().Height;
            animation.Width = inner.GetAnimation().Width;
            Crystals.Add(inner);
            inner.HealthChanged += new HealthChangedHandler(updateHealth);

            for (int x = 0; x < numOuterCrystals; x++)
            {
                double angle = 2 * Math.PI * x / numOuterCrystals - Math.PI / 2;
                Vector2 offset = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * radius;
                Crystal outer = new Crystal("crystal_" + x, GroundPos + offset, crystalHealth, this);
                Crystals.Add(outer);
                OuterCrystals.Add(outer);
                outer.HealthChanged += new HealthChangedHandler(updateHealth);
                outer.Direction = -offset;
            }
        }
예제 #3
0
파일: CrystalMan.cs 프로젝트: nemec/4Realms
        protected override void updateAttack()
        {
            if (isAttackAnimDone && attackWait < This.gameTime.TotalGameTime)
            {
                attackWait = This.gameTime.TotalGameTime + new TimeSpan(0, 0, This.Game.rand.Next(2, 5));
                int AttackChoice = This.Game.rand.Next(7);
                if (AttackChoice <= 0 && OuterCrystals.Count > 0)
                {
                    foreach (Crystal c in OuterCrystals)
                    {
                        mAttacks.Add(Attacks.LightningSpan(c, this, 5, 0).GetEnumerator());
                    }
                }
                else if (AttackChoice <= 1 && OuterCrystals.Count > 0)
                {
                    Crystal target = OuterCrystals.GetRandomElement();
                    if (target != null)
                    {
                        mAttacks.Add(Attacks.LightningSpan(target, this, 7, 0).GetEnumerator());
                    }
                }
                else if (AttackChoice <= 2)
                {
                    AttackRotation rot;
                    if (This.Game.rand.Next(2) == 0)
                    {
                        rot = AttackRotation.Clockwise;
                    }
                    else
                    {
                        rot = AttackRotation.CounterClockwise;
                    }
                    foreach (Crystal c in OuterCrystals)
                    {
                        mAttacks.Add(Attacks.LightningSpan(c, this, 7, 0, rotation: rot).GetEnumerator());
                    }
                }
                else
                {
                    attackStartTime = This.gameTime.TotalGameTime;

                    Effect    particleEffect = This.Game.CurrentLevel.GetEffect("ParticleSystem");
                    Texture2D lightning      = This.Game.CurrentLevel.GetTexture("sparkball");

                    foreach (TimeSpan delay in new TimeSpan[] {
                        TimeSpan.Zero, new TimeSpan(0, 0, 0, 0, 500), new TimeSpan(0, 0, 1),
                    })
                    {
                        Sprite          target = (This.Game.CurrentLevel as FrostbyteLevel).allies.Where(x => x.State != SpriteState.Dead).GetRandomElement();
                        ParticleEmitter particleEmitterLightning = new ParticleEmitter(1000, particleEffect, lightning);
                        particleEmitterLightning.effectTechnique  = "FadeAtXPercent";
                        particleEmitterLightning.fadeStartPercent = .98f;
                        particleEmitterLightning.blendState       = BlendState.Additive;
                        (particleEmitterLightning.collisionObjects.First() as Collision_BoundingCircle).Radius = 10;
                        (particleEmitterLightning.collisionObjects.First() as Collision_BoundingCircle).createDrawPoints();
                        particleEmitters.Add(particleEmitterLightning);

                        mAttacks.Add(LevelFunctions.DelayEnumerable <bool>(Attacks.LightningProjectile(target, currentCrystal, 5, 0, new TimeSpan(0, 0, 0, 5),
                                                                                                       int.MaxValue, 2.5f, true,
                                                                                                       delegate(OurSprite attacker, Vector2 direction, float projectileSpeed, ParticleEmitter particleEmitter)
                        {
                            Vector2 tangent = new Vector2(-direction.Y, direction.X);
                            for (int i = -5; i < 6; i++)
                            {
                                particleEmitter.createParticles(-direction * projectileSpeed * 5,
                                                                tangent * -i * 40,
                                                                particleEmitter.GroundPos + tangent * i * ParticleEmitter.EllipsePerspectiveModifier - direction * (Math.Abs(i) * 7),
                                                                4,
                                                                300);
                            }
                        },
                                                                                                       particleEmitterLightning,
                                                                                                       Vector2.Zero), delay).GetEnumerator());
                    }
                }
            }
        }