예제 #1
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);
        }
예제 #2
0
        protected override NPC TargetDecider(ManagerHelper mH)
        {
            NPC   closest         = null;
            float closestDistance = float.PositiveInfinity;

            foreach (var affliationType in mH.GetGametype().GetTeams())
            {
                if (affliationType != affiliation)
                {
                    NPC closestForTeam =
                        mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(affliationType), this);

                    if (closestForTeam != null)
                    {
                        float closestDistanceForTeam = PathHelper.DistanceSquared(GetOriginPosition(),
                                                                                  closestForTeam.GetOriginPosition());

                        if (closestDistanceForTeam < closestDistance)
                        {
                            closest         = closestForTeam;
                            closestDistance = closestDistanceForTeam;
                        }
                    }
                }
            }

            return(closest);
        }
예제 #3
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);
        }
예제 #4
0
        public override void Update(ManagerHelper mH)
        {
            //if black dont work
            if (affilation == NPC.AffliationTypes.black)
            {
                spawnTime    = 10000;
                spawnCounter = 0;
            }

            else if (isOneUse && !isUsed)
            {
                spawnTime = 8;
                NPCManager temp = mH.GetNPCManager();

                if (spawnCounter > spawnTime)
                {
                    isGoodSpawnPoint = true;

                    foreach (var agent in mH.GetNPCManager().GetNPCs())
                    {
                        if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, spawnPoint, 100))
                        {
                            isGoodSpawnPoint = false;
                        }
                    }
                }
                else
                {
                    spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                }
            }

            else if (!isUsed)
            {
                spawnTime = 8;

                NPCManager temp = mH.GetNPCManager();

                if (spawnCounter > spawnTime)
                {
                    isGoodSpawnPoint = true;

                    foreach (var agent in mH.GetNPCManager().GetNPCs())
                    {
                        if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, spawnPoint, 100))
                        {
                            isGoodSpawnPoint = false;
                        }
                    }
                }
                else
                {
                    spawnCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                }
            }
        }
예제 #5
0
 public virtual void SpawnCommander(ManagerHelper mH, Type commanderType, NPC.AffliationTypes team, Vector2 point)
 {
     if (commanderType == typeof(RedCommander))
     {
         mH.GetNPCManager().Add(new RedCommander(point, team));
     }
     else if (commanderType == typeof(BlueCommander))
     {
         mH.GetNPCManager().Add(new BlueCommander(point, team));
     }
     else if (commanderType == typeof(GreenCommander))
     {
         mH.GetNPCManager().Add(new GreenCommander(point, team));
     }
     else if (commanderType == typeof(YellowCommander))
     {
         mH.GetNPCManager().Add(new YellowCommander(point, team));
     }
     else if (commanderType == typeof(RedPlayerCommander))
     {
         mH.GetNPCManager().Add(new RedPlayerCommander(point, team, mH));
     }
     else if (commanderType == typeof(BluePlayerCommander))
     {
         mH.GetNPCManager().Add(new BluePlayerCommander(point, team, mH));
     }
     else if (commanderType == typeof(GreenPlayerCommander))
     {
         mH.GetNPCManager().Add(new GreenPlayerCommander(point, team, mH));
     }
     else if (commanderType == typeof(YellowPlayerCommander))
     {
         mH.GetNPCManager().Add(new YellowPlayerCommander(point, team, mH));
     }
 }
예제 #6
0
 public void Update(ManagerHelper mH)
 {
     medicKills           = mH.GetNPCManager().GetMedicKills();
     flagsCaptured        = mH.GetGametype().GetFlagsCaptured();
     flagsReturned        = mH.GetGametype().GetFlagsReturned();
     rocksCreatedCounter += (mH.GetNPCManager().GetSpecificCommander(NPC.AffliationTypes.green) != null) ?
                            mH.GetNPCManager().GetSpecificCommander(NPC.AffliationTypes.green).GetPowerStatistic() : 0;
     rocksDestroyed            = mH.GetAbilityManager().GetRocksDestroyedByCommanders();
     waterSpilledCounter       = mH.GetAbilityManager().GetWaterSpilledCounter();
     dotsRecruited             = mH.GetGametype().GetDotsRecruited();
     lightningTravelledCounter = mH.GetAbilityManager().GetLightningTravelledCounter();
     mostTimeFlagAway          = mH.GetGametype().GetMostTimeFlagAway();
     quickestFlagCapture       = mH.GetGametype().GetQuickestFlagCapture();
     dotsSetOnFireCounter      = mH.GetAbilityManager().GetDotsSetOnFireCounter();
 }
