Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }