Esempio n. 1
0
        public void UpdateWaterThread()
        {
            EventWaitHandle[] waitHandles =
            {
                WaterUpdateEvent,
                Program.ShutdownEvent
            };

#if CREATE_CRASH_LOGS
            try
#endif
            {
                while (!DwarfGame.ExitGame && !ExitThreads)
                {
                    EventWaitHandle wh = Datastructures.WaitFor(waitHandles);

                    if (wh == Program.ShutdownEvent)
                    {
                        break;
                    }

                    if (!PauseThreads)
                    {
                        Water.UpdateWater();
                    }
                }
            }
#if CREATE_CRASH_LOGS
            catch (Exception exception)
            {
                ProgramData.WriteExceptionLog(exception);
            }
#endif
        }
Esempio n. 2
0
        private void CreateSubtreeRecursive(Act root, ref Vector2 lastPosition, ref Vector2 size)
        {
            if (root == null)
            {
                return;
            }
            else
            {
                ActElement element = new ActElement();
                element.act      = root;
                element.position = lastPosition;

                Elements.Add(element);

                lastPosition.Y += ElementHeight;
                lastPosition.X += ElementWidth;

                size   += Datastructures.SafeMeasure(GUI.DefaultFont, element.act.Name);
                size.X += ElementWidth;
                size.Y += ElementHeight;

                if (root.Children != null && root.Enumerator.Current != Act.Status.Success)
                {
                    foreach (Act child in root.Children)
                    {
                        CreateSubtreeRecursive(child, ref lastPosition, ref size);
                    }
                }

                lastPosition.X -= ElementWidth;
            }
        }
Esempio n. 3
0
 public void SayYay()
 {
     if (Yays != null && Yays.Count > 0)
     {
         SoundManager.PlaySound(Datastructures.SelectRandom(Yays), 0.25f);
     }
 }
Esempio n. 4
0
        private void OpenDiplomacyConversation(WorldManager World)
        {
            World.Paused = true;
            var name = "";

            if (Creatures.Count > 0)
            {
                name = Creatures.First().Stats.FullName;
            }
            else
            {
                name = TextGenerator.ToTitleCase(TextGenerator.GenerateRandom(Datastructures.SelectRandom(OwnerFaction.Race.NameTemplates).ToArray()));
            }
            // Prepare conversation memory for an envoy conversation.
            var cMem = World.ConversationMemory;

            cMem.SetValue("$world", new Yarn.Value(World));
            cMem.SetValue("$envoy", new Yarn.Value(this));
            cMem.SetValue("$envoy_demands_tribute", new Yarn.Value(this.TributeDemanded != 0));
            cMem.SetValue("$envoy_tribute_demanded", new Yarn.Value((float)this.TributeDemanded.Value));
            cMem.SetValue("$envoy_name", new Yarn.Value(name));
            cMem.SetValue("$envoy_faction", new Yarn.Value(OwnerFaction.ParentFaction.Name));
            cMem.SetValue("$player_faction", new Yarn.Value(this.OtherFaction));
            cMem.SetValue("$offensive_trades", new Yarn.Value(0));
            cMem.SetValue("$trades", new Yarn.Value(0));

            var politics = World.Overworld.GetPolitics(OtherFaction.ParentFaction, OwnerFaction.ParentFaction);

            cMem.SetValue("$faction_was_at_war", new Yarn.Value(politics.IsAtWar));
            cMem.SetValue("$envoy_relationship", new Yarn.Value(politics.GetCurrentRelationship().ToString()));

            GameStateManager.PushState(new YarnState(OwnerFaction.World, OwnerFaction.Race.DiplomacyConversation, "Start", cMem));
        }
