Example #1
0
        //Specialized Paths
        protected void DefensePath(ManagerHelper mH, Vector2 m)
        {
            float x = mH.GetRandom().Next(-100, 100);
            float y = mH.GetRandom().Next(-100, 100);

            mH.GetPathHelper().FindClearPath(GetOriginPosition(), m + new Vector2(x, y), mH, path);
        }
Example #2
0
        public void Set(Vector2 p, Vector2 v, float dT, float d, float t, float rA, ManagerHelper mH)
        {
            base.Set("Effects/particle_fire", p, v, dT, d, t, rA, mH);

            frameIndex = mH.GetRandom().Next(4);
            rotation   = (float)(mH.GetRandom().NextDouble() * Math.PI) * 2;
        }
Example #3
0
        public override void Update(ManagerHelper mH)
        {
            //Slow it to a stop
            if (velocity.Length() > 5)
            {
                Turn(((turnRight) ? -1 : 1) * MathHelper.Pi / 15 * (velocity.Length() / 64));

                //Spawn blood
                if (mH.GetRandom().Next(100) < 0)
                {
                    mH.GetParticleManager()
                    .AddFire(GetOriginPosition(),
                             PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 100, 2, 0.03f, 1, 1);
                }
            }
            else if (velocity.Length() != 0)
            {
                velocity *= 0;
            }

            //Prevent body parts from intersecting surroundings
            foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers())
            {
                int tempCollide = CollisionHelper.IntersectPixelsDirectional(this, e);
                if (tempCollide != -1)
                {
                    velocity = CollisionHelper.CollideDirectional(GetOriginPosition(), tempCollide) * velocity.Length() *
                               0.8f;
                }
            }

            base.Update(mH);
        }
Example #4
0
 protected override void Behavior(ManagerHelper mH)
 {
     if (mH.GetRandom().Next(100) == 0)
     {
         //Spawn lightning thing
         mH.GetParticleManager().AddParticle("Effects/spr_bolt_strip3", GetOriginPosition() +
                                             new Vector2(mH.GetRandom().Next(-16, 16), mH.GetRandom().Next(-16, 16)),
                                             Vector2.Zero, 0.05f, 0, 0, (float)MathHelper.Pi / 10);
     }
 }
Example #5
0
 protected virtual void EffectSpawnCode(ManagerHelper mH)
 {
     //Spawn bullet particles 15% of the time
     if (mH.GetRandom().Next(100) < 15)
     {
         mH.GetParticleManager()
         .AddParticle("Effects/particle_smoke", GetOriginPosition(),
                      PathHelper.Direction((float)(MathHelper.Pi * mH.GetRandom().NextDouble()) * 2) * 20, 4, 0.005f, 1,
                      0.1f);
     }
 }
Example #6
0
        public void Set(Vector2 p, NPC.AffliationTypes aT, ManagerHelper mH)
        {
            originPosition = p;
            position       = p - origin;
            affiliation    = aT;
            animateTimer   = 0;
            rotation       = (float)(Math.PI * 2 * mH.GetRandom().NextDouble());
            splash.SetOriginPosition(originPosition);
            splash.position = position;

            mH.GetAudioManager().Play(AudioManager.WATER, (float)mH.GetRandom().NextDouble() / 4 + 0.5f, AudioManager.RandomPitch(mH), 0, false);
        }
Example #7
0
        public override void Update(ManagerHelper mH)
        {
            if (movementPhase == MovementPhaseType.picking || movementPhase == MovementPhaseType.dropping)
            {
                if (timer > endTime)
                {
                    timer = 0;

                    if (mH.GetRandom().NextDouble() > 0.5f)
                    {
                        movementPhase = MovementPhaseType.turningLeft;
                    }
                    else
                    {
                        movementPhase = MovementPhaseType.turningRight;
                    }

                    do
                    {
                        endRotation = (float)(Math.PI * mH.GetRandom().Next(4) / 2);
                    } while (endRotation == rotation);
                }
                else
                {
                    timer += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                }
            }
            else
            {
                if (MathHelper.Distance(rotation, endRotation) > 0.01)
                {
                    Turn(((movementPhase == MovementPhaseType.turningLeft) ? -1.0f : 1.0f) * MathHelper.Pi / 240.0f);
                }
                else
                {
                    rotation = endRotation;
                    if (myBox == null)
                    {
                        movementPhase = MovementPhaseType.picking;
                    }
                    else
                    {
                        movementPhase = MovementPhaseType.dropping;
                    }
                }
            }

            base.Update(mH);
        }
