private void InsertEvent(MapEvent mapEvent, Dictionary <string, List <MapEvent> > events) { if (!events.ContainsKey(mapEvent.Position.ToString())) { events[mapEvent.Position.ToString()] = new List <MapEvent>(); } events[mapEvent.Position.ToString()].Add(mapEvent); }
private void Navigate(MapEvent mapEvent) { GameMap.NavigateTo(new PlayerLocation { MapName = mapEvent.Details[MapName], Transform = new Transform2(new Vector2(int.Parse(mapEvent.Details["x"]), int.Parse(mapEvent.Details["y"]))) }); }
public void Add(MapEvent mapEvent) { if (!_eventTypes.ContainsKey(mapEvent.TypeName)) { throw new ArgumentException("Map events must have key that maps to a map event type."); } InsertEvent(mapEvent, _events.Value); _json.Save(_mapPath, _events.Value.Values.SelectMany(eventList => eventList)); }
public GameObject Instantiate(MapEvent mapEvent) { return(Entity.Create("teleport", mapEvent.Position) .Add(new Collision { IsBlocking = false }) .Add(x => new BoxCollider(x.World)) .Add(new StepTrigger()) .Add(new OnCollision { Action = _ => Navigate(mapEvent) })); }
public void Remove(MapEvent mapEvent) { _events.Value[mapEvent.Position.ToString()].Remove(mapEvent); _json.Save(_mapPath, _events.Value.Values.SelectMany(eventList => eventList)); }