예제 #7
0
        protected virtual NPC TargetDecider(ManagerHelper mH)
        {
            if (mH.GetGametype() is Survival)
            {
                NPC   closest         = null;
                float closestDistance = float.PositiveInfinity;

                foreach (var suicide in mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black))
                {
                    if (NPCManager.IsNPCInRadius(suicide, GetOriginPosition(), sight) &&
                        NPCManager.IsNPCInDirection(suicide, GetOriginPosition(), rotation, vision, mH))
                    {
                        float distanceToSuicide = PathHelper.DistanceSquared(GetOriginPosition(), suicide.GetOriginPosition());

                        if (distanceToSuicide < closestDistance)
                        {
                            closestDistance = distanceToSuicide;
                            closest         = suicide;
                        }
                    }
                }

                return(closest);
            }
            else
            {
                NPC   closest         = null;
                float closestDistance = float.PositiveInfinity;

                foreach (var agent in mH.GetNPCManager().GetNPCs())
                {
                    if (agent.GetAffiliation() != affiliation &&
                        NPCManager.IsNPCInRadius(agent, GetOriginPosition(), sight) &&
                        NPCManager.IsNPCInDirection(agent, GetOriginPosition(), rotation, vision, mH))
                    {
                        float distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition());

                        if (distanceToAgent < closestDistance)
                        {
                            closestDistance = distanceToAgent;
                            closest         = agent;
                        }
                    }
                }

                return(closest);
            }
        }
예제 #8
0
        protected override void SpecialPath(ManagerHelper mH)
        {
            //do i have friends
            NPC friend = mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(affiliation), this);

            if (friend != null)
            {
                float closestDistancetoTarget = float.PositiveInfinity;
                target = null;

                foreach (var team in mH.GetGametype().GetTeams())
                {
                    if (team != affiliation)
                    {
                        NPC closestTargetForTeam = mH.GetNPCManager()
                                                   .GetClosestInList(mH.GetNPCManager().GetAllies(team),
                                                                     friend.GetOriginPosition());

                        if (closestTargetForTeam != null)
                        {
                            float closestDiestanceToTargetForTeam = PathHelper.DistanceSquared(
                                closestTargetForTeam.GetOriginPosition(), friend.GetOriginPosition());

                            if (closestDiestanceToTargetForTeam < closestDistancetoTarget)
                            {
                                target = closestTargetForTeam;
                                closestDistancetoTarget = closestDiestanceToTargetForTeam;
                            }
                        }
                    }
                }
            }
            Vector2 destination;

            //if so
            if (friend != null && target != null)
            {
                //we can now get a midpoint
                destination = PathHelper.MidPoint(friend.GetOriginPosition(), target.GetOriginPosition());
                //and wedge ourselves in
                mH.GetPathHelper().FindClearPath(GetOriginPosition(), destination, mH, path);
            }
            //else, we shall wander the planes between heaven and hell
            else
            {
                RandomPath(mH);
            }
        }
