Exemplo n.º 1
0
        public DebugVisibleItem(ITypeResolver resolver, Vector2 pos)
            : base(resolver, pos, Angle.Right)
        {
            visible = new VisibleProperty(this);

            AddProperty(visible);
        }
Exemplo n.º 2
0
 public void CleanupEngine()
 {
     VisibleItem   = null;
     SightingItem  = null;
     SmellableItem = null;
     SnifferItem   = null;
     Visible       = null;
     Sighting      = null;
     Smellable     = null;
     Sniffer       = null;
     Map           = null;
     Engine        = null;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Registers Sugar
        /// </summary>
        /// <param name="typeMapper">Type Mapper</param>
        /// <param name="settings">Settings</param>
        private void RegisterSugar(ITypeMapper typeMapper, KeyValueStore settings)
        {
            // Sugar
            typeMapper.RegisterItem <SugarItem, SugarState, SugarInfo>(this, "Sugar");

            // Collidable
            typeMapper.AttachItemProperty <SugarItem, CollidableProperty>(this, "Sugar Collidable", (i) =>
            {
                CollidableProperty property = new CollidableProperty(i);

                // Define mass (Fixed)
                property.CollisionFixed = true;
                property.CollisionMass  = 0f;

                // Bind Collision Radius to the Item Radius
                property.CollisionRadius = i.Radius;
                i.RadiusChanged         += (item, v) => { property.CollisionRadius = v; };

                return(property);
            });

            // Visibility
            typeMapper.AttachItemProperty <SugarItem, VisibleProperty>(this, "Sugar Visible", (i) =>
            {
                VisibleProperty property = new VisibleProperty(i);

                // Bind Visibility Radius to the Item Radius
                property.VisibilityRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.VisibilityRadius = v; };

                return(property);
            });

            // Collectable
            typeMapper.AttachItemProperty <SugarItem, SugarCollectableProperty>(this, "Sugar Collectable"); // TODO: Amounts (SugarMaxCapacity, Math.Min(SugarMaxCapacity, amount))
        }
