示例#1
0
 private void SetDisplayColor(GameComponent body, Color color)
 {
     foreach (var sprite in body.EnumerateAll().OfType <Tinter>())
     {
         sprite.VertexColorTint = color;
     }
 }
示例#2
0
 public static void SetTintRecursive(this GameComponent component, Color color)
 {
     foreach (var sprite in component.EnumerateAll().OfType <Tinter>())
     {
         sprite.VertexColorTint = color;
     }
 }
示例#3
0
 public static void SetTintRecursive(this GameComponent component, Color color, bool oneShot = false)
 {
     foreach (var sprite in component.EnumerateAll().OfType <Tinter>())
     {
         if (!oneShot)
         {
             sprite.VertexColorTint = color;
         }
         else
         {
             sprite.OneShotTint = color;
         }
     }
 }
示例#4
0
 public static void SetVertexColorRecursive(this GameComponent component, Color color, bool oneShot = false)
 {
     foreach (var sprite in component.EnumerateAll().OfType <ITintable>())
     {
         if (!oneShot)
         {
             sprite.SetVertexColor(color);
         }
         else
         {
             sprite.SetOneShotTint(color);
         }
     }
 }
        bool IsDwarf(GameComponent body)
        {
            if (body == null)
            {
                return(false);
            }

            var dwarves = body.EnumerateAll().OfType <Creature>().ToList();

            if (dwarves.Count <= 0)
            {
                return(false);
            }

            return(dwarves[0].Faction == World.PlayerFaction);
        }
示例#6
0
        public bool CanAttack(GameComponent other)
        {
            var creature = other.EnumerateAll().OfType <Creature>().FirstOrDefault();

            if (creature == null)
            {
                return(false);
            }

            if (World.Overworld.GetPolitics(creature.Faction.ParentFaction, World.PlayerFaction.ParentFaction).GetCurrentRelationship() == Relationship.Loving)
            {
                return(false);
            }

            return(true);
        }
        bool IsNotSelectedDwarf(GameComponent body)
        {
            if (body == null)
            {
                return(true);
            }

            var dwarves = body.EnumerateAll().OfType <Creature>().ToList();

            if (dwarves.Count <= 0)
            {
                return(false);
            }

            Creature dwarf = dwarves[0];

            return(dwarf.Faction == World.PlayerFaction && !World.PersistentData.SelectedMinions.Contains(dwarf.AI));
        }
        public override void Construct()
        {
            Border      = "border-one";
            Font        = "font10";
            OnConstruct = (sender) =>
            {
                sender.Root.RegisterForUpdate(sender);

                AddChild(new Widget
                {
                    AutoLayout         = AutoLayout.DockBottom,
                    MinimumSize        = new Point(0, 32),
                    Text               = "CLOSE",
                    ChangeColorOnHover = true,
                    OnClick            = (sender1, args) => sender.Close()
                });

                ComponentProperties = AddChild(new Widget
                {
                    AutoLayout  = AutoLayout.DockBottom,
                    MinimumSize = new Point(0, 128),
                });

                ListView = AddChild(new WidgetListView
                {
                    AutoLayout = AutoLayout.DockFill,
                    SelectedItemForegroundColor = new Vector4(0, 0, 0, 1),
                    ChangeColorOnSelected       = false,
                    Border     = null,
                    ItemHeight = 24
                }) as WidgetListView;

                ListView.Border = null; // Can't make WidgetListView stop defaulting its border without breaking everywhere else its used.
            };

            OnUpdate = (sender, time) =>
            {
                if (sender.Hidden)
                {
                    return;
                }
                if (SelectedEntity == null)
                {
                    SelectedComponent = null;
                    ListView.ClearItems();
                    return;
                }

                var components = SelectedEntity.EnumerateAll();

                int i = 0;
                ListView.ClearItems();
                foreach (var component in components)
                {
                    i++;
                    var tag        = component.GuiTag as Widget;
                    var lambdaCopy = component;

                    if (tag != null)
                    {
                        ListView.AddItem(tag);
                    }
                    else
                    {
                        #region Create gui row

                        tag = Root.ConstructWidget(new Widget
                        {
                            Text              = component.GetType().Name,
                            MinimumSize       = new Point(0, 16),
                            Padding           = new Margin(0, 0, 4, 4),
                            TextVerticalAlign = VerticalAlign.Center,
                            Tag = lambdaCopy
                        });

                        tag.OnClick = (sender1, args) =>
                        {
                            if (tag.IsAnyParentHidden())
                            {
                                return;
                            }
                            SelectedComponent = lambdaCopy;
                        };

                        #endregion

                        component.GuiTag = tag;
                        ListView.AddItem(tag);
                    }
                }

                ListView.Invalidate();

                if (SelectedComponent != null)
                {
                    Drawer3D.DrawBox(SelectedComponent.GetBoundingBox(), Color.White, 0.1f, true);
                    ComponentProperties.Text = SelectedComponent.GetType().Name
                                               + "\n" + SelectedComponent.Position.ToString()
                                               + "\nBB Extents: " + SelectedComponent.BoundingBoxSize.ToString()
                                               + "\nBB Offset: " + SelectedComponent.LocalBoundingBoxOffset.ToString();
                }
                else
                {
                    ComponentProperties.Text = "";
                }
            };

            base.Construct();
        }