public override void OnPlayerEntered(ITileAttributeArgs args) { var attribute = args.Attribute as WarpTileAttribute; var player = (args as TileAttributePlayerArgs).Player; var tile = (args as TileAttributePlayerArgs).Tile; if (player.MapID != attribute.WarpMap) { var map = Engine.Services.Get <WorldManager>().GetMap(attribute.WarpMap); if (map != null) { player.JoinMap(map); var newLayer = map.Layers.FirstOrDefault(l => l.Name == attribute.LayerName); if (newLayer != null) { player.Layer = newLayer; } } else { Engine.Services.Get <Logger>().LogEvent($"Player {player.Descriptor.Name} stepped on warp tile where destination does not exist!", LogTypes.ERROR, new Exception($"Player {player.Descriptor.Name} stepped on warp tile where destination does not exist!")); return; } } player.WarpTo(new Vector(attribute.X, attribute.Y)); }
public override void OnUpdate(ITileAttributeArgs args) { Tile tile = (args as TileAttributeUpdateArgs).Tile; GameTime gameTime = (args as TileAttributeUpdateArgs).GameTime; var attribute = args.Attribute as NPCSpawnTileAttribute; if (_nextNPCSpawnTime <= gameTime.TotalGameTime.TotalMilliseconds && _heartbeatListener.NPCs.Count < attribute.MaxSpawns) { var npcDesc = Engine.Services.Get <NPCManager>().Get(attribute.NPCID); if (npcDesc == null) { Engine.Services.Get <Logger>().LogEvent($"Error spawning NPC: {attribute.NPCID} does not exist!", LogTypes.ERROR, new Exception($"Error spawning NPC: {attribute.NPCID} does not exist!")); return; } NPC npc = new NPC(npcDesc, tile.Layer.Map) { Layer = tile.Layer }; npc.WarpTo(tile.Position); // This allows the tile spawner to keep track of npcs that exist, and respawn if neccessary (i.e., they die). _heartbeatListener.NPCs.Add(npc); _nextNPCSpawnTime = gameTime.TotalGameTime.TotalMilliseconds + (attribute.RespawnTime * 1000); } }
public override void OnPlayerEntered(ITileAttributeArgs args) { Player player = (args as TileAttributePlayerArgs).Player; string dialogueName = (args.Attribute as StartDialogueTileAttribute).DialogueName; string branchName = (args.Attribute as StartDialogueTileAttribute).BranchName; Engine.Services.Get <DialogueManager>().Get(dialogueName).Start(branchName, player); }
public override void OnPlayerLeft(ITileAttributeArgs args) { }
public override void OnPlayerEntered(ITileAttributeArgs args) { }
public override void OnInitalize(ITileAttributeArgs args) { }
public abstract void OnUpdate(ITileAttributeArgs args);
public abstract void OnPlayerLeft(ITileAttributeArgs args);
public abstract void OnPlayerEntered(ITileAttributeArgs args);
public abstract void OnInitalize(ITileAttributeArgs args);
public override void OnUpdate(ITileAttributeArgs args) { }