Esempio n. 5
0
        public override void Render(SpriteBatch batch, Camera camera, Viewport viewport)
        {
            if (batch == null || camera == null)
            {
                return;
            }

            Vector2 extents = Datastructures.SafeMeasure(Font, Text);


            Vector3 unprojected = viewport.Project(Position, camera.ProjectionMatrix, camera.ViewMatrix, Matrix.Identity);

            if (unprojected.Z > 0.999f)
            {
                return;
            }

            Rectangle rect = new Rectangle((int)(unprojected.X - extents.X / 2.0f - StrokeWeight), (int)(unprojected.Y - extents.Y / 2.0f - StrokeWeight),
                                           (int)(extents.X + StrokeWeight + 5), (int)(extents.Y + StrokeWeight + 5));

            Drawer2D.FillRect(batch, rect, FillColor);
            Drawer2D.DrawRect(batch, rect, RectStrokeColor, StrokeWeight);
            Drawer2D.SafeDraw(batch, Text, Font, StrokeColor, new Vector2(unprojected.X + 1, unprojected.Y) - extents / 2.0f, Vector2.Zero);
            Drawer2D.SafeDraw(batch, Text, Font, StrokeColor, new Vector2(unprojected.X - 1, unprojected.Y) - extents / 2.0f, Vector2.Zero);

            Drawer2D.SafeDraw(batch, Text, Font, StrokeColor, new Vector2(unprojected.X, unprojected.Y + 1) - extents / 2.0f, Vector2.Zero);
            Drawer2D.SafeDraw(batch, Text, Font, StrokeColor, new Vector2(unprojected.X, unprojected.Y - 1) - extents / 2.0f, Vector2.Zero);

            Drawer2D.SafeDraw(batch, Text, Font, TextColor, new Vector2(unprojected.X, unprojected.Y) - extents / 2.0f, Vector2.Zero);
        }
Esempio n. 6
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            string text = Text;

            if (WordWrap)
            {
                text = DwarfGUI.WrapLines(Text, LocalBounds, TextFont);
            }

            if (Truncate)
            {
                Vector2 measure  = Datastructures.SafeMeasure(TextFont, text);
                Vector2 wMeasure = Datastructures.SafeMeasure(TextFont, "W");
                if (measure.X > GlobalBounds.Width)
                {
                    int numLetters = GlobalBounds.Width / (int)wMeasure.X;
                    text = Text.Substring(0, Math.Min(numLetters, Text.Length)) + "...";
                }
            }

            if (StrokeColor.A > 0)
            {
                Drawer2D.DrawAlignedStrokedText(batch, text, TextFont, TextColor, StrokeColor, Alignment, GlobalBounds);
            }
            else
            {
                Drawer2D.DrawAlignedText(batch, text, TextFont, TextColor, Alignment, GlobalBounds);
            }
            base.Render(time, batch);
        }
Esempio n. 7
0
        public override MaybeNull <Act> CreateScript(Creature creature)
        {
            if (creature.Stats.IsAsleep)
            {
                return(null);
            }

            if (!creature.Faction.Race.HasValue(out var race) || !race.IsIntelligent || !creature.IsOnGround)
            {
                return(creature.AI.ActOnWander());
            }

            var rooms = creature.World.EnumerateZones();
            var items = creature.Faction.OwnedObjects.OfType <Flag>().ToList();

            bool goToItem = MathFunctions.RandEvent(0.2f);

            if (goToItem && items.Count > 0)
            {
                return(new Sequence(
                           new GoToEntityAct(Datastructures.SelectRandom(items), creature.AI),
                           new Wrap(() => ConverseFriends(creature.AI))));
            }

            return(creature.AI.ActOnWander());
        }
Esempio n. 8
0
        public override void Render(SpriteBatch batch, Camera camera, Viewport viewport)
        {
            if (camera == null)
            {
                return;
            }
            Vector2 extents = Datastructures.SafeMeasure(Font, Text);

            Vector3 unprojected = viewport.Project(Position, camera.ProjectionMatrix, camera.ViewMatrix, Matrix.Identity);

            if (unprojected.Z > 0 && viewport.Bounds.Contains((int)unprojected.X, (int)unprojected.Y))
            {
                Drawer2D.SafeDraw(batch, Text, Font, StrokeColor,
                                  new Vector2(unprojected.X + 1, unprojected.Y) - extents / 2.0f, Vector2.Zero);
                Drawer2D.SafeDraw(batch, Text, Font, StrokeColor,
                                  new Vector2(unprojected.X - 1, unprojected.Y) - extents / 2.0f, Vector2.Zero);

                Drawer2D.SafeDraw(batch, Text, Font, StrokeColor,
                                  new Vector2(unprojected.X, unprojected.Y + 1) - extents / 2.0f, Vector2.Zero);
                Drawer2D.SafeDraw(batch, Text, Font, StrokeColor,
                                  new Vector2(unprojected.X, unprojected.Y - 1) - extents / 2.0f, Vector2.Zero);

                Drawer2D.SafeDraw(batch, Text, Font, TextColor, new Vector2(unprojected.X, unprojected.Y) - extents / 2.0f,
                                  Vector2.Zero);
            }
        }