Exemplo n.º 4
0
 set => SetValue(VisibleProperty, value);
 private void InitVisibleItem(Vector2 pos)
 {
     VisibleItem = new DebugVisibleItem(pos);
     Visible = VisibleItem.GetProperty<VisibleProperty>();
     Engine.InsertItem(VisibleItem);
 }
 public void CleanupEngine()
 {
     VisibleItem = null;
     SightingItem = null;
     SmellableItem = null;
     SnifferItem = null;
     Visible = null;
     Sighting = null;
     Smellable = null;
     Sniffer = null;
     Map = null;
     Engine = null;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Tworzy widok listy
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public virtual ListViewFactory <T> CreateGrid <T>(string title = null, string description = null)
        {
            var view = new ListViewFactory <T>();

            var visibleProperty = new List <VisibleProperty>();

            var type       = typeof(T);
            var properties = type.GetProperties();

            foreach (var propertyInfo in properties)
            {
                var scaffoldColumns = propertyInfo.GetCustomAttributes(typeof(GridViewAttribute));
                if (scaffoldColumns.Any())
                {
                    var scaffoldColumn = scaffoldColumns.First() as GridViewAttribute;
                    if (scaffoldColumn != null)
                    {
                        var vp = new VisibleProperty()
                        {
                            ListView = scaffoldColumn, PropertyInfo = propertyInfo
                        };
                        if (propertyInfo.PropertyType == typeof(bool))
                        {
                            vp.ListView.ColumnType = GridColumnType.CheckboxColumn;
                        }
                        visibleProperty.Add(vp);
                    }
                }
            }
            var df = view.AddDataForm();

            if (title != null)
            {
                df.AddLabel(title);
            }
            if (description != null)
            {
                df.AddLabel(description);
            }

            var grid = df.AddGridView();

            grid.GridView.GroupingEnabled        = true;
            grid.GridView.AllowFilteringByColumn = true;
            grid.GridView.AllowSorting           = true;
            grid.GridView.AggregateEnabled       = true;

            foreach (var property in visibleProperty)
            {
                var column = grid.Column(property.PropertyInfo.Name).Label(property.ListView.Label ?? property.PropertyInfo.Name);

                column.Column.FilterFunction     = property.ListView.FilterFunction;
                column.Column.FilterDefaultValue = property.ListView.FilterDefaultValue;
                column.Column.ColumnType         = property.ListView.ColumnType;
                if (property.ListView.FilterFunction != GridKnownFunction.NoFilter)
                {
                    column.ShowColumnFilter();
                }

                column.Column.Width            = property.ListView.Width;
                column.Column.DataFormatString = property.ListView.DataFormatString;
                column.Column.Aggregate        = property.ListView.Aggregate;

                column.Column.DataTypeName = property.ListView.ColumnDataType?.AssemblyQualifiedName;
                //property.PropertyInfo.PropertyType.AssemblyQualifiedName;
            }

            view.Grid = grid;

            return(view);
        }
Exemplo n.º 8
0
 private void InitVisibleItem(Vector2 pos)
 {
     VisibleItem = new DebugVisibleItem(pos);
     Visible     = VisibleItem.GetProperty <VisibleProperty>();
     Engine.InsertItem(VisibleItem);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Default Constructor for the Type Mapper.
 /// </summary>
 /// <param name="item">Related Engine Item</param>
 /// <param name="property">Related Engine Property</param>
 public VisibleState(Item item, VisibleProperty property)
     : base(item, property)
 {
 }
Exemplo n.º 10
0
        /// <summary>
        /// Registers Ants
        /// </summary>
        /// <param name="typeMapper">Type Mapper</param>
        /// <param name="settings">Settings</param>
        private void RegisterAnt(ITypeMapper typeMapper, KeyValueStore settings)
        {
            // Ant Item
            settings.Set <AntItem>("ZickZackAngle", 10, "Correction Angle after Sprint");
            settings.Set <AntItem>("ZickZackRange", 30f, "Distance to go every Sprint");
            settings.Set <AntItem>("RotationSpeed", 20, "Maximum Rotation Angle per Round");
            settings.Set <AntItem>("DropSugar", false, "Will an Ant leave a small Sugar on Drop");
            settings.Set <AntItem>("MarkerDelay", 10, "Time in Rounds between Marker-Drops");
            typeMapper.RegisterItem <AntItem, AntState, AntInfo>(this, "Ant");

            // Walking
            settings.Set <AntItem>("MaxSpeed", 1f, "Maximum Speed of an Ant");
            typeMapper.AttachItemProperty <AntItem, WalkingProperty>(this, "Ant Walking", (i) =>
            {
                WalkingProperty property = new WalkingProperty(i);

                // Set Maximum Speed based on the current Settings
                // TODO: Check for Castes
                property.MaximumSpeed = i.Settings.GetFloat <AntItem>("MaxSpeed").Value;

                // Bind Item Orientation to Walk-Direction
                property.Direction    = i.Orientation;
                i.OrientationChanged += (item, v) => { property.Direction = v; };

                return(property);
            });

            // Collision
            settings.Set <AntItem>("Mass", 1f, "Collision Mass of an Ant");
            typeMapper.AttachItemProperty <AntItem, CollidableProperty>(this, "Ant Collidable", (i) =>
            {
                CollidableProperty property = new CollidableProperty(i);

                // Set Mass to Settings
                property.CollisionFixed = false;
                property.CollisionMass  = i.Settings.GetFloat <AntItem>("Mass").Value;

                // Bind Collision Radius to Item Radius
                property.CollisionRadius = i.Radius;
                i.RadiusChanged         += (item, v) => { property.CollisionRadius = v; };

                return(property);
            });

            // Visibility
            typeMapper.AttachItemProperty <AntItem, VisibleProperty>(this, "Ant Visible", (i) =>
            {
                VisibleProperty property = new VisibleProperty(i);

                // Bind Visibility Radius to the Item Radius
                property.VisibilityRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.VisibilityRadius = v; };

                return(property);
            });

            // Sighting
            settings.Set <AntItem>("ViewRange", 20f, "View Range of an Ant");
            settings.Set <AntItem>("ViewAngle", 360, "View Angle of an Ant");
            typeMapper.AttachItemProperty <AntItem, SightingProperty>(this, "Ant Sighting", (i) =>
            {
                SightingProperty property = new SightingProperty(i);

                // Set View Range and Angle
                property.ViewRange = i.Settings.GetFloat <AntItem>("ViewRange").Value;
                property.ViewAngle = i.Settings.GetFloat <AntItem>("ViewAngle").Value;

                // Bind View Direction to the Item Orientation
                property.ViewDirection = i.Orientation;
                i.OrientationChanged  += (item, v) => { property.ViewDirection = v; };

                return(property);
            });

            // Sniffer
            typeMapper.AttachItemProperty <AntItem, SnifferProperty>(this, "Ant Sniffer");

            // Carrier
            settings.Set <AntItem>("CarrierStrength", 10f, "Carrier Strength of an Ant");
            typeMapper.AttachItemProperty <AntItem, CarrierProperty>(this, "Ant Carrier", (i) =>
            {
                CarrierProperty property = new CarrierProperty(i);
                property.CarrierStrength = i.Settings.GetFloat <AntItem>("CarrierStrength").Value;
                return(property);
            });

            // Attackable
            settings.Set <AntItem>("MaxHealth", 100f, "Maximum Health for an Ant");
            typeMapper.AttachItemProperty <AntItem, AttackableProperty>(this, "Ant Attackable", (i) =>
            {
                AttackableProperty property = new AttackableProperty(i);

                // Bind Attackable Radius to Item Radius
                property.AttackableRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.AttackableRadius = v; };

                // Health
                property.AttackableMaximumHealth = settings.GetInt <AntItem>("MaxHealth").Value;
                property.AttackableHealth        = settings.GetInt <AntItem>("MaxHealth").Value;

                return(property);
            });

            // Attacker
            settings.Set <AntItem>("AttackRange", 3f, "Attack Range for a Bug");
            settings.Set <AntItem>("RecoveryTime", 2, "Recovery Time in Rounds for a Bug");
            settings.Set <AntItem>("AttackStrength", 5, "Attach Strength for a Bug");
            typeMapper.AttachItemProperty <AntItem, AttackerProperty>(this, "Ant Attacker", (i) =>
            {
                AttackerProperty property   = new AttackerProperty(i);
                property.AttackRange        = i.Settings.GetFloat <AntItem>("AttackRange").Value;
                property.AttackRecoveryTime = i.Settings.GetInt <AntItem>("RecoveryTime").Value;
                property.AttackStrength     = i.Settings.GetInt <AntItem>("AttackStrength").Value;
                return(property);
            });

            // Collector
            settings.Set <AntItem>("SugarCapacity", 5, "Maximum Capacity for Sugar");
            settings.Set <AntItem>("AppleCapacity", 2, "Maximum Capacity for Apple");
            typeMapper.AttachItemProperty <AntItem, SugarCollectorProperty>(this, "Ant Sugar Collectable", (i) =>
            {
                SugarCollectorProperty property = new SugarCollectorProperty(i);
                property.Capacity = i.Settings.GetInt <AntItem>("SugarCapacity").Value;
                return(property);
            });
            typeMapper.AttachItemProperty <AntItem, AppleCollectorProperty>(this, "Ant Apple Collectable", (i) =>
            {
                AppleCollectorProperty property = new AppleCollectorProperty(i);
                property.Capacity = i.Settings.GetInt <AntItem>("AppleCapacity").Value;
                return(property);
            }); // TODO: Optional, wenn _settings.ANT_APPLECOLLECT | _settings.ANT_APPLE_CAPACITY, 0);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Registers classic Bugs
        /// </summary>
        /// <param name="typeMapper">Type Mapper</param>
        /// <param name="settings">Settings</param>
        private void RegisterClassicBug(ITypeMapper typeMapper, KeyValueStore settings)
        {
            // Classic Bug
            typeMapper.RegisterItem <ClassicBugItem, BugState, BugInfo>(this, "Classic Bug");

            // Walking
            settings.Set <ClassicBugItem>("MaxSpeed", 2f, "Maximum Speed of a Classic Bug");
            typeMapper.AttachItemProperty <ClassicBugItem, WalkingProperty>(this, "Classic Bug Walking", (i) =>
            {
                WalkingProperty property = new WalkingProperty(i);

                // Set Walking Speed
                property.MaximumSpeed = i.Settings.GetFloat <ClassicBugItem>("MaxSpeed").Value;

                // Bind Direction to the Items Orientation
                property.Direction    = i.Orientation;
                i.OrientationChanged += (item, v) => { property.Direction = v; };

                return(property);
            });

            // Collision
            settings.Set <ClassicBugItem>("Mass", 10f, "Collision Mass of a Classic Bug");
            typeMapper.AttachItemProperty <ClassicBugItem, CollidableProperty>(this, "Classic Bug Collidable", (i) =>
            {
                CollidableProperty property = new CollidableProperty(i);

                // Set Collision Mass
                property.CollisionFixed = false;
                property.CollisionMass  = i.Settings.GetFloat <ClassicBugItem>("Mass").Value;

                // Bind Collision Radius to the Item Radius
                property.CollisionRadius = i.Radius;
                i.RadiusChanged         += (item, v) => { property.CollisionRadius = v; };

                return(property);
            });

            // Visibility
            typeMapper.AttachItemProperty <ClassicBugItem, VisibleProperty>(this, "Classic Bug Visible", (i) =>
            {
                VisibleProperty property = new VisibleProperty(i);

                // Bind Visibility Radius to the Item Radius
                property.VisibilityRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.VisibilityRadius = v; };

                return(property);
            });

            // Sighting
            settings.Set <ClassicBugItem>("ViewRange", 20f, "View Range of a Classic Bug");
            settings.Set <ClassicBugItem>("ViewAngle", 360, "View Angle of a Classic Bug");
            typeMapper.AttachItemProperty <ClassicBugItem, SightingProperty>(this, "Classic Bug Sighting", (i) =>
            {
                SightingProperty property = new SightingProperty(i);

                // Set View Range and Angle
                property.ViewRange = i.Settings.GetFloat <ClassicBugItem>("ViewRange").Value;
                property.ViewAngle = i.Settings.GetFloat <ClassicBugItem>("ViewAngle").Value;

                // Bind View Direction to the Item Orientation
                property.ViewDirection = i.Orientation;
                i.OrientationChanged  += (item, v) => { property.ViewDirection = v; };

                return(property);
            });

            // Sniffer
            typeMapper.AttachItemProperty <ClassicBugItem, SnifferProperty>(this, "Classic Bug Sniffer");

            // Attackable
            settings.Set <ClassicBugItem>("MaxHealth", 1000, "Maximum Health of a Classic Bug");
            typeMapper.AttachItemProperty <ClassicBugItem, AttackableProperty>(this, "Classic Bug Attackable", (i) =>
            {
                AttackableProperty property = new AttackableProperty(i);

                // Bind Attackable Radius to Item Radius
                property.AttackableRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.AttackableRadius = v; };

                // Health
                property.AttackableMaximumHealth = settings.GetInt <ClassicBugItem>("MaxHealth").Value;
                property.AttackableHealth        = settings.GetInt <ClassicBugItem>("MaxHealth").Value;

                return(property);
            });

            // Attacker
            settings.Set <ClassicBugItem>("AttackRange", 5f, "Attack Range for a Classic Bug");
            settings.Set <ClassicBugItem>("RecoveryTime", 5, "Recovery Time in Rounds for a Classic Bug");
            settings.Set <ClassicBugItem>("AttackStrength", 10, "Attach Strength for a Classic Bug");
            typeMapper.AttachItemProperty <ClassicBugItem, AttackerProperty>(this, "Classic Bug Attacker", (i) =>
            {
                AttackerProperty property   = new AttackerProperty(i);
                property.AttackRange        = i.Settings.GetFloat <ClassicBugItem>("AttackRange").Value;
                property.AttackRecoveryTime = i.Settings.GetInt <ClassicBugItem>("RecoveryTime").Value;
                property.AttackStrength     = i.Settings.GetInt <ClassicBugItem>("AttackStrength").Value;
                return(property);
            });
        }
