示例#1
0
        public virtual bool ProjectileCheck(ManagerHelper mH)
        {
            if (health <= 0)
            {
                mH.GetEnvironmentManager().RemoveStaticBlocker(this);
                return(true);
            }

            Queue <Projectile> tempProjectiles = mH.GetProjectileManager().GetProjectiles();

            foreach (Projectile p in tempProjectiles)
            {
                if (CollisionHelper.IntersectPixelsPoint(p.GetOriginPosition(), this) != new Vector2(-1) && p.GetDrawTime() > 0)
                {
                    health -= p.GetDamage();
                    p.SetDrawTime(0f);

                    if (health <= 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#2
0
        public override void Update(ManagerHelper mH)
        {
            Queue <Projectile> tempProjectiles = mH.GetProjectileManager().GetProjectiles();

            foreach (Projectile p in tempProjectiles)
            {
                if (p.GetDrawTime() > 0 &&
                    CollisionHelper.IntersectPixelsPoint(p.GetOriginPosition(), this) != new Vector2(-1))
                {
                    health     -= p.GetDamage();
                    lastDamager = p.GetCreator();

                    p.SetDrawTime(0);
                }
            }

            if (timer < animateTime)
            {
                frameIndex = (int)(timer / animateTime * 12);
                float frameModifier = ((frameIndex + 1) * 6);

                if (mH.GetGametype() is Survival)
                {
                    foreach (NPC a in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black))
                    {
                        float distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), a.GetOriginPosition());

                        if (distanceToAgent < frameModifier * frameModifier)
                        {
                            a.AddAcceleration(PathHelper.DirectionVector(GetOriginPosition(), a.GetOriginPosition()) * 10);

                            a.ChangeHealth(-1 * DAMAGE, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.green));
                        }
                    }
                }
                else
                {
                    foreach (NPC a in mH.GetNPCManager().GetNPCs())
                    {
                        if (a.GetAffiliation() != affiliation)
                        {
                            var distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), a.GetOriginPosition());

                            if (distanceToAgent < frameModifier * frameModifier)
                            {
                                a.AddAcceleration(PathHelper.DirectionVector(GetOriginPosition(), a.GetOriginPosition()) * 10);

                                a.ChangeHealth(-1 * DAMAGE, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.green));
                            }
                        }
                    }
                }

                timer += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
            }

            base.Update(mH);
        }
示例#3
0
        protected override bool ProjectileCheck(ManagerHelper mH)
        {
            if (health <= 0)
            {
                return(true);
            }

            else
            {
                foreach (Projectile p in mH.GetProjectileManager().GetProjectiles())
                {
                    if (p.GetDrawTime() > 0 && p.GetAffiliation() != affiliation &&
                        CollisionHelper.IntersectPixelsSimple(this, p) != new Vector2(-1))
                    {
                        lastDamagerDirection = PathHelper.DirectionVector(GetOriginPosition(), p.GetOriginPosition());
                        counter = 0;

                        float test = p.GetRotation() + MathHelper.Pi;
                        if (test > MathHelper.TwoPi)
                        {
                            test -= MathHelper.TwoPi;
                        }

                        if (MathHelper.Distance(test, rotation) > (MathHelper.Pi * 5 / 6))
                        {
                            ChangeHealth(-1 * p.GetDamage(), p.GetCreator());
                            mH.GetParticleManager().AddBlood(this);

                            if (health <= 0)
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            Vector2 knockback = new Vector2((float)(p.velocity.X * .05), (float)(p.velocity.Y * .05));
                            accelerations.Add(knockback);
                            mH.GetAudioManager().Play(AudioManager.JUGGERNAUT_RICOHET, (float).05, 0, 0, false);
                        }

                        p.SetDrawTime(0);
                    }

                    else
                    {
                        counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                    }

                    if (counter > 2)
                    {
                        counter = 0;
                        lastDamagerDirection = Vector2.Zero;
                    }
                }
            }

            return(false);
        }
示例#4
0
 private void Bomb(ManagerHelper mH)
 {
     for (int i = 0; i < NUM_BOMBS; i++)
     {
         mH.GetProjectileManager()
         .AddProjectile(ProjectileManager.BOMB, GetOriginPosition(), this,
                        PathHelper.Direction(rotation) * 500, 50, true, false, 0.5f);
     }
 }