Esempio n. 9
0
 public void SayBoo()
 {
     if (Boos != null && Boos.Count > 0)
     {
         SoundManager.PlaySound(Datastructures.SelectRandom(Boos), 0.25f);
     }
 }
Esempio n. 10
0
        public override Task ActOnIdle()
        {
            if (StealFromPlayerProbability > 0 && MathFunctions.RandEvent(StealFromPlayerProbability))
            {
                var resources = World.ListApparentResources();
                if (resources.Count > 0)
                {
                    var resource = Datastructures.SelectRandom(resources);
                    if (resource.Value.Count > 0)
                    {
                        AssignTask(new ActWrapperTask(new GetResourcesOfApparentType(this, new List <ResourceApparentTypeAmount>()
                        {
                            new ResourceApparentTypeAmount(resource.Value.Type, 1)
                        }))
                        {
                            Name = "Steal stuff", Priority = TaskPriority.High
                        });
                    }
                }
            }

            LeaveWorldTimer.Update(DwarfTime.LastTime);

            if (LeaveWorldTimer.HasTriggered)
            {
                LeaveWorld();
                LeaveWorldTimer.Reset();
            }

            return(base.ActOnIdle());
        }
Esempio n. 11
0
        private void RebuildSegments()
        {
            VertexCount = 0;
            var newSegments = new Dictionary <uint, TriangleSegment>();

            foreach (var segment in Segments)
            {
                TriangleSegment newSegment = new TriangleSegment
                {
                    ID         = segment.Key,
                    StartIndex = VertexCount
                };

                for (int i = segment.Value.StartIndex; i < segment.Value.EndIndex; i++)
                {
                    VertexScratch[VertexCount] = Verticies[i];
                    VertexCount++;
                }
                newSegment.EndIndex        = VertexCount;
                newSegments[newSegment.ID] = newSegment;
            }
            Datastructures.Swap(ref Segments, ref newSegments);
            Datastructures.Swap(ref Verticies, ref VertexScratch);
            Buffer.SetData(Verticies);
        }
Esempio n. 12
0
        public override Act CreateScript(Creature creature)
        {
            var above = VoxelHelpers.GetVoxelAbove(creature.Physics.CurrentVoxel);

            if ((above.IsValid && above.LiquidLevel > 0) || creature.AI.Movement.CanFly)
            {
                return(new Wrap(() => SwimUp(creature))
                {
                    Name = "Swim up"
                });
            }

            var findLand = FindLand(creature.World.ChunkManager.ChunkData,
                                    creature.Physics.CurrentVoxel.Coordinate, 3);

            if (findLand.IsValid)
            {
                return(new GoToVoxelAct(findLand, PlanAct.PlanType.Into, creature.AI));
            }
            else
            {
                if (creature.Faction.GetRooms().Count == 0)
                {
                    return(new LongWanderAct(creature.AI)
                    {
                        PathLength = 20, Radius = 30, Is2D = true
                    });
                }
                else
                {
                    return(new GoToZoneAct(creature.AI, Datastructures.SelectRandom(creature.Faction.GetRooms())));
                }
            }
        }
Esempio n. 13
0
        public override Act CreateScript(Creature creature)
        {
            if (creature.Physics.CurrentVoxel.GetVoxelAbove().WaterLevel > 0 || creature.AI.Movement.CanFly)
            {
                return(new Wrap(() => SwimUp(creature))
                {
                    Name = "Swim up"
                });
            }

            Voxel findLand = FindLand(3, creature.Physics.CurrentVoxel);

            if (findLand == null)
            {
                if (creature.Faction.GetRooms().Count == 0)
                {
                    return(new LongWanderAct(creature.AI)
                    {
                        PathLength = 20, Radius = 30, Is2D = true
                    });
                }
                else
                {
                    return(new GoToZoneAct(creature.AI, Datastructures.SelectRandom(creature.Faction.GetRooms())));
                }
            }
            else
            {
                return(new GoToVoxelAct(findLand, PlanAct.PlanType.Into, creature.AI));
            }
        }
Esempio n. 14
0
        public override IEnumerable <Status> Run()
        {
            if (DestinationName != null && Destination == null)
            {
                Destination = Agent.Blackboard.GetData <Zone>(DestinationName);
            }
            if (Tree == null)
            {
                var voxel = Datastructures.SelectRandom(Destination.Voxels);
                Tree = new GoToVoxelAct(VoxelHelpers.GetVoxelAbove(voxel), PlanAct.PlanType.Into, Agent);
                Tree.Initialize();
            }

            if (Tree == null)
            {
                yield return(Status.Fail);
            }
            else
            {
                foreach (Status s in base.Run())
                {
                    yield return(s);
                }
            }
        }
