private void UpdateSoldierDefend() { if (this.targetTown == null) { Goblins goblins = GameObject.FindObjectOfType(typeof(Goblins)) as Goblins; if (goblins != null && !goblins.AreKilled() && goblins.targetTown != null) { Town town = goblins.targetTown; Dictionary <string, string> parameters = this.GetDialogParameters(); parameters.Add("townName", town.townName); this.SetTargetTown(town); } } }
public void ArriveAtTown(Town town, bool isDestination) { if (this.type == Type.Bard && isDestination) { if (town.townId == "mission") { StartCoroutine("FadeOut"); print("Available bards: " + string.Join(", ", GameState.availableBards.ToArray())); } else { town.ProcessStories(this.heardStories.ToArray()); foreach (string storyId in town.folkSongs) { if (!GameState.KnowsStory(storyId)) { this.LearnStory(storyId); this.ShowDialog("learn_folk_song"); } } } } if (this.type != Type.Bard && town.townId == "mission") { bool learned = false; List <Story> newStories = new List <Story>(); foreach (Story story in this.heardStories) { if (!GameState.KnowsStory(story)) { learned = true; GameState.AddKnownStory(story); newStories.Add(story); } } if (learned) { Dictionary <string, string> parameters = new Dictionary <string, string>() { { "speakerId", this.state.id }, { "speakerName", this.state.name }, { "storyName", newStories[0].title } }; GameState.ShowDialog("learn_from_unit", parameters); } } //TODO refactor Goblins goblins = GameObject.FindObjectOfType(typeof(Goblins)) as Goblins; if (goblins.targetTown == town && !goblins.AreKilled()) { if (this.mode == Mode.SoldierDefend) { goblins.Kill(); this.animator.SetTrigger("WarriorFight"); } else { this.BeScaredByGoblins(town); } } if (this.mode == Mode.AdventurerRing) { if (Ring.IsAtTown(town)) { Ring ring = GameObject.FindObjectOfType(typeof(Ring)) as Ring; this.ShowDialog("find_ring"); ring.GiveToPerson(this); } } if (this.mode == Mode.AdventurerDeliver && Ring.BelongsTo(this) && town.townId == "fairy_castle") { this.ShowDialog("deliver_ring"); Ring ring = GameObject.FindObjectOfType(typeof(Ring)) as Ring; ring.GiveToPerson(Unit.GetUnit("queen")); Door door = Town.GetTown("door_west") as Door; door.SetOpen(true); } }