Unit SpawnPerson(string id) { GameState.PersonTemplate template = GameState.GetPersonTemplate(id); Unit unit = (GameObject.Instantiate(this.unitPrefab, this.transform.position, Quaternion.identity) as GameObject).GetComponent <Unit>(); GameState.PersonState state = GameState.InstantiatePersonFromTemplate(template, id); state.position = this.transform.position; unit.LoadState(state); unit.ArriveAtTown(this, true); return(unit); }
public void Start() { this.townOffset = Random.onUnitSphere; this.townOffset.z = 0; if (this.state == null) { this.state = new GameState.PersonState(); this.state.id = Random.Range(0, int.MaxValue).ToString(); this.currentTown = this.GetNearestTown(); } }
public void NextButtonPressed() { //Add the bard to the game if (GameState.availableBards.Count > 0) { string id = GameState.availableBards[0]; GameState.availableBards.RemoveAt(0); GameState.PersonState bard = GameState.InstantiatePersonFromTemplate(id, id); bard.placeAtTown = "mission"; bard.heardStories = this.GetSelectedStories(); bard.targetTown = GameState.targetTown.id; GameState.StorePerson(bard); print("Bards remaining: " + string.Join(", ", GameState.availableBards.ToArray())); } Application.LoadLevel("Map"); }
public void LoadState(GameState.PersonState state) { this.state = state; Vector3 position; if (state.placeAtTown != null) { print("Placing at town: " + state.placeAtTown); position = Town.GetTown(state.placeAtTown).transform.position; state.placeAtTown = null; } else { position = state.position; } this.transform.position = position; this.id = state.id; this.type = state.type; this.mode = state.mode; this.speed = state.speed; this.heardStories = new List <Story>(this.state.heardStories); if (this.state.nextTown != null) { this.nextTown = Town.GetTown(state.nextTown); } if (this.state.targetTown != null) { this.SetTargetTown(Town.GetTown(state.targetTown)); } else { this.currentTown = this.GetNearestTown(); } this.mainSprite.sprite = this.GetSprite(this.type); //For bard fadeout if (this.type == Type.Bard && this.currentTown == this.targetTown && this.currentTown.townId == "mission") { StartCoroutine(FadeOut()); } this.InitializeAnimations(); }