示例#5
0
        protected void TossGrenade(ManagerHelper mH)
        {
            Vector2 tempPos = PathHelper.Direction(rotation + MathHelper.PiOver2) * new Vector2(10);

            mH.GetProjectileManager()
            .AddTossable(ProjectileManager.GRENADE, GetOriginPosition() + tempPos, this,
                         PathHelper.Direction(rotation) * 500, 100, true, 1.5f);

            GrenadeSound(mH);
        }
示例#6
0
        protected override void Shoot(ManagerHelper mH)
        {
            Vector2 tempPos = PathHelper.Direction(rotation + MathHelper.PiOver2) * new Vector2(10);

            mH.GetProjectileManager()
            .AddProjectile(ProjectileManager.STANDARD, GetOriginPosition() + tempPos, this,
                           PathHelper.Direction(rotation + (float)mH.GetRandom().NextDouble() / 8 - 0.0625f) * 400, 15,
                           false, true, 1.3f);

            ShootSound(mH);
        }
示例#7
0
        protected override void Shoot(ManagerHelper mH)
        {
            Vector2 tempPos = PathHelper.Direction(rotation + MathHelper.PiOver2) * new Vector2(10);

            mH.GetProjectileManager()
            .AddProjectile(ProjectileManager.ROCKET, GetOriginPosition() + tempPos, this,
                           PathHelper.Direction(rotation) * 300, 100, true, true, 5);

            mH.GetAudioManager().Play(AudioManager.SPECIALIST_SHOOT, AudioManager.RandomVolume(mH),
                                      AudioManager.RandomPitch(mH), 0, false);
        }
示例#8
0
        protected virtual void Shoot(ManagerHelper mH)
        {
            Vector2 tempPos = PathHelper.Direction(rotation + MathHelper.PiOver2) * new Vector2(10);

            mH.GetProjectileManager()
            .AddProjectile(ProjectileManager.STANDARD, GetOriginPosition() + tempPos, this,
                           PathHelper.Direction(rotation + (float)mH.GetRandom().NextDouble() / 8 - 0.0625f) * 400, 25,
                           false, true, 5);

            mH.GetAudioManager().Play(AudioManager.STANDARD_SHOOT, AudioManager.RandomVolume(mH),
                                      AudioManager.RandomPitch(mH), 0, false);
        }
示例#9
0
        public virtual bool ProjectileCheck(ManagerHelper mH)
        {
            foreach (Projectile p in mH.GetProjectileManager().GetProjectiles())
            {
                if (p.GetDrawTime() > 0 &&
                    CollisionHelper.IntersectPixelsPoint(p.GetOriginPosition(), this) != new Vector2(-1) &&
                    p.GetIfShouldCollide())
                {
                    p.SetDrawTime(0);
                }
            }

            return(false);
        }
示例#10
0
        protected void ShootShotgun(ManagerHelper mH)
        {
            Vector2 tempPos = PathHelper.Direction(rotation + MathHelper.PiOver2) * new Vector2(10);

            //7 Shots
            for (int s = 0; s < 7; s++)
            {
                mH.GetProjectileManager()
                .AddProjectile(ProjectileManager.SHOTGUN, GetOriginPosition() + tempPos, this,
                               PathHelper.Direction(rotation + (float)mH.GetRandom().NextDouble() / 4 - 0.125f) * 500, 18,
                               false, true, 0.5f);
            }

            ShotgunSound(mH);
        }
示例#11
0
        protected virtual bool ProjectileCheck(ManagerHelper mH)
        {
            if (health <= 0)
            {
                return(true);
            }

            if (mH.GetGametype() is Survival && affiliation != AffliationTypes.black)
            {
                return(false);
            }
            else
            {
                foreach (Projectile p in mH.GetProjectileManager().GetProjectiles())
                {
                    if (p.GetDrawTime() > 0 && p.GetAffiliation() != affiliation &&
                        CollisionHelper.IntersectPixelsSimple(this, p) != new Vector2(-1))
                    {
                        lastDamagerDirection = PathHelper.DirectionVector(GetOriginPosition(), p.GetOriginPosition());
                        ChangeHealth(-1 * p.GetDamage(), p.GetCreator());
                        mH.GetParticleManager().AddBlood(this);
                        counter = 0;

                        if (health <= 0)
                        {
                            return(true);
                        }

                        p.SetDrawTime(0);
                    }

                    else
                    {
                        counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                    }

                    if (counter > 2)
                    {
                        counter = 0;
                        lastDamagerDirection = Vector2.Zero;
                    }
                }
            }

            return(false);
        }
示例#12
0
        protected void LayMine(ManagerHelper mH)
        {
            mH.GetProjectileManager().AddMine(this);

            MineSound(mH);
        }