Example #8
0
        public void AddBlood(NPC n)
        {
            string asset = "Effects/particle_blood_";

            if (n.GetType() == typeof(RedCommander) || n.GetType() == typeof(RedPlayerCommander))
            {
                asset += "red";
            }
            else if (n.GetType() == typeof(BlueCommander) || n.GetType() == typeof(BluePlayerCommander))
            {
                asset += "blue";
            }
            else if (n.GetType() == typeof(GreenCommander) || n.GetType() == typeof(GreenPlayerCommander))
            {
                asset += "green";
            }
            else if (n.GetType() == typeof(YellowCommander) || n.GetType() == typeof(YellowPlayerCommander))
            {
                asset += "yellow";
            }
            else
            {
                switch (n.GetAffiliation())
                {
                case NPC.AffliationTypes.red:
                    asset += "red";
                    break;

                case NPC.AffliationTypes.blue:
                    asset += "blue";
                    break;

                case NPC.AffliationTypes.green:
                    asset += "green";
                    break;

                case NPC.AffliationTypes.yellow:
                    asset += "yellow";
                    break;

                case NPC.AffliationTypes.black:
                    return;
                }
            }

            AddParticle(asset, n.GetOriginPosition(),
                        PathHelper.Direction((float)(managers.GetRandom().NextDouble() * MathHelper.TwoPi)) * 50, 2, 0.03f, 1, 2);
        }
Example #9
0
        public Vector2 Spawn(NPC.AffliationTypes a)
        {
            for (int i = 0; i < 50; i++)
            {
                int        x  = managers.GetRandom().Next(spawnPoints.Count);
                SpawnPoint sP = spawnPoints[x];

                if (sP.IsGoodSpawnPoint() && (a == sP.GetAffilation() || sP.GetAffilation() == NPC.AffliationTypes.grey))
                {
                    sP.Spawn();
                    return(sP.spawnPoint);
                }
            }

            return(LastPickSpawn(a));
        }
Example #10
0
        private void Spawn(ManagerHelper mH)
        {
            allies = mH.GetNPCManager().GetAllies(affiliation);
            int aT  = mH.GetRandom().Next(3, 6);
            var ass = (Assault)mH.GetGametype();

            if (spawnCounter > spawnTime && allies.Count < mH.GetGametype().GetPopCap())
            {
                if (aT != 3 && aT != 6)
                {
                    if (affiliation == ass.GetAttacker())
                    {
                        aT = 5;
                    }
                    else
                    {
                        aT = 4;
                    }
                }

                mH.GetGametype().Spawn(mH, affiliation, mH.GetSpawnHelper().Spawn(affiliation), aT);

                spawnCounter = 0;
            }
            else
            {
                spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
            }
        }
Example #11
0
 protected override void EffectSpawnCode(ManagerHelper mH)
 {
     if (mH.GetRandom().NextDouble() < 0.5f)
     {
         base.EffectSpawnCode(mH);
     }
 }
Example #12
0
        public override void Update(ManagerHelper mH)
        {
            frameIndex = mH.GetRandom().Next(totalFrames);

            if (mH.GetGametype() is Survival)
            {
                foreach (NPC a in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black))
                {
                    if (CollisionHelper.IntersectPixelsDirectional(a, this) != -1)
                    {
                        a.ChangeHealth(-1, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.yellow));
                    }
                }
            }

            else
            {
                foreach (NPC a in mH.GetNPCManager().GetNPCs())
                {
                    if (a.GetAffiliation() != affiliation && CollisionHelper.IntersectPixelsPoint(GetOriginPosition(), a) != new Vector2(-1))
                    {
                        a.ChangeHealth(-1, mH.GetNPCManager().GetCommander(NPC.AffliationTypes.yellow));
                    }
                }
            }

            lifeTimer -= mH.GetGameTime().ElapsedGameTime.TotalSeconds;

            base.Update(mH);
        }
Example #13
0
        public override void Update(ManagerHelper mH)
        {
            if (animate)
            {
                if (animationTimer > animationEnd)
                {
                    frameIndex++;
                    animationTimer = 0;

                    if (frameIndex >= totalFrames)
                    {
                        frameIndex = 0;
                        animate    = false;
                    }
                }
                else
                {
                    animationTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                }
            }
            else
            {
                animate = mH.GetRandom().Next(300) == 0;
            }

            base.Update(mH);
        }
