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); }
public ScenarioElement CreateMapElement(Point position, MapElements type) { if (mapElementCreator.ContainsKey(type) != true) { return(null); } return(mapElementCreator[type](position, type)); }
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)); } }
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); }
/// <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"); }
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); }
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); }
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)); }
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)); }
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); }
public bool PlayerHasObject(MapElements obj) { return(scenMan.LoadedScenario.PlayerHasObject(obj)); }
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)); }
public bool PlayerHasObject(MapElements obj) { return(CurrPlayerState.HasObject(obj)); }
public Point FindCharacterPos(MapElements character) { return(BaseAction.FindCharacter(scenMan.LoadedScenario, character).Position); }
public void RemObjectFromPlayer(MapElements obj) { CurrPlayerState.RemObject(obj); }
public Point FindObjetPos(MapElements obj) { return(BaseAction.FindObject(scenMan.LoadedScenario, obj).Position); }
public ClimbLadderArg(DynamicElement character, MapElements ladderType) : base(character) { LadderType = ladderType; }
/// <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; }
/// <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; }