public static DynamicElement GetDynamicElementAround(
            Scenario scenario,
            Point charPos,
            MapElements type,
            Func <Scenario, Point, DynamicElement> GetElem
            )
        {
            var obj = GetElem(scenario, DirUtils.GetNorthFromPos(charPos));

            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            obj = GetElem(scenario, DirUtils.GetEastFromPos(charPos));
            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            obj = GetElem(scenario, DirUtils.GetSouthFromPos(charPos));
            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            obj = GetElem(scenario, DirUtils.GetWestFromPos(charPos));
            if (obj != null && obj.Type == type)
            {
                return(obj);
            }

            return(null);
        }
 public static bool IsDynamicElementAround(
     Scenario scenario,
     Point charPos,
     MapElements type,
     Func <Scenario, Point, DynamicElement> GetElem
     )
 {
     return(GetDynamicElementAround(scenario, charPos, type, GetElem) != null);
 }
Exemplo n.º 3
0
        public ScenarioElement CreateMapElement(Point position, MapElements type)
        {
            if (mapElementCreator.ContainsKey(type) != true)
            {
                return(null);
            }

            return(mapElementCreator[type](position, type));
        }
Exemplo n.º 4
0
 public T GetMapElementByName <T>(string name)
 {
     if (typeof(T) == typeof(IMapElement))
     {
         return((T)MapElements.FirstOrDefault(x => x.Key == name));
     }
     else
     {
         return((T)MapPath.FirstOrDefault(x => x.Key == name));
     }
 }