Example #14
0
        private Vector2 FindOpenNodePoint(Vector2 e, ManagerHelper mH)
        {
            Vector2 tempEnd    = e,
                    tempNewEnd = e;

            while (field[(int)tempEnd.X, (int)tempEnd.Y].GetBlocker())
            {
                for (int x = -1; x < 2; x++)
                {
                    for (int y = -1; y < 2; y++)
                    {
                        if ((int)tempEnd.X + x < 0 || (int)tempEnd.X + x > length || tempEnd.Y + y < 0 ||
                            tempEnd.Y + y > width)
                        {
                            continue;
                        }

                        if (!field[(int)tempEnd.X + x, (int)tempEnd.Y + y].GetBlocker())
                        {
                            return(new Vector2((int)tempEnd.X + x, (int)tempEnd.Y + y));
                        }
                    }
                }

                do
                {
                    tempNewEnd = new Vector2((mH.GetRandom().NextDouble() > 0.5) ? -1 : 1, mH.GetRandom().Next(-1, 1)) +
                                 tempEnd;
                } while (tempNewEnd.X < 0 || tempNewEnd.X > length || tempNewEnd.Y < 0 || tempNewEnd.Y > width);

                tempEnd = tempNewEnd;
            }

            return(e);
        }
Example #15
0
        public override void Update(ManagerHelper mH)
        {
            if (isExplosive && drawTime <= 0)
            {
                mH.GetParticleManager().AddExplosion(GetOriginPosition(), this.creator, damage);
                isExplosive = false;
            }

            if (position.X < 0 || position.X > mH.GetLevelSize().X ||
                position.Y < 0 || position.Y > mH.GetLevelSize().Y)
            {
                SetDrawTime(0);
            }

            if (drawTime > 0)
            {
                drawTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds;

                SpriteUpdate(mH);

                //Spawn cool things to make it look better
                if (mH.GetRandom().NextDouble() < 0.5f)
                {
                    EffectSpawnCode(mH);
                }
            }

            existenceTime -= mH.GetGameTime().ElapsedGameTime.TotalSeconds;
        }
Example #16
0
        public override void Update(ManagerHelper mH)
        {
            if (timer > endTime)
            {
                timer = 0;

                for (int i = 0; i < belts.Length; i++)
                {
                    belts[i].SetFrameIndex(belts[i].GetFrameIndex() + 1);
                    belts[i].SetModeIndex(belts[i].GetModeIndex() + 1);

                    if (belts[i].GetFrameIndex() == belts[i].totalFrames)
                    {
                        belts[i].SetFrameIndex(0);
                    }

                    if (belts[i].GetModeIndex() == belts[i].totalModes)
                    {
                        belts[i].SetModeIndex(0);
                    }

                    foreach (NPC a in mH.GetNPCManager().GetNPCs())
                    {
                        int tempCollide = CollisionHelper.IntersectPixelsDirectional(a, belts[i]);

                        if (tempCollide != -1)
                        {
                            a.AddAcceleration(directions[i] * 2);
                        }
                    }

                    belts[i].Update(mH);
                }

                if (mH.GetRandom().NextDouble() > 0.993)
                {
                    mH.GetEnvironmentManager()
                    .AddStaticBlocker(new SwitchBox(boxNodes[(mH.GetRandom().Next(2) == 0) ? 0 : 11].pos, this,
                                                    theCrane));
                }
            }
            else
            {
                timer += (mH.GetGameTime().ElapsedGameTime.TotalSeconds);
            }
        }
Example #17
0
            public Vector2 GetRandomDir(ManagerHelper mH)
            {
                if (dirs.Count == 0)
                {
                    return(Vector2.Zero);
                }

                return(dirs[mH.GetRandom().Next(dirs.Count)]);
            }
Example #18
0
        public void Set(Vector2 p, float r, NPC.AffliationTypes aT, ManagerHelper mH)
        {
            affiliation = aT;
            rotation    = r;
            position    = p;

            lifeTimer = 2;

            mH.GetAudioManager().Play(AudioManager.SPARK, (float)mH.GetRandom().NextDouble() / 4 + 0.5f, AudioManager.RandomPitch(mH), 0, false);
        }
Example #19
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);
        }
Example #20
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);
        }
