Esempio n. 1
0
        public DebugSmellableItem(ITypeResolver resolver, Vector2 pos)
            : base(resolver, pos, Angle.Right)
        {
            smellable = new SmellableProperty(this, 10);

            AddProperty(smellable);
        }
        public DebugSmellableItem(ITypeResolver resolver, Vector2 pos)
            : base(resolver, pos, Angle.Right)
        {
            smellable = new SmellableProperty(this, 10);

            AddProperty(smellable);
        }
 public void CleanupEngine()
 {
     VisibleItem   = null;
     SightingItem  = null;
     SmellableItem = null;
     SnifferItem   = null;
     Visible       = null;
     Sighting      = null;
     Smellable     = null;
     Sniffer       = null;
     Map           = null;
     Engine        = null;
 }
Esempio n. 4
0
        /// <summary>
        /// Registers Marker
        /// </summary>
        /// <param name="typeMapper">Type Mapper</param>
        /// <param name="settings">Settings</param>
        private void RegisterMarker(ITypeMapper typeMapper, KeyValueStore settings)
        {
            // Marker
            settings.Set <MarkerItem>("MinRadius", 20f, "Minimum Radius of a Marker");
            settings.Set <MarkerItem>("MaxRadius", 200f, "Maximum Radius of a Marker");
            settings.Set <MarkerItem>("Volume", 2000f, "Total Volume of a Marker");
            typeMapper.RegisterItem <MarkerItem, MarkerState, MarkerInfo>(this, "Marker");

            // Smellable
            typeMapper.AttachItemProperty <MarkerItem, SmellableProperty>(this, "Marker Smellable", (i) =>
            {
                SmellableProperty property = new SmellableProperty(i);

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

                return(property);
            });
        }
Esempio n. 5
0
        public MarkerItem(SimulationContext context, Faction faction, Vector2 position, float radius, int information)
            : base(context, faction, position, radius, Angle.Right)
        {
            Information = information;

            smellable = GetProperty <SmellableProperty>();
            if (smellable == null)
            {
                throw new NotSupportedException("Marker has no Smellable Property");
            }

            minRadius = Settings.GetFloat <MarkerItem>("MinRadius").Value;
            float maxRadius = Settings.GetFloat <MarkerItem>("MaxRadius").Value;
            float volume    = Settings.GetFloat <MarkerItem>("Volume").Value;

            float finalRadius = Math.Max(minRadius, Math.Min(maxRadius, radius));

            TotalAge   = (int)(volume / finalRadius);
            step       = (finalRadius - minRadius) / TotalAge;
            CurrentAge = 0;
        }
Esempio n. 6
0
        protected override void RequestDraw()
        {
            if (_level != null)
            {
                DrawPlayground(_level.Map.GetCellCount(), _level.Map.Tiles);

                foreach (var item in _level.Items)
                {
                    float?bodySpeed       = null;
                    float?bodyDirection   = null;
                    float?bodyRadius      = null;
                    float?smellableRadius = null;
                    float?viewRange       = null;
                    float?viewAngle       = null;
                    float?viewDirection   = null;
                    float?attackRange     = null;

                    // Movement
                    if (item.ContainsProperty <WalkingProperty>())
                    {
                        WalkingProperty prop = item.GetProperty <WalkingProperty>();
                        bodySpeed     = prop.Speed;
                        bodyDirection = prop.Direction;
                    }

                    // Kollisionsradius
                    if (item.ContainsProperty <CollidableProperty>())
                    {
                        CollidableProperty prop = item.GetProperty <CollidableProperty>();
                        bodyRadius = prop.CollisionRadius;
                    }

                    // Sicht
                    if (item.ContainsProperty <SightingProperty>())
                    {
                        SightingProperty prop = item.GetProperty <SightingProperty>();
                        viewRange     = prop.ViewRange;
                        viewDirection = prop.ViewDirection.Radian;
                        viewAngle     = prop.ViewAngle;
                    }

                    // Attack
                    if (item.ContainsProperty <AttackerProperty>())
                    {
                        AttackerProperty prop = item.GetProperty <AttackerProperty>();
                        attackRange = prop.AttackRange;
                    }

                    // Stinkender radius
                    if (item.ContainsProperty <SmellableProperty>())
                    {
                        SmellableProperty prop = item.GetProperty <SmellableProperty>();
                        smellableRadius = prop.SmellableRadius;
                    }

                    Color color       = Color.Gray;
                    Color?borderColor = null;

                    // Farbe
                    if (item is AnthillItem)
                    {
                        color = Color.Brown;
                    }
                    else if (item is SugarItem)
                    {
                        color = Color.White;
                    }
                    else if (item is AppleItem)
                    {
                        color = Color.LightGreen;
                    }
                    else if (item is BugItem)
                    {
                        color = Color.Blue;
                    }
                    else if (item is AntItem)
                    {
                        color = Color.LightGray;
                        AntItem ant = item as AntItem;
                        switch (ant.PlayerIndex)
                        {
                        case 0: borderColor = Color.Orange; break;

                        case 1: borderColor = Color.Red; break;

                        case 2: borderColor = Color.Yellow; break;

                        case 3: borderColor = Color.Green; break;

                        case 4: borderColor = Color.Blue; break;

                        case 5: borderColor = Color.Purple; break;

                        case 6: borderColor = Color.White; break;

                        case 7: borderColor = Color.Black; break;
                        }
                    }
                    else if (item is MarkerItem)
                    {
                        color = Color.LightGray;
                        MarkerItem marker = item as MarkerItem;
                        switch (marker.PlayerIndex)
                        {
                        case 0: borderColor = Color.Orange; break;

                        case 1: borderColor = Color.Red; break;

                        case 2: borderColor = Color.Yellow; break;

                        case 3: borderColor = Color.Green; break;

                        case 4: borderColor = Color.Blue; break;

                        case 5: borderColor = Color.Purple; break;

                        case 6: borderColor = Color.White; break;

                        case 7: borderColor = Color.Black; break;
                        }
                    }

                    // Malen
                    DrawItem(item.Id, item.Position,
                             bodyRadius, bodyDirection, bodySpeed, color,
                             viewRange, viewDirection, viewAngle,
                             attackRange, smellableRadius, borderColor);
                }
            }
        }
