예제 #1
0
 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);
 }
예제 #2
0
 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"])))
     });
 }
예제 #3
0
 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));
 }
예제 #4
0
 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)
     }));
 }
예제 #5
0
 public void Remove(MapEvent mapEvent)
 {
     _events.Value[mapEvent.Position.ToString()].Remove(mapEvent);
     _json.Save(_mapPath, _events.Value.Values.SelectMany(eventList => eventList));
 }