예제 #9
0
        public void Intitialize(ManagerHelper mH)
        {
            //kd stuff
            medicKills     = 0;
            flagsCaptured  = new Dictionary <NPC.AffliationTypes, int>();
            flagsReturned  = new Dictionary <NPC.AffliationTypes, int>();
            rocksDestroyed = new Dictionary <NPC.AffliationTypes, int>();
            dotsRecruited  = new Dictionary <NPC.AffliationTypes, int>();

            killsToCommanders         = new int[4, 4];
            vendittaKills             = 0;
            vendittaKiller            = NPC.AffliationTypes.black;
            vendittaVictim            = NPC.AffliationTypes.black;
            rocksCreatedCounter       = 0;
            waterSpilledCounter       = 0;
            lightningTravelledCounter = 0;
            foreach (NPC.AffliationTypes a in affilations)
            {
                flagsCaptured.Add(a, 0);
                flagsReturned.Add(a, 0);
                rocksDestroyed.Add(a, 0);
                dotsRecruited.Add(a, 0);

                stats.Add(a, mH.GetNPCManager().GetStats(a));
            }
        }
예제 #10
0
        public Vector2 SpawnSucideDots()
        {
            int  spawnPick;
            bool proceed = false;
            int  counter = 0;

            do
            {
                spawnPick = managers.GetRandom().Next(0, suicideSpawnPoints.Count);
                counter++;

                List <NPC> suicides     = managers.GetNPCManager().GetAllies(NPC.AffliationTypes.black);
                int        suicideCount = 0;

                foreach (NPC suicide in suicides)
                {
                    if (NPCManager.IsNPCInRadius(suicide, suicideSpawnPoints[spawnPick].GetOriginPosition(), 60))
                    {
                        suicideCount++;
                    }

                    if (suicideCount >= 1)
                    {
                        break;
                    }
                }

                if (suicideCount < 1)
                {
                    proceed = true;
                }
            } while (!proceed && counter < 240);

            return(suicideSpawnPoints[spawnPick].GetOriginPosition());
        }
예제 #11
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;
            }
        }
예제 #12
0
            public void Draw(SpriteBatch sB, ManagerHelper mH)
            {
                if (shouldDrawScores)
                {
                    DrawScores(sB, mH);
                }

                NPC commander = mH.GetNPCManager().GetCommander(myCamera.commanderType);

                if (commander != null)
                {
                    back.Draw(sB, Vector2.Zero, null);
                    power.Draw(sB, Vector2.Zero, null);
                    damage.Draw(sB, Vector2.Zero, null);
                    health.Draw(sB, Vector2.Zero, null);
                    front.Draw(sB, Vector2.Zero, null);
                    gun.Draw(sB, Vector2.Zero, null);
                    toss.Draw(sB, Vector2.Zero, null);

                    if (myCamera.GetTeammateColor() != NPC.AffliationTypes.grey)
                    {
                        teammate.Draw(sB, Vector2.Zero, null);
                    }
                }
            }
예제 #13
0
        //This method will be used to dictate the AI's behavior in this public class
        public override void Update(ManagerHelper mH)
        {
            double distanceToTarget = PathHelper.DistanceSquared(GetOriginPosition(), targetPosition);

            if (distanceToTarget < 300 * 300 && !hasBombed)
            {
                Bomb(mH);
                hasBombed = true;
            }

            if (distanceToTarget < 50 * 50)
            {
                drawTarget = false;
            }

            //remove thyself
            if (position.X < -200 || position.X > mH.GetLevelSize().X + 200 || position.Y < -200 ||
                position.Y > mH.GetLevelSize().Y + 200)
            {
                mH.GetNPCManager().Remove(this);
            }

            var newTargetSpriteIndex =
                (int)
                (targetSprite.GetTotalFrames() *
                 Math.Max(0,
                          Math.Min(1000 * 1000, 1000 * 1000 - PathHelper.DistanceSquared(GetOriginPosition(), targetPosition))) /
                 1000 * 1000);

            targetSprite.SetFrameIndex(newTargetSpriteIndex);

            SpriteUpdate(mH);
            targetSprite.Update(mH);
        }