Example #21
0
        public void Set(Vector2 p, Vector2 direction, NPC.AffliationTypes aT, ManagerHelper mH)
        {
            frameCounter = 0;
            scale        = 1;
            doomedDots.Clear();
            dotsSetOnFire.Clear();
            affiliation    = aT;
            frameIndex     = 0;
            originPosition = p;
            position       = p - origin;
            velocity       = new Vector2(300 * direction.X, 300 * direction.Y);

            mH.GetAudioManager().Play(AudioManager.FIREBALL, (float)mH.GetRandom().NextDouble() / 4 + 0.75f, AudioManager.RandomPitch(mH), 0, false);
        }
Example #22
0
        public void Update(ManagerHelper mH)
        {
            for (int i = 0; i < cameras.Count; i++)
            {
                if (pauser == null)
                {
                    var commander = (Commander)mH.GetNPCManager().GetCommander(cameras[i].commanderType);
                    if (commander != null)
                    {
                        Vector2 newPlace = Vector2.Lerp(new Vector2(cameras[i].dimensions.X, cameras[i].dimensions.Y),
                                                        commander.GetOriginPosition() +
                                                        ((rumbleAmount[i] != 0)
                                                             ? new Vector2(
                                                             ((float)mH.GetRandom().NextDouble() * rumbleAmount[i]) -
                                                             (rumbleAmount[i] / 2),
                                                             ((float)mH.GetRandom().NextDouble() * rumbleAmount[i]) -
                                                             (rumbleAmount[i] / 2))
                                                             : Vector2.Zero), 0.05f);

                        cameras[i].dimensions.X = (int)newPlace.X;
                        cameras[i].dimensions.Y = (int)newPlace.Y;

                        huds[i].Update(mH, commander);
                    }
                }

                if (cameras[i].GetState().IsButtonDown(Buttons.Start) && !cameras[i].GetOldState().IsButtonDown(Buttons.Start) ||
                    cameras[i].GetState().IsButtonDown(Buttons.BigButton) && !cameras[i].GetState().IsButtonDown(Buttons.BigButton) && pauser == null)
                {
                    SetPause(cameras[i].GetCommanderType(), mH);
                    pauserIndex = i;
                }
            }

            //Reset rumble amounts
            ResetAllRumble();
        }
Example #23
0
        protected void RandomPath(ManagerHelper mH)
        {
            bool    validPoint;
            Vector2 randPoint;

            pathTimerEnd = 10;

            do
            {
                validPoint = true;
                randPoint  = new Vector2(mH.GetRandom().Next((int)mH.GetLevelSize().X),
                                         mH.GetRandom().Next((int)mH.GetLevelSize().Y)) / mH.GetPathHelper().GetNodeSize();

                foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers())
                {
                    foreach (Vector2 n in e.GetFrameBlockers())
                    {
                        if (n.Equals(randPoint))
                        {
                            validPoint = false;
                            break;
                        }
                        else
                        {
                            validPoint = true;
                        }
                    }

                    if (!validPoint)
                    {
                        break;
                    }
                }
            } while (!validPoint);

            mH.GetPathHelper().FindClearPath(GetOriginPosition(), randPoint * 32, mH, path);
        }
Example #24
0
        public override void Update(ManagerHelper mH)
        {
            foreach (NPC a in mH.GetNPCManager().GetNPCs())
            {
                if (CollisionHelper.IntersectPixelsDirectional(a, this) != -1)
                {
                    if (a.GetAffiliation() == affiliation)
                    {
                        if (mH.GetRandom().Next(40) == 0)
                        {
                            a.ChangeHealth(10, NPC.AffliationTypes.same);
                            mH.GetParticleManager().AddHeal(a);
                        }
                    }
                    else
                    {
                        a.AddAcceleration(a.velocity * new Vector2(-0.003f));
                    }
                }
            }

            //Animations
            if (animateTimer < animateEnd)
            {
                frameIndex = (int)(animateTimer / animateEnd * totalFrames);
            }
            if (animateTimer < splashEnd)
            {
                splash.SetFrameIndex((int)(animateTimer / splashEnd * splash.totalFrames));
            }
            animateTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds +
                            (mH.GetRandom().NextDouble() / 1000);

            //Base Updates
            splash.Update(mH);
            base.Update(mH);
        }
Example #25
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);
        }
Example #26
0
        public override void Update(ManagerHelper mH)
        {
            foreach (var agent in mH.GetNPCManager().GetNPCs())
            {
                if (CollisionHelper.IntersectPixelsPoint(agent.GetOriginPosition(), this) != new Vector2(-1))
                {
                    agent.ChangeHealth(-2, null);

                    mH.GetParticleManager()
                    .AddFire(agent.GetOriginPosition(),
                             PathHelper.Direction((float)(mH.GetRandom().NextDouble() * Math.PI * 2)) * 100, 1, 0.05f, 1,
                             0.1f);
                }
            }

            base.Update(mH);
        }