Esempio n. 15
0
        public override void Render(DwarfTime time, SpriteBatch batch)
        {
            Rectangle globalBounds = GlobalBounds;

            Color c = TextColor;

            if (IsMouseOver)
            {
                c = HoverTextColor;
            }

            Rectangle checkboxBounds = new Rectangle(GlobalBounds.Right - 32, GlobalBounds.Top + 1, 32, 32);

            GUI.Skin.RenderCheckbox(checkboxBounds, Checked, batch);
            Vector2 measure = Datastructures.SafeMeasure(GUI.DefaultFont, Text);


            Drawer2D.DrawStrokedText(batch, Text,
                                     GUI.DefaultFont,
                                     new Vector2(GlobalBounds.Right - measure.X - 32, GlobalBounds.Top + 5),
                                     c, StrokeColor);


            base.Render(time, batch);
        }
Esempio n. 16
0
        private static GameComponent __factory1(ComponentManager Manager, Vector3 Position, Blackboard Data)
        {
            IEnumerable <Resource> foods = Library.EnumerateResourceTypesWithTag(Resource.ResourceTags.RawFood);
            Resource randresource        = Library.CreateMealResourceType(Datastructures.SelectRandom(foods).Name, Datastructures.SelectRandom(foods).Name);

            return(new ResourceEntity(Manager, new ResourceAmount(randresource.Name), Position));
        }
Esempio n. 17
0
        private string GetFarewell()
        {
            string greeting = "";

            greeting = Datastructures.SelectRandom(Faction.Race.Speech.Farewells);
            return(greeting);
        }
Esempio n. 18
0
        public List <ResourceAmount> GenerateResources()
        {
            Dictionary <ResourceLibrary.ResourceType, ResourceAmount> toReturn =
                new Dictionary <ResourceLibrary.ResourceType, ResourceAmount>();

            foreach (var tags in TradeGoods)
            {
                int num = MathFunctions.RandInt(tags.Value - 5, tags.Value + 5);


                List <Resource> resources = ResourceLibrary.GetResourcesByTag(tags.Key);

                if (resources.Count <= 0)
                {
                    continue;
                }

                for (int i = 0; i < num; i++)
                {
                    Resource randResource = Datastructures.SelectRandom(resources);

                    if (randResource.Type == ResourceLibrary.ResourceType.Trinket ||
                        randResource.Type == ResourceLibrary.ResourceType.GemTrinket ||
                        tags.Key == Resource.ResourceTags.Craft)
                    {
                        Resource.ResourceTags craftTag        = Datastructures.SelectRandom(Crafts);
                        List <Resource>       availableCrafts = ResourceLibrary.GetResourcesByTag(craftTag);

                        Resource trinket = ResourceLibrary.GenerateTrinket(
                            Datastructures.SelectRandom(availableCrafts).Type, MathFunctions.Rand(0.1f, 3.0f));

                        if (MathFunctions.RandEvent(0.3f) && Encrustings.Count > 0)
                        {
                            List <Resource> availableGems =
                                ResourceLibrary.GetResourcesByTag(Datastructures.SelectRandom(Encrustings));
                            randResource = ResourceLibrary.EncrustTrinket(trinket.Type,
                                                                          Datastructures.SelectRandom(availableGems).Type);
                        }
                        else
                        {
                            randResource = trinket;
                        }
                    }

                    if (!toReturn.ContainsKey(randResource.Type))
                    {
                        toReturn[randResource.Type] = new ResourceAmount(randResource.Type, 1);
                    }
                    else
                    {
                        toReturn[randResource.Type].NumResources += 1;
                    }
                }
            }

            List <ResourceAmount> resList = toReturn.Select(amount => amount.Value).ToList();

            return(resList);
        }
Esempio n. 19
0
        private string GetGreeting()
        {
            string greeting = "";

            greeting  = Datastructures.SelectRandom(Faction.Race.Speech.Greetings);
            greeting += " I am " + TalkerName + " of " + Faction.Name + ".";
            return(greeting);
        }