Esempio n. 7
0
        protected override void RequestDraw()
        {
            if (_engine != null)
            {
                DrawPlayground(_engine.Map.GetCellCount(), _engine.Map.Tiles);

                foreach (var item in _engine.Items)
                {
                    float?bodySpeed       = null;
                    float?bodyDirection   = null;
                    float?bodyRadius      = null;
                    float?smellableRadius = null;
                    float?viewRange       = null;
                    float?viewAngle       = null;
                    float?viewDirection   = null;
                    float?attackRange     = null;

                    // Movement
                    if (item.ContainsProperty <WalkingProperty>())
                    {
                        WalkingProperty prop = item.GetProperty <WalkingProperty>();
                        bodySpeed     = prop.Speed;
                        bodyDirection = prop.Direction;
                    }

                    // Kollisionsradius
                    if (item.ContainsProperty <CollidableProperty>())
                    {
                        CollidableProperty prop = item.GetProperty <CollidableProperty>();
                        bodyRadius = prop.CollisionRadius;
                    }

                    // Sicht
                    if (item.ContainsProperty <SightingProperty>())
                    {
                        SightingProperty prop = item.GetProperty <SightingProperty>();
                        viewRange     = prop.ViewRange;
                        viewDirection = prop.ViewDirection.Radian;
                        viewAngle     = prop.ViewAngle;
                    }

                    // Attack
                    if (item.ContainsProperty <AttackerProperty>())
                    {
                        AttackerProperty prop = item.GetProperty <AttackerProperty>();
                        attackRange = prop.AttackRange;
                    }

                    // Stinkender radius
                    if (item.ContainsProperty <SmellableProperty>())
                    {
                        SmellableProperty prop = item.GetProperty <SmellableProperty>();
                        smellableRadius = prop.SmellableRadius;
                    }

                    DrawItem(item.Id, item.Position,
                             bodyRadius, bodyDirection, bodySpeed, Color.White,
                             viewRange, viewDirection, viewAngle,
                             attackRange, smellableRadius, null);
                }
            }
        }
 private void InitSmellableItem(Vector2 pos)
 {
     SmellableItem = new DebugSmellableItem(pos);
     Smellable = SmellableItem.GetProperty<SmellableProperty>();
     Engine.InsertItem(SmellableItem);
 }
 public void CleanupEngine()
 {
     VisibleItem = null;
     SightingItem = null;
     SmellableItem = null;
     SnifferItem = null;
     Visible = null;
     Sighting = null;
     Smellable = null;
     Sniffer = null;
     Map = null;
     Engine = null;
 }
Esempio n. 10
0
 private void InitSmellableItem(Vector2 pos)
 {
     SmellableItem = new DebugSmellableItem(pos);
     Smellable     = SmellableItem.GetProperty <SmellableProperty>();
     Engine.InsertItem(SmellableItem);
 }