Ejemplo n.º 1
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.Faction = this;
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);

            if (this == World.PlayerFaction)
            {
                foreach (var m in Minions.Where(c => !SelectedMinions.Contains(c)))
                {
                    if (m.Creature.SelectionCircle != null)
                    {
                        m.Creature.DeleteSelectionCircle();
                    }
                    m.Creature.Sprite.DrawSilhouette = false;
                }
                ;

                foreach (CreatureAI creature in SelectedMinions)
                {
                    if (creature.Creature.SelectionCircle == null)
                    {
                        creature.Creature.Physics.AddChild(new SelectionCircle(creature.Manager));
                    }
                    creature.Creature.SelectionCircle.SetFlagRecursive(GameComponent.Flag.Visible, true);
                    creature.Creature.Sprite.DrawSilhouette = true;
                }
            }

            foreach (Room zone in GetRooms())
            {
                zone.ZoneBodies.RemoveAll(body => body.IsDead);
            }

            Designations.CleanupDesignations();

            foreach (var zone in RoomBuilder.DesignatedRooms)
            {
                zone.Update();
            }

            if (HandleThreatsTimer == null)
            {
                HandleThreatsTimer = new Timer(1.0f, false, Timer.TimerMode.Real
                                               );
            }

            HandleThreatsTimer.Update(time);
            if (HandleThreatsTimer.HasTriggered)
            {
                HandleThreats();
            }

            OwnedObjects.RemoveAll(obj => obj.IsDead);
        }
Ejemplo n.º 2
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.Faction  = this;
            CraftBuilder.Faction = this;
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);

            foreach (var m in Minions)
            {
                m.Creature.SelectionCircle.SetFlagRecursive(GameComponent.Flag.Visible, false);
                m.Creature.Sprite.DrawSilhouette = false;
            }
            ;

            foreach (CreatureAI creature in SelectedMinions)
            {
                creature.Creature.SelectionCircle.SetFlagRecursive(GameComponent.Flag.Visible, true);
                creature.Creature.Sprite.DrawSilhouette = true;
            }

            foreach (Room zone in GetRooms())
            {
                zone.ZoneBodies.RemoveAll(body => body.IsDead);
            }

            Designations.CleanupDesignations();

            foreach (var zone in RoomBuilder.DesignatedRooms)
            {
                zone.Update();
            }

            HandleThreatsTimer.Update(time);
            if (HandleThreatsTimer.HasTriggered)
            {
                HandleThreats();
            }

            OwnedObjects.RemoveAll(obj => obj.IsDead);
        }
Ejemplo n.º 3
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.Faction  = this;
            CraftBuilder.Faction = this;
            WallBuilder.Faction  = this;
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);
            Minions.ForEach(m =>
            {
                m.Creature.SelectionCircle.IsVisible = false;
                m.Creature.Sprite.DrawSilhouette     = false;
            });
            SelectedMinions.ForEach(m => {
                m.Creature.SelectionCircle.IsVisible = true;
                m.Creature.Sprite.DrawSilhouette     = true;
            }

                                    );

            // Turned off until a non-O(n^2) collision method is create.
            //CollideMinions(time);

            List <ulong> removalKeys = new List <ulong>();

            foreach (KeyValuePair <ulong, BuildOrder> kvp in DigDesignations)
            {
                Voxel v = kvp.Value.Vox;
                if (v.IsEmpty || v.Health <= 0.0f || v.Type.Name == "empty" || v.Type.IsInvincible)
                {
                    removalKeys.Add(kvp.Key);
                }
            }

            for (int i = 0; i < removalKeys.Count; i++)
            {
                DigDesignations.Remove(removalKeys[i]);
            }

            List <Body> gatherRemovals = (from b in GatherDesignations
                                          where b == null || b.IsDead
                                          select b).ToList();

            foreach (Body b in gatherRemovals)
            {
                GatherDesignations.Remove(b);
            }


            List <BuildOrder> removals = new List <BuildOrder>();

            foreach (BuildOrder d in GuardDesignations)
            {
                Voxel v = d.Vox;

                if (!v.IsEmpty && !(v.Health <= 0.0f) && v.Type.Name != "empty")
                {
                    continue;
                }

                removals.Add(d);

                if (!v.IsEmpty)
                {
                    v.Kill();
                }
            }

            foreach (BuildOrder v in removals)
            {
                GuardDesignations.Remove(v);
            }

            List <Body> treesToRemove = ChopDesignations.Where(tree => tree.IsDead).ToList();

            foreach (Body tree in treesToRemove)
            {
                ChopDesignations.Remove(tree);
            }

            List <Body> attacksToRemove = AttackDesignations.Where(body => body.IsDead).ToList();

            foreach (Body body in attacksToRemove)
            {
                AttackDesignations.Remove(body);
            }

            HandleThreats();
        }
Ejemplo n.º 4
0
        public void Update(DwarfTime time)
        {
            RoomBuilder.CheckRemovals();

            Minions.RemoveAll(m => m.IsDead);
            SelectedMinions.RemoveAll(m => m.IsDead);

            CollideMinions(time);

            List <BuildOrder> removals = (from d in DigDesignations
                                          let vref = d.Vox
                                                     let v = vref
                                                             where v.IsEmpty || v.Health <= 0.0f || v.Type.Name == "empty" || v.Type.IsInvincible
                                                             select d).ToList();

            foreach (BuildOrder v in removals)
            {
                DigDesignations.Remove(v);
            }

            List <Body> gatherRemovals = (from b in GatherDesignations
                                          where b == null || b.IsDead
                                          select b).ToList();

            foreach (Body b in gatherRemovals)
            {
                GatherDesignations.Remove(b);
            }


            removals.Clear();
            foreach (BuildOrder d in GuardDesignations)
            {
                Voxel v = d.Vox;

                if (!v.IsEmpty && !(v.Health <= 0.0f) && v.Type.Name != "empty")
                {
                    continue;
                }

                removals.Add(d);

                if (!v.IsEmpty)
                {
                    v.Kill();
                }
            }

            foreach (BuildOrder v in removals)
            {
                GuardDesignations.Remove(v);
            }

            List <Body> treesToRemove = ChopDesignations.Where(tree => tree.IsDead).ToList();

            foreach (Body tree in treesToRemove)
            {
                ChopDesignations.Remove(tree);
            }

            List <Body> attacksToRemove = AttackDesignations.Where(body => body.IsDead).ToList();

            foreach (Body body in attacksToRemove)
            {
                AttackDesignations.Remove(body);
            }

            HandleThreats();

            UpdateTradeEnvoys();
            UpdateWarParties();
        }