예제 #14
0
        protected override void NewPath(ManagerHelper mH)
        {
            NPC   tempEnemy        = null;
            float shortestDistance = float.PositiveInfinity;

            foreach (var agent in mH.GetNPCManager().GetNPCs())
            {
                if (agent.GetAffiliation() != affiliation)
                {
                    float distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition());

                    if (distanceToAgent < shortestDistance)
                    {
                        shortestDistance = distanceToAgent;
                        tempEnemy        = agent;
                    }
                }
            }

            Vector2 closetRockPosition = FindClosestRock(mH);

            if (closetRockPosition != new Vector2(-1, -1))
            {
                mH.GetPathHelper().FindClearPath(GetOriginPosition(), closetRockPosition, mH, path);
            }
            else if (tempEnemy != null)
            {
                mH.GetPathHelper().FindClearPath(GetOriginPosition(), tempEnemy.GetOriginPosition(), mH, path);
            }
            else
            {
                RandomPath(mH);
            }
        }
예제 #15
0
        protected override void NewPath(ManagerHelper mH)
        {
            List <Vector2> sniperSpots = mH.GetLevel().GetSniperSpots();
            Vector2        endPoint    = GetOriginPosition();

            foreach (Vector2 v in sniperSpots)
            {
                bool validPoint = true;

                foreach (NPC agent in mH.GetNPCManager().GetNPCs())
                {
                    if (agent.GetAffiliation() != affiliation &&
                        NPCManager.IsNPCInRadius(agent, GetOriginPosition(), 200))
                    {
                        validPoint = false;
                        break;
                    }
                }

                if (validPoint)
                {
                    endPoint = v;
                    break;
                }
            }

            mH.GetPathHelper().FindClearPath(GetOriginPosition(), endPoint, mH, path);
        }
예제 #16
0
 protected override void Shoot(ManagerHelper mH)
 {
     mH.GetNPCManager().Add(new Bomber(BomberOrigin(mH), affiliation, target, mH));
     calledIn = 0;
     mH.GetAudioManager().Play(AudioManager.STATIC, AudioManager.RandomVolume(mH),
                               AudioManager.RandomPitch(mH), 0, false);
 }
예제 #17
0
        protected void EngagePath(ManagerHelper mH)
        {
            NPC tempEnemy;

            if (mH.GetGametype() is Survival)
            {
                tempEnemy = target ?? mH.GetNPCManager()
                            .GetClosestInList(mH.GetNPCManager().GetAllies(AffliationTypes.black), this);
            }
            else
            {
                NPC   tempClosestEnemy    = null;
                float tempClosestDistance = float.PositiveInfinity;

                foreach (var agent in mH.GetNPCManager().GetNPCs())
                {
                    if (agent.GetAffiliation() != affiliation)
                    {
                        float distaceToEnemy = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition());

                        if (distaceToEnemy < tempClosestDistance)
                        {
                            tempClosestDistance = distaceToEnemy;
                            tempClosestEnemy    = agent;
                        }
                    }
                }

                tempEnemy = target != null ? target : tempClosestEnemy;
            }

            if (tempEnemy != null)
            {
                if (PathHelper.DistanceSquared(GetOriginPosition(), tempEnemy.GetOriginPosition()) > 128 * 128)
                {
                    mH.GetPathHelper().FindClearPath(GetOriginPosition(), tempEnemy.GetOriginPosition(), mH, path);
                }
                else
                {
                    HoverPath(mH, GetOriginPosition(), 64);
                }
            }
            else
            {
                RandomPath(mH);
            }
        }
예제 #18
0
        public override bool Update(ManagerHelper mH)
        {
            if (GetIfAllPlayersAreDead(mH) && redCommanderHasSpawned)
            {
                gameEndTimer = -1;
            }

            if ((int)gameEndTimer % 30 == 0)
            {
                if (!hasAppliedModifier)
                {
                    survivalPointModifier++;
                    suicideSpawnModifier++;
                    UpdateScoreSurvival(mH);

                    hasAppliedModifier = true;
                }
            }
            else
            {
                hasAppliedModifier = false;
            }

            #region Spawns

            if (mH.GetNPCManager().GetAllies(NPC.AffliationTypes.black).Count <= NUM_SUICIDES && counter > spawnSecs)
            {
                mH.GetNPCManager().Add(new Suicide(mH.GetSpawnHelper().SpawnSucideDots(), mH));

                counter    = 0;
                spawnSecs -= mH.GetGameTime().ElapsedGameTime.TotalSeconds;
            }

            //Update spent time
            counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;

            #endregion

            foreach (Claimable c in claimables)
            {
                c.Update(mH);
            }

            return(base.Update(mH));
        }
