public NPC(WorldState world, Point originTile, NPCTemplate template) : base(world, template.Name) { OriginTile = originTile; Template = template; Template.InitializeSelf(this); }
/// <summary> /// Revisa entre los templates de la habitación actual buscando el keyword dado por el jugador. /// Devuelve el enemigo que encuentre. /// </summary> /// <param name="keywordGiven"></param> /// <param name="currentRoom"></param> /// <returns></returns> public NPCTemplate TryToFight(string[] keywordGiven, RoomObject currentRoom) { string[] newString = new string[keywordGiven.Length - 1]; for (int i = 1; i < keywordGiven.Length; i++) { newString[i - 1] = keywordGiven[i]; } vsPlayer = false; for (int i = 0; i < currentRoom.npcTemplatesInRoom.Count; i++) { NPCTemplate npc = currentRoom.npcTemplatesInRoom[i]; if (npc.GetType() == typeof(EnemyNPCTemplate)) { foreach (string keyword in npc.keywords) { foreach (string keyworkByPlayer in newString) { if (keyword == keyworkByPlayer) { vsPlayer = false; return(npc); } } } } } return(null); }
/// <summary> /// Spawns a new NPC in the world. /// </summary> /// <param name="template">The template to create the NPC from.</param> /// <param name="position">The position to spawn the NPC at.</param> /// <returns>The newly spawned NPC.</returns> public NPC SpawnNPC(NPCTemplate template, Point position) { NPC npc = new NPC(this, position, template); _npcs.Add(npc); npc.MoveInstantly(position); npc.Template.Behavior.OnSpawned(npc); return(npc); }
public string buildPhrase() { string phrase = ""; switch (action) { case ActionType.Kill: phrase += "Mata"; break; case ActionType.Visit: phrase += "Ve a"; break; case ActionType.Talk: phrase += "Habla con"; break; case ActionType.GetItem: phrase += "Consigue"; break; default: break; } phrase += " "; switch (type) { case ActorType.NPC: if (idType == IdType.Template) { NPCTemplate data = NPCTemplate.get(id); phrase += data.name; } else { NPCData data = NPC.get(id); phrase += data.name; } break; case ActorType.Item: ItemData item = Item.get(id); phrase += item.name; break; } phrase += " "; if (quantity > 1) { phrase += currentQuantity + "/" + quantity; } return(phrase); }
public string buildPhrase() { string phrase = ""; switch (action) { case ActionType.Kill: phrase += LanguageManager.get("TASK_KILL"); break; case ActionType.Visit: phrase += LanguageManager.get("TASK_VISIT"); break; case ActionType.Talk: phrase += LanguageManager.get("TASK_TALK"); break; case ActionType.GetItem: phrase += LanguageManager.get("TASK_GET_ITEM"); break; default: break; } phrase += " "; switch (type) { case ActorType.NPC: if (idType == IdType.Template) { NPCTemplate data = NPCTemplate.get(id); phrase += data.name; } else { NPCData data = NPC.get(id); phrase += data.name; } break; case ActorType.Item: ItemData item = Item.get(id); phrase += item.name; break; } phrase += " "; if (quantity > 1) { phrase += currentQuantity + "/" + quantity; } return(phrase); }
public override void RespondToInput(GameController controller, string[] separatedInputWords, string[] separatedCompleteInputWords) { if (separatedInputWords.Length > 1) { PlayerInstance player = controller.combatController.TryToFightPlayer(separatedCompleteInputWords, controller.playerRoomNavigation.currentRoom); if (player != null) { controller.LogStringWithReturn("Atacas a " + player.playerName); NetworkManager.Instance.TryToAttack(player.playerName); controller.LogStringWithReturn("¡Inicia el combate!"); TextUserInput.OnFight += StartFight; controller.combatController.PrepareFight(player, controller.playerManager); controller.LogStringWithReturn(" "); return; } NPCTemplate npcToAttack = controller.combatController.TryToFight(separatedInputWords, controller.playerRoomNavigation.currentRoom); EnemyNPC enemy = controller.playerRoomNavigation.PickAnEnemy((EnemyNPCTemplate)npcToAttack); if (npcToAttack == null) { controller.LogStringWithReturn("No puedes atacar a " + separatedCompleteInputWords[1] + "."); return; } if (enemy == null && player == null) { controller.LogStringWithReturn("No hay un " + separatedInputWords[1] + " al que atacar."); return; } controller.LogStringWithReturn("¡Inicia el combate!"); TextUserInput.OnFight += StartFight; controller.combatController.PrepareFight(enemy, controller.playerManager); controller.LogStringWithReturn(" "); } else { controller.LogStringWithReturn("Das un puño al aire."); } }
public static NPCData fillById(NPCData.creatureTemplate id, int level) { int _id = (int)id; NPCData npc = new NPCData(); NPCTemplate template = NPCTemplate.get(_id); npc.name = template.name; npc.template = _id; npc.race = template.creatureRace; npc.subRace = template.creatureSubRace; npc.level = level; npc.health = template.healthBase * level; npc.isAggresive = template.isAgressive; return(npc); }
/// <summary> /// Attempts a random encounter. Call this after every step while in encounter areas. /// </summary> /// <param name="world"></param> /// <returns></returns> public static bool TryRandomEncounter(WorldState world) { List <NPCTemplate> encounters; if (!_encounters.TryGetValue(world.Map.Info.Environment, out encounters)) { return(false); } bool didEncounter = (new Random((int)world.Game.TotalUpdates).NextDouble() < 0.3); NPCTemplate encounteredNPC = encounters[new Random((int)world.Game.TotalUpdates + 1337).Next() % encounters.Count]; if (didEncounter) { // spawn a new NPC but don't actually add it to the world NPC entity = new NPC(world, new Point(0, 0), encounteredNPC); world.StartCombat(entity); } return(didEncounter); }
public static void insertNPCTemplates() { NPCTemplate template; template = new NPCTemplate(); template.id = (int)NPCData.creatureTemplate.CastleSpider; template.name = "Araña del castillo"; template.creatureRace = NPCData.creatureRace.Monster; template.creatureSubRace = NPCData.creatureSubRace.Normal; template.isAgressive = true; template.healthBase = 100; template.create(); template = new NPCTemplate(); template.id = (int)NPCData.creatureTemplate.Human; template.name = "Default name"; template.creatureRace = NPCData.creatureRace.Human; template.creatureSubRace = NPCData.creatureSubRace.Normal; template.isAgressive = false; template.healthBase = 100; template.create(); }
public static void insertNPCTemplates() { NPCTemplate template; template = new NPCTemplate(); template.id = (int)NPCData.creatureTemplate.CastleSpider; template.name = "Araña del castillo"; template.creatureRace = NPCData.creatureRace.Monster; template.creatureSubRace = NPCData.creatureSubRace.Normal; template.isAgressive = true; template.healthBase = 100; template.create (); template = new NPCTemplate(); template.id = (int)NPCData.creatureTemplate.Human; template.name = "Mike"; template.creatureRace = NPCData.creatureRace.Human; template.creatureSubRace = NPCData.creatureSubRace.Normal; template.isAgressive = false; template.healthBase = 100; template.create (); }
public static void insertNPCs() { NPCData npc; List <Vector3> waypoints = new List <Vector3>(); int i = 1; npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 25); npc.id = i++; npc.name = "Mike Ghole"; npc.subRace = NPCData.creatureSubRace.Seller; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.CastleSpider, 5); npc.id = i++; npc.create(); waypoints = new List <Vector3>(); waypoints.Add(new Vector3(7.56f, 0.00f, -0.81f)); waypoints.Add(new Vector3(1.08f, 0.00f, -5.30f)); waypoints.Add(new Vector3(-8.74f, 0.00f, 0.02f)); waypoints.Add(new Vector3(0.35f, 0.00f, 3.60f)); insertWaypointsTo(npc.id, waypoints); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 25); npc.id = i++; npc.name = "Instructor"; npc.subRace = NPCData.creatureSubRace.Quest; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 40); npc.id = i++; npc.name = "Hagrid"; npc.subRace = NPCData.creatureSubRace.Quest; npc.create(); }
public FieldNPC(NPCTemplate template) { Template = template; Registry = new Dictionary <string, string>(); }
public NPC(NPCTemplate template) { name = template.name; }
public static void insertNPCs() { NPCData npc; List <Vector3> waypoints = new List <Vector3>(); int i = 1; npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 25); npc.id = i++; npc.name = "Mike Ghole"; npc.subRace = NPCData.creatureSubRace.Seller; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.CastleSpider, 5); npc.id = i++; npc.create(); waypoints = new List <Vector3>(); waypoints.Add(new Vector3(7.56f, 0.00f, -0.81f)); waypoints.Add(new Vector3(1.08f, 0.00f, -5.30f)); waypoints.Add(new Vector3(-8.74f, 0.00f, 0.02f)); waypoints.Add(new Vector3(0.35f, 0.00f, 3.60f)); insertWaypointsTo(npc.id, waypoints); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 25); npc.id = i++; npc.name = "Instructor"; npc.subRace = NPCData.creatureSubRace.Quest; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 40); npc.id = i++; npc.name = "Hagrid"; npc.subRace = NPCData.creatureSubRace.Quest; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 40); npc.id = i++; npc.name = "Estudiante"; npc.subRace = NPCData.creatureSubRace.Talker; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 40); npc.id = i++; npc.name = "Estudiante"; npc.subRace = NPCData.creatureSubRace.Talker; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 40); npc.id = i++; npc.name = "Estudiante"; npc.subRace = NPCData.creatureSubRace.Talker; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 40); npc.id = i++; npc.name = "Estudiante"; npc.subRace = NPCData.creatureSubRace.Normal; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 40); npc.id = i++; //This is 9 npc.name = "Student"; npc.subRace = NPCData.creatureSubRace.Talker; npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 50); npc.id = i++; // 10 npc.name = "Professor Quirel"; npc.subRace = NPCData.creatureSubRace.Normal; waypoints = new List <Vector3>(); waypoints.Add(new Vector3(-6.82f, 0.00f, -4f)); waypoints.Add(new Vector3(-5.96f, 0.00f, -5f)); waypoints.Add(new Vector3(-1.96f, 0.01f, 4f)); insertWaypointsTo(npc.id, waypoints); npc.create(); // END ----------------- npc = NPCTemplate.fillById(NPCData.creatureTemplate.Human, 50); npc.id = i++; // 11 npc.name = "Draco"; npc.isAggresive = true; npc.attackRange = 6; npc.attacksPerSecond = 0.25f; npc.subRace = NPCData.creatureSubRace.Normal; waypoints = new List <Vector3>(); waypoints.Add(new Vector3(6.65f, 0.01f, -3.00f)); waypoints.Add(new Vector3(-0.75f, 0.01f, -9.16f)); waypoints.Add(new Vector3(-4.18f, 0.01f, -3.61f)); insertWaypointsTo(npc.id, waypoints); npc.create(); }
public FieldNPCGenerator(FieldLifeTemplate lifeTemplate, NPCTemplate npcTemplate) { _lifeTemplate = lifeTemplate; _npcTemplate = npcTemplate; }
public FieldNPC(NPCTemplate template, bool left = true) { Template = template; MoveAction = Convert.ToByte(left); }
public TrunkDialog(FieldUser user, NPCTemplate template, ItemTrunk trunk) : base(user) { _template = template; _trunk = trunk; }
public FieldNPC(NPCTemplate template) { Template = template; }
public override void OnEnter(GameState previousState) { if (_transitionRenderTarget == null) { _transitionRenderTarget = new RenderTarget2D(Game.GraphicsDevice, 480, 270, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents); } if (_spawnArgs.OldPlayer != null) { Player = new Player(this, _spawnArgs.OldPlayer); } else { Player = new Player(this, _playerName); } if (_spawnArgs.Position != new Point(-1, -1)) { Player.MoveInstantly(_spawnArgs.Position); } _lastPlayerPos = Player.Position; Player.Heading = _spawnArgs.Direction; for (int x = 0; x < Map.Width; x++) { for (int y = 0; y < Map.Height; y++) { if (Map[Tile.MapLayer.NPC, x, y] != DefaultTiles.EmptyNPC) { SpawnNPC(NPCTemplate.FromTile(Map[Tile.MapLayer.NPC, x, y]), new Point(x, y)); } } } if (_useTransiton) { _transition = new TweenedDouble(Game, 1); _transition.TweenTo(0, TweenEaseType.Linear, 0.4); Paused = true; } else { _transition = new TweenedDouble(Game, 0); Coroutine.Start(ShowMapName); } Camera = new Camera(this); Game.IsMouseVisible = false; if (Map.TransitionCache != null) { Map.TransitionCache.Clear(); } if (Map.Atlas != null) { Map.Atlas.Clear(); } }