private void RemoveNpc(NpcName npcName) { if (CurrentWorld != null) { try { NPC npc = CurrentWorld.NPCs.First(n => n.Name == npcName.Character); CurrentWorld.NPCs.Remove(npc); Points.Remove(npcName.Character); MessageBox.Show(string.Format("{1} ({0}) removed.", npcName.Character, npcName.Name), "NPC Removed"); } catch (InvalidOperationException) { MessageBox.Show(string.Format("{1} ({0}) was not on the map.", npcName.Character, npcName.Name), "NPC Doesn't Exist"); } } }
private void AddNpc(NpcName npc) { if (CurrentWorld != null) { if (!CurrentWorld.NPCs.Any(n => n.Name == npc.Character)) { var spawn = new Vector2Int32(CurrentWorld.SpawnX, CurrentWorld.SpawnY); CurrentWorld.NPCs.Add(new NPC{Home = spawn, IsHomeless = true, Name = npc.Character, Position= new Vector2(spawn.X * 16, spawn.Y * 16), SpriteId = npc.Id}); Points.Add(npc.Character); MessageBox.Show(string.Format("{1} ({0}) added to spawn.", npc.Character, npc.Name), "NPC Added"); } else { MessageBox.Show(string.Format("{1} ({0}) is already on the map.", npc.Character, npc.Name), "NPC Exists"); } } }