예제 #19
0
 private void UpdateScoreSurvival(ManagerHelper mH)
 {
     if (mH.GetNPCManager().GetCommander(NPC.AffliationTypes.red) != null)
     {
         scores[0] += 10 * survivalPointModifier;
     }
     if (mH.GetNPCManager().GetCommander(NPC.AffliationTypes.blue) != null)
     {
         scores[1] += 10 * survivalPointModifier;
     }
     if (mH.GetNPCManager().GetCommander(NPC.AffliationTypes.green) != null)
     {
         scores[2] += 10 * survivalPointModifier;
     }
     if (mH.GetNPCManager().GetCommander(NPC.AffliationTypes.yellow) != null)
     {
         scores[3] += 10 * survivalPointModifier;
     }
 }
예제 #20
0
        public override bool ShouldUsePower(ManagerHelper mH)
        {
            if (mH.GetGametype() is Survival)
            {
                if (target != null && PathHelper.DistanceSquared(target.GetOriginPosition(), GetOriginPosition()) < 200 * 200)
                {
                    return(true);
                }
            }
            else
            {
                if (GetPercentHealth() < .5)
                {
                    return(true);
                }

                foreach (NPC ally in mH.GetNPCManager().GetAllies(affiliation))
                {
                    if (NPCManager.IsNPCInRadius(ally, GetOriginPosition(), 200) && ally.GetHealth() < (ally.GetMaxHealth() / 2))
                    {
                        return(true);
                    }
                }

                //Check for number of enemies
                int enemyCount = 0;

                foreach (var agent in mH.GetNPCManager().GetNPCs())
                {
                    if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), 200))
                    {
                        enemyCount++;
                    }
                }

                if (enemyCount > 3)
                {
                    return(true);
                }
            }

            return(base.ShouldUsePower(mH));
        }
예제 #21
0
        protected override void Explode(ManagerHelper mH)
        {
            mH.GetParticleManager().AddExplosion(GetOriginPosition(), ((lastDamager == null) ? this : lastDamager), 300);
            mH.GetNPCManager().Remove(this);

            if (lastDamager != null)
            {
                mH.GetGametype().ChangeScore(lastDamager, 1);
            }
        }
예제 #22
0
 protected override void Shoot(ManagerHelper mH)
 {
     foreach (NPC agent in mH.GetNPCManager().GetAllies(affiliation))
     {
         if (agent != this && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), healRadius))
         {
             agent.ChangeHealth(HEAL_NUM, this);
             mH.GetParticleManager().AddHeal(agent);
         }
     }
 }
예제 #23
0
        protected override void Behavior(ManagerHelper mH)
        {
            //am i threatened?
            threatened = false;
            foreach (NPC agent in mH.GetNPCManager().GetNPCs())
            {
                if (agent.GetAffiliation() != affiliation &&
                    NPCManager.IsNPCInRadius(agent, GetOriginPosition(), awareness))
                {
                    threatened = true;
                }
            }

            //also temp
            threatened = threatened || campingCounter >= campingEnd;

            target = TargetDecider(mH);

            if (threatened)
            {
                NewPath(mH);
                campingCounter = 0;
            }

            if (!path.GetMoving())
            {
                //If nothing to shoot at, turn around
                if (target == null)
                {
                    Turn(TURN_AMOUNT);
                    campingCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                }
                else
                {
                    if (shootingCounter > shootingSpeed)
                    {
                        shootingCounter = 0;
                        Shoot(mH);
                    }
                    else
                    {
                        shootingCounter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                    }
                }
            }
            else if (path.Count == 0)
            {
                path.SetMoving(false);
                campingCounter = 0;
            }
        }