Example #27
0
        private void Spawn(ManagerHelper mH)
        {
            allies = mH.GetNPCManager().GetAllies(affiliation);

            if (spawnCounter > spawnTime && allies.Count < mH.GetGametype().GetPopCap())
            {
                mH.GetGametype()
                .Spawn(mH, affiliation, mH.GetSpawnHelper().Spawn(affiliation), mH.GetRandom().Next(6, 9));

                spawnCounter = 0;
            }

            else
            {
                spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
            }
        }
Example #28
0
        public override void Update(ManagerHelper mH)
        {
            foreach (Sprite section in poolSections)
            {
                section.Turn(10000.0f / (section.GetFrame().Width *section.GetFrame().Width) * mH.GetDeltaSeconds());
            }

            foreach (NPC a in mH.GetNPCManager().GetNPCs())
            {
                if (!(a is Bomber))
                {
                    float tempDistance = PathHelper.DistanceSquared(GetOriginPosition(), a.GetOriginPosition());

                    if (tempDistance < 15 * 15)
                    {
                        //TODO: Modify
                        a.position = mH.GetLevelSize() * new Vector2(mH.GetRandom().Next(2), mH.GetRandom().Next(2));
                    }
                    else if (tempDistance < frame.Width / 2 * frame.Width / 2)
                    {
                        float tempRot = PathHelper.Direction(a.GetOriginPosition(), GetOriginPosition()) -
                                        MathHelper.Pi / 9;
                        a.AddAcceleration(new Vector2(DWMath.Cos(tempRot), DWMath.Sin(tempRot)) * 4);
                    }
                }
            }

            foreach (Particle e in mH.GetParticleManager().GetParticles())
            {
                float tempDistance = PathHelper.DistanceSquared(GetOriginPosition(), e.GetOriginPosition());

                if (tempDistance < 15 * 15)
                {
                    e.SetDrawTime(0);
                }
                else if (tempDistance < (frame.Width / 2) * (frame.Width / 2))
                {
                    float tempRot = PathHelper.Direction(e.GetOriginPosition(), GetOriginPosition()) + MathHelper.Pi / 9;
                    e.AddAcceleration(new Vector2((float)DWMath.Cos(tempRot), (float)DWMath.Sin(tempRot)) * 100);
                }
            }

            base.Update(mH);
        }
Example #29
0
        public void Set(Vector2 p, NPC.AffliationTypes aT, ManagerHelper mH)
        {
            position = p;

            animateTime = 0.3f;
            timer       = 0;

            health = 150;

            affiliation = aT;

            LoadContent(mH.GetTextureManager());

            mH.GetAudioManager().Play(AudioManager.LARGE_ROCK, (float)mH.GetRandom().NextDouble() / 4 + 0.75f, AudioManager.RandomPitch(mH), 0, false);

            for (int i = 0; i < 10; i++)
            {
                mH.GetParticleManager().AddStandardSmoke(origin + position, 64);
            }
        }
Example #30
0
        protected void HoverPath(ManagerHelper mH, Vector2 p, int r)
        {
            bool    validPoint;
            Vector2 randPoint;
            Vector2 originNode = GetOriginPosition() / mH.GetPathHelper().GetNodeSize();

            do
            {
                validPoint = true;
                randPoint  = originNode + new Vector2(mH.GetRandom().Next(-1 * r / 32, r / 32), mH.GetRandom().Next(-1 * r / 32, r / 32));

                if ((randPoint.X > 0 && randPoint.X < mH.GetLevelSize().X / 32) &&
                    (randPoint.Y > 0 && randPoint.Y < mH.GetLevelSize().Y / 32))
                {
                    foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers())
                    {
                        foreach (Vector2 n in e.GetFrameBlockers())
                        {
                            if ((n.X + (int)e.GetOriginPosition().X) == randPoint.X &&
                                (n.Y + (int)e.GetOriginPosition().Y) == randPoint.Y)
                            {
                                validPoint = false;
                                break;
                            }
                        }

                        if (!validPoint)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    validPoint = false;
                }
            } while (!validPoint);

            mH.GetPathHelper().FindClearPath(GetOriginPosition(), randPoint * 32, mH, path);
        }