Exemplo n.º 12
0
        /// <summary>
        /// Registers Anthills
        /// </summary>
        /// <param name="typeMapper">Type Mapper</param>
        /// <param name="settings">Settings</param>
        private void RegisterAnthill(ITypeMapper typeMapper, KeyValueStore settings)
        {
            // Anthill
            typeMapper.RegisterItem <AnthillItem, AnthillState, AnthillInfo>(this, "Anthill");

            // Collision
            typeMapper.AttachItemProperty <AnthillItem, CollidableProperty>(this, "Anthill Collidable", (i) =>
            {
                CollidableProperty property = new CollidableProperty(i);

                // Set Collision Mass
                property.CollisionFixed = true;
                property.CollisionMass  = 0f;

                // Bind Radius to the Item Radius
                property.CollisionRadius = i.Radius;
                i.RadiusChanged         += (item, v) => { property.CollisionRadius = v; };

                return(property);
            });

            // Visibility
            typeMapper.AttachItemProperty <AnthillItem, VisibleProperty>(this, "Anthill Visible", (i) =>
            {
                VisibleProperty property = new VisibleProperty(i);

                // Bind Visibility Radius to the Item Radius
                property.VisibilityRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.VisibilityRadius = v; };

                return(property);
            });

            // Attackable
            settings.Set <AnthillItem>("Attackable", false, "Enables the possibility to destroy Anthills");
            settings.Set <AnthillItem>("MaxHealth", 1000, "Maximum Health of an Anthill");
            settings.Set <AnthillItem>("Buildable", false, "Can an Anthill build by ants");
            typeMapper.AttachItemProperty <AnthillItem, AttackableProperty>(this, "Anthill Attackable", (i) =>
            {
                // Check Attackable Switch
                if (!i.Settings.GetBool <AnthillItem>("Attackable").Value)
                {
                    return(null);
                }

                AttackableProperty property = new AttackableProperty(i);

                // Bind Attackable Radius to Item Radius
                property.AttackableRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.AttackableRadius = v; };

                // Health
                property.AttackableMaximumHealth = settings.GetInt <AnthillItem>("MaxHealth").Value;
                property.AttackableHealth        = settings.GetInt <AnthillItem>("MaxHealth").Value;

                return(property);
            });

            // Collectable
            typeMapper.AttachItemProperty <AnthillItem, SugarCollectableProperty>(this, "Anthill Sugarsafe"); // TODO: Radius
            typeMapper.AttachItemProperty <AnthillItem, AppleCollectableProperty>(this, "Anthill Applesafe"); // TODO: Radius
        }