예제 #24
0
        protected override void DeathmatchPath(ManagerHelper mH)
        {
            var       temp = (Deathmatch)mH.GetGametype();
            Claimable c    = temp.GetClosestClaimable(GetOriginPosition(), mH);

            if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count)
            {
                mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path);
            }
            else
            {
                EngagePath(mH);
            }
        }
예제 #25
0
        protected virtual void Explode(ManagerHelper mH)
        {
            for (int i = 0; i < 4; i++)
            {
                mH.GetParticleManager().AddGut(this, i);
            }

            mH.GetNPCManager().Remove(this);

            if ((mH.GetGametype() is Assasssins || mH.GetGametype() is Deathmatch) && lastDamager != null)
            {
                mH.GetGametype().ChangeScore(lastDamager, 1);
            }
        }
예제 #26
0
        public override void Update(ManagerHelper mH)
        {
            if (armed)
            {
                if (existanceTimer > existanceTime)
                {
                    draw = false;
                }
                else
                {
                    foreach (NPC agent in mH.GetNPCManager().GetNPCs())
                    {
                        if (agent.GetAffiliation() != creator.GetAffiliation() &&
                            NPCManager.IsNPCInRadius(agent, GetOriginPosition(), explodeRadius))
                        {
                            draw = false;
                            mH.GetParticleManager().AddExplosion(GetOriginPosition(), creator, damage);
                        }
                    }
                }
            }
            else
            {
                if (existanceTimer > armedTime)
                {
                    armed = true;

                    modeIndex = NPC.GetTeam(creator.GetAffiliation()) + 1;
                }
            }

            if (pulseTimer > pulseBeginTime)
            {
                frameIndex = (int)(totalFrames * (pulseTimer - pulseBeginTime) / (pulseTime - pulseBeginTime));
            }
            else
            {
                frameIndex = 0;
            }

            if (pulseTimer > pulseTime)
            {
                pulseTimer = 0;
            }

            pulseTimer     += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
            existanceTimer += mH.GetGameTime().ElapsedGameTime.TotalSeconds;

            base.Update(mH);
        }
예제 #27
0
        public override void Update(ManagerHelper mH)
        {
            if (!taken)
            {
                foreach (NPC a in mH.GetNPCManager().GetCommanders())
                {
                    if (CollisionHelper.IntersectPixelsRadius(a, this, 16, 32) != new Vector2(-1))
                    {
                        if (mH.GetNPCManager().GetAllies(a.GetAffiliation()).Count < mH.GetGametype().GetPopCap())
                        {
                            taken = true;
                            mH.GetGametype().UpdateDotsRecruited(a.GetPersonalAffilation());

                            for (int i = 0;
                                 i < 50 && !mH.GetGametype().Spawn(mH, a.GetAffiliation(), GetOriginPosition());
                                 i++)
                            {
                                //Ain't this just a gem?
                            }
                        }
                    }
                }
            }
            else
            {
                if (counter > 7) // counter greater than x number of seconds
                {
                    Activate();
                    counter = 0;
                }
                else
                {
                    counter += mH.GetGameTime().ElapsedGameTime.TotalSeconds;
                }
            }
        }
예제 #28
0
        protected override void SurvivalPath(ManagerHelper mH)
        {
            pathTimerEnd = .5;

            var       temp  = (Survival)mH.GetGametype();
            Claimable c     = temp.GetClosestClaimable(GetOriginPosition());
            NPC       enemy =
                mH.GetNPCManager()
                .GetClosestInList(mH.GetNPCManager().GetAllies(AffliationTypes.black),
                                  GetOriginPosition());

            if (enemy != null && PathHelper.DistanceSquared(GetOriginPosition(), enemy.GetOriginPosition()) < 200 * 200)
            {
                mH.GetPathHelper().FindEscapePath(GetOriginPosition(), enemy.GetOriginPosition(), 400, mH, 200, path);
            }
            else if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count)
            {
                mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path);
            }
            else
            {
                RandomPath(mH);
            }
        }
예제 #29
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);
            }
        }
예제 #30
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);
        }