Esempio n. 20
0
        public void RenderSliderHorizontal(SpriteFont font, Rectangle boundingRect, float value, float minvalue, float maxValue, Slider.SliderMode mode, bool drawLabel, bool invertValue, SpriteBatch spriteBatch)
        {
            const int padding = 5;

            if (invertValue)
            {
                value = maxValue - value;
            }

            int       fieldSize = Math.Max(Math.Min((int)(0.2f * boundingRect.Width), 150), 64);
            Rectangle rect      = new Rectangle(boundingRect.X + padding, boundingRect.Y + boundingRect.Height / 2 - TileHeight / 2, boundingRect.Width - fieldSize - padding * 2, boundingRect.Height / 2);
            Rectangle fieldRect = new Rectangle(boundingRect.Right - fieldSize, boundingRect.Y + boundingRect.Height / 2 - TileHeight / 2, fieldSize, boundingRect.Height / 2);
            int       maxX      = rect.X + rect.Width;
            int       diffX     = rect.Width % TileWidth;
            int       right     = maxX;
            int       left      = rect.X;
            int       top       = rect.Y;


            for (int x = left; x <= right; x += TileWidth)
            {
                spriteBatch.Draw(Texture, new Rectangle(x, rect.Y, TileWidth, TileHeight), GetSourceRect(Tile.Track), Color.White);
            }

            spriteBatch.Draw(Texture, new Rectangle(maxX - diffX, rect.Y, diffX, TileHeight), GetSourceRect(Tile.Track), Color.White);

            int sliderX = (int)((value - minvalue) / (maxValue - minvalue) * rect.Width + rect.X);

            spriteBatch.Draw(Texture, new Rectangle(sliderX - TileWidth / 2, rect.Y, TileWidth, TileHeight), GetSourceRect(Tile.SliderTex), Color.White);

            if (!drawLabel)
            {
                return;
            }
            RenderField(fieldRect, spriteBatch);

            float v = 0.0f;

            if (invertValue)
            {
                value = value - maxValue;
            }
            if (mode == Slider.SliderMode.Float)
            {
                v = (float)Math.Round(value, 2);
            }
            else
            {
                v = (int)value;
            }

            string toDraw = "" + v;

            Vector2 origin = Datastructures.SafeMeasure(font, toDraw) * 0.5f;

            Drawer2D.SafeDraw(spriteBatch, toDraw, font, Color.Black, new Vector2(fieldRect.X + fieldRect.Width / 2, fieldRect.Y + 16), origin);
        }
Esempio n. 21
0
 public void RotateClockwise(int numRotations)
 {
     for (int i = 0; i < numRotations; i++)
     {
         Template    = Datastructures.RotateClockwise(Template);
         Accessories = Datastructures.RotateClockwise(Accessories);
         Rotation   -= (float)Math.PI * 0.5f;
     }
 }
Esempio n. 22
0
        private static GameComponent CreateRandomFood(WorldManager world, Vector3 position)
        {
            IEnumerable <Resource> foods = ResourceLibrary.GetResourcesByTag(Resource.ResourceTags.RawFood);

            Resource randresource = ResourceLibrary.CreateMeal(Datastructures.SelectRandom(foods).Type,
                                                               Datastructures.SelectRandom(foods).Type);

            return(new ResourceEntity(world.ComponentManager, new ResourceAmount(randresource.Type), position));
        }
Esempio n. 23
0
        public void AddMoney(DwarfBux money)
        {
            if (money == 0.0m)
            {
                return;
            }

            // In this case, we need to remove money from the economy.
            // This means that we first take money from treasuries. If there is any left,
            // we subtract it from the current money count.
            if (money < 0)
            {
                DwarfBux amountLeft = -money;
                foreach (Treasury treasury in Treasurys)
                {
                    DwarfBux amountToTake = System.Math.Min(treasury.Money, amountLeft);
                    treasury.Money -= amountToTake;
                    amountLeft     -= amountToTake;
                }
                return;
            }

            DwarfBux amountRemaining = money;

            foreach (Treasury treasury in Treasurys)
            {
                if (amountRemaining <= 0)
                {
                    break;
                }

                DwarfBux maxInTreasury = treasury.Voxels.Count * Treasury.MoneyPerPile - treasury.Money;
                DwarfBux amountToTake  = System.Math.Min(maxInTreasury, amountRemaining);

                amountRemaining -= amountToTake;
                treasury.Money  += amountToTake;
            }
            if (amountRemaining > 0 && RoomBuilder.DesignatedRooms.Count > 0)
            {
                World.MakeAnnouncement("We need more treasuries!");
                // Generate a number of coin piles.
                for (DwarfBux total = 0m; total < amountRemaining; total += 1024m)
                {
                    Zone    randomZone = Datastructures.SelectRandom(RoomBuilder.DesignatedRooms);
                    Vector3 point      = MathFunctions.RandVector3Box(randomZone.GetBoundingBox()) +
                                         new Vector3(0, 1.0f, 0);
                    CoinPile pile = EntityFactory.CreateEntity <CoinPile>("Coins Resource", point);
                    pile.Money = 1024m;

                    // Special case where we just need to add a little bit of money (less than 64 coins)
                    if (money - total < 1024m)
                    {
                        pile.Money = money - total;
                    }
                }
            }
        }