Exemplo n.º 5
0
        void ParseMapElement(Point position, MapElements type)
        {
            var elem = mapElementCreator.CreateMapElement(position, type);

            if (elem == null)
            {
                MessageBox.Show(string.Format("ParseMapElement doesn't know element {0}", type), "ParseMapElement Failure!");
                return;
            }

            ParseDynamicElement(elem, position);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Jeżeli element jest dodany to zwracamy jego klucz
        /// </summary>
        /// <param name="el"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string AddElementOnMap(StandardElements el, string name)
        {
            if (!MapElements.Exists(x => x.Key == name))
            {
                if (el == StandardElements.Gun)
                {
                    MapElements.Add(new Gun(name));
                    return(name);
                }
                else if (el == StandardElements.SpawnPiont)
                {
                    if (MapElements.FirstOrDefault(x => x.GetType() == typeof(SpawnPoint)) == null)
                    {
                        MapElements.Add(new SpawnPoint(name));
                        return(name);
                    }
                    else
                    {
                        return("There is already spawn point");
                    }
                }
            }

            if (el == StandardElements.ReverseIce)
            {
                if (MapPath.FirstOrDefault(x => x.Key == name) == null)
                {
                    MapPath.Add(new RegularIce(name));
                    return(name);
                }
                else
                {
                    return("There is already spawn point");
                }
            }
            else if (el == StandardElements.NormalIce)
            {
                if (MapPath.FirstOrDefault(x => x.Key == name) == null)
                {
                    MapPath.Add(new RegularIce(name));
                    return(name);
                }
                else
                {
                    return("There is already spawn point");
                }
            }

            return("Coś poszło nie tak");
        }
Exemplo n.º 7
0
        public void InitTestGame(Player player)
        {
            SpawnPoint StartPoint = (SpawnPoint)MapElements.Where(x => typeof(SpawnPoint) == x.GetType()).FirstOrDefault();

            if (StartPoint != null)
            {
                if (StartPoint.Position.X > 0 && StartPoint.Position.Y > 0)
                {
                    player.Position = StartPoint.Position;
                }
                else
                {
                    //  GraphicsDebugMessage test = new GraphicsDebugMessage();
                    //  test.Message = "huj";
                }
            }
        }
        /// <summary>
        /// Create a new scenario element.
        /// </summary>
        /// <param name="image">Element appearance (image).</param>
        /// <param name="position">Element starting position.</param>
        public ScenarioElement(Bitmap image, Point position, MapElements type)
        {
            Type = type;

            sprite = new PictureBox()
            {
                Image     = image,
                Width     = ScenarioManager.SPRITE_WIDTH,
                Height    = ScenarioManager.SPRITE_HEIGHT,
                BackColor = Color.Transparent
            };

            Position = position;

            IsEnabled = true;

            uiHandler.SetupPictureBox(sprite);
        }
Exemplo n.º 9
0
 public void drawElement(SpriteBatch spriteBatch, MapElements type, int x, int y)
 {
     Vector2 pos = new Vector2(x, y);
     switch (type)
     {
         case MapElements.WALL:
         case MapElements.SPAWN:
         case MapElements.GRASS:
             sprite.setX(1);
             sprite.setY(8);
             break;
         case MapElements.TREE:
             sprite.setX(0);
             sprite.setY(12);
             break;
         default:
             return;
     }
     spriteBatch.Draw(_world_texture, pos, sprite.SourceRect, Color.White, 0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0);
 }
Exemplo n.º 10
0
        private void Init(DataTemplate template)
        {
            Random random = new Random(DateTime.Now.Millisecond);

            foreach (var info in _mapPointsInfo)
            {
                var mapPointViewModel = new MapPointViewModel(info)
                {
                    Count = _mapNameToCount[info.Name]
                };
                mapPointViewModel.Zoom          = Zoom;
                mapPointViewModel.MapPointColor = new SolidColorBrush(Color.FromRgb(
                                                                          (byte)random.Next(1, 255),
                                                                          (byte)random.Next(1, 255),
                                                                          (byte)random.Next(1, 255)));
                PlaceList.Add(mapPointViewModel);
                _mapNameToMapPoint.Add(mapPointViewModel.Name, mapPointViewModel);

                var mapCustomElement = new MapCustomElement()
                {
                    Content         = mapPointViewModel,
                    ContentTemplate = template,
                };

                _mapNameToMapElement.Add(info.Name, mapCustomElement);

                mapCustomElement.MouseLeftButtonDown += OnMapCustomElementClick;

                BindingOperations.SetBinding(mapCustomElement, MapCustomElement.LocationProperty,
                                             new Binding("Location")
                {
                    Source = mapPointViewModel
                });

                MapElements.Add(mapCustomElement);
            }
        }
 public GoapSpNode(int id, int weight, MapElements type) : base(id, weight)
 {
     Type = type;
 }
 public static bool IsCharacterAround(Scenario scenario, Point charPos, MapElements type)
 {
     return(IsDynamicElementAround(scenario, charPos, type, GetCharacterAtPos));
 }
Exemplo n.º 13
0
 public UseKeyArg(DynamicElement character, MapElements keyType, MapElements doorType)
     : base(character)
 {
     KeyType  = keyType;
     DoorType = doorType;
 }
 public static DynamicElement FindCharacter(Scenario scenario, MapElements type)
 {
     return(scenario.CharactersList.Find(elem => elem.Type == type));
 }
 public static DynamicElement FindObject(Scenario scenario, MapElements type)
 {
     return(scenario.ObjectsList.Find(elem => elem.Type == type));
 }
 public static DynamicElement GetObjectAround(Scenario scenario, Point charPos, MapElements type)
 {
     return(GetDynamicElementAround(scenario, charPos, type, GetObjectAtPos));
 }
Exemplo n.º 17
0
 public void AddObjectToPlayer(MapElements obj)
 {
     CurrPlayerState.AddObject(obj);
 }
 public AttackActionArg(DynamicElement character, MapElements enemyType, params MapElements[] weapons)
     : base(character)
 {
     EnemyType = enemyType;
     Weapons   = new List <MapElements>(weapons);
 }
 public void AddObject(MapElements obj)
 {
     objects.Add(obj);
 }
Exemplo n.º 20
0
 public bool PlayerHasObject(MapElements obj)
 {
     return(scenMan.LoadedScenario.PlayerHasObject(obj));
 }
Exemplo n.º 21
0
 public DynamicElement FindCharacter(MapElements character)
 {
     return(BaseAction.FindCharacter(scenMan.LoadedScenario, character));
 }
 public void RemObject(MapElements obj)
 {
     objects.Remove(obj);
 }
 public bool HasObject(MapElements obj)
 {
     return(objects.Contains(obj));
 }
Exemplo n.º 24
0
 public bool PlayerHasObject(MapElements obj)
 {
     return(CurrPlayerState.HasObject(obj));
 }
Exemplo n.º 25
0
 public Point FindCharacterPos(MapElements character)
 {
     return(BaseAction.FindCharacter(scenMan.LoadedScenario, character).Position);
 }
Exemplo n.º 26
0
 public void RemObjectFromPlayer(MapElements obj)
 {
     CurrPlayerState.RemObject(obj);
 }
Exemplo n.º 27
0
 public Point FindObjetPos(MapElements obj)
 {
     return(BaseAction.FindObject(scenMan.LoadedScenario, obj).Position);
 }
 public ClimbLadderArg(DynamicElement character, MapElements ladderType)
     : base(character)
 {
     LadderType = ladderType;
 }
Exemplo n.º 29
0
 /// <summary>
 /// Create a new static element.
 /// </summary>
 /// <param name="image">Element appearance (image).</param>
 /// <param name="position">Element starting position.</param>
 /// <param name="blockeable">The element may block the path?</param>
 public StaticElement(Bitmap image, Point position, MapElements type, bool blockeable = false) : base(image, position, type)
 {
     Blockeable = blockeable;
 }
Exemplo n.º 30
0
 /// <summary>
 /// Create a new dynamic element.
 /// </summary>
 /// <param name="image">Element appearance (image).</param>
 /// <param name="position">Element starting position.</param>
 /// <param name="blockeable">This element blocks the path?</param>
 public DynamicElement(Bitmap image, Point position, MapElements type, bool blockeable = true, bool isPickupable = false)
     : base(image, position, type)
 {
     Blockeable   = blockeable;
     IsPickupable = isPickupable;
 }