Exemplo n.º 13
0
        /// <summary>
        /// Registers Apples
        /// </summary>
        /// <param name="typeMapper">Type Mapper</param>
        /// <param name="settings">Settings</param>
        private void RegisterApple(ITypeMapper typeMapper, KeyValueStore settings)
        {
            // Apple
            typeMapper.RegisterItem <AppleItem, AppleState, AppleInfo>(this, "Apple");

            // Collidable
            settings.Set <AppleItem>("Mass", 200f, "Mass of an Apple");
            typeMapper.AttachItemProperty <AppleItem, CollidableProperty>(this, "Apple Collidable", (i) =>
            {
                CollidableProperty property = new CollidableProperty(i);

                // Define Radius
                property.CollisionRadius = AppleItem.AppleInnerRadius;

                // Define Mass
                property.CollisionFixed = false;
                property.CollisionMass  = i.Settings.GetFloat <AppleItem>("Mass").Value;

                return(property);
            });

            // Visibility
            typeMapper.AttachItemProperty <AppleItem, VisibleProperty>(this, "Apple Visible", (i) =>
            {
                VisibleProperty property = new VisibleProperty(i);

                // Bind Visibility Radius to the Item Radius
                property.VisibilityRadius = i.Radius;
                i.RadiusChanged          += (item, v) => { property.VisibilityRadius = v; };

                return(property);
            });

            // Portable
            settings.Set <AppleItem>("Weight", 200f, "Weight of an Apple");
            typeMapper.AttachItemProperty <AppleItem, PortableProperty>(this, "Apple Portable", (i) =>
            {
                PortableProperty property = new PortableProperty(i);

                // Set Weight
                property.PortableWeight = settings.GetFloat <AppleItem>("Weight").Value;

                // Bind Portable Radius to the Item Radius
                property.PortableRadius = i.Radius;
                i.RadiusChanged        += (item, v) => { property.PortableRadius = v; };

                return(property);
            });

            settings.Set <AppleItem>("Collectable", false, "Will an Apple be collectable");
            settings.Set <AppleItem>("Amount", 250, "Amount of Apple Units");
            typeMapper.AttachItemProperty <AppleItem, AppleCollectableProperty>(this, "Apple Collectable", (i) =>
            {
                if (!i.Settings.GetBool <AppleItem>("Collectable").Value)
                {
                    return(null);
                }

                AppleCollectableProperty property = new AppleCollectableProperty(i);
                property.Capacity = i.Settings.GetInt <AppleItem>("Amount").Value;
                property.Amount   = i.Settings.GetInt <AppleItem>("Amount").Value;
                return(property);
            });
        }