Esempio n. 24
0
        private static GameComponent CreateRandomFood(Vector3 position)
        {
            List <Resource> foods = ResourceLibrary.GetResourcesByTag(Resource.ResourceTags.RawFood);

            Resource randresource = ResourceLibrary.CreateMeal(Datastructures.SelectRandom(foods),
                                                               Datastructures.SelectRandom(foods));

            return(new ResourceEntity(randresource.Type, position));
        }
Esempio n. 25
0
        private string GetBadTradeText()
        {
            string generic = Datastructures.SelectRandom(Faction.Race.Speech.BadTrades);

            if (LastEvent.IsHate())
            {
                generic += " We are offended by this trade.";
            }
            return(generic);
        }
Esempio n. 26
0
        private Vector2 MeasureColumn(IEnumerable <Entry> column)
        {
            Vector2 toReturn = Vector2.Zero;

            foreach (Entry s in column)
            {
                toReturn.Y += Datastructures.SafeMeasure(Font, s.LocalName).Y;
                toReturn.X  = (float)Math.Max(toReturn.X, Datastructures.SafeMeasure(Font, s.LocalName).X);
            }
            return(toReturn);
        }
Esempio n. 27
0
        public static ResourceEntity CreateRandomTrinket(WorldManager world, Vector3 pos)
        {
            Resource randResource = ResourceLibrary.GenerateTrinket(Datastructures.SelectRandom(ResourceLibrary.Resources.Where(r => r.Value.Tags.Contains(Resource.ResourceTags.Material))).Key, MathFunctions.Rand(0.1f, 3.5f));

            if (MathFunctions.RandEvent(0.5f))
            {
                randResource = ResourceLibrary.EncrustTrinket(randResource.Type, Datastructures.SelectRandom(ResourceLibrary.Resources.Where(r => r.Value.Tags.Contains(Resource.ResourceTags.Gem))).Key);
            }

            return(new ResourceEntity(world.ComponentManager, new ResourceAmount(randResource.Type), pos));
        }
Esempio n. 28
0
        private static GameComponent __factory0(ComponentManager Manager, Vector3 Position, Blackboard Data)
        {
            var randResource = Library.CreateTrinketResourceType(Datastructures.SelectRandom(Library.EnumerateResourceTypes().Where(r => r.Tags.Contains(Resource.ResourceTags.Material))).Name, MathFunctions.Rand(0.1f, 3.5f));

            if (MathFunctions.RandEvent(0.5f))
            {
                randResource = Library.CreateEncrustedTrinketResourceType(randResource.Name, Datastructures.SelectRandom(Library.EnumerateResourceTypes().Where(r => r.Tags.Contains(Resource.ResourceTags.Gem))).Name);
            }

            return(new ResourceEntity(Manager, new ResourceAmount(randResource.Name), Position));
        }
Esempio n. 29
0
        private Vector2 MeasureColumn(List <string> column)
        {
            Vector2 toReturn = Vector2.Zero;

            foreach (string s in column)
            {
                toReturn.Y += Datastructures.SafeMeasure(GUI.DefaultFont, s).Y;
                toReturn.X  = (float)Math.Max(toReturn.X, Datastructures.SafeMeasure(GUI.DefaultFont, s).X);
            }
            return(toReturn);
        }
Esempio n. 30
0
 public MeleeAct(CreatureAI agent, Body target) :
     base(agent)
 {
     FailTimer     = new Timer(5.0f, false);
     Timeout       = new Timer(100.0f, false);
     Training      = false;
     Name          = "Attack!";
     EnergyLoss    = 200.0f;
     Target        = target;
     CurrentAttack = Datastructures.SelectRandom(agent.Creature.Attacks);
 }