/* public void RemoveEnemy(GameObject enemy, bool stay){ * Person2 p = enemy.GetComponent<Person2>(); * enemy.transform.position -= new Vector3(-100,0,0);// hide off-screen for a bit * occupants.Remove (p); * game.CheckOutEnemy (p, stay); * }*/ // Called at the beginning of the night public bool CheckIn() { foreach (Person2 p in occupants) { if (p != null) { p.Exit(true); } } foreach (Node n in nodes) { n.BoxDisable(); } occupants.Clear(); if (open && items.Count > 0) { // calculate quality int totalcost = 0; foreach (GameObject g in items) { if (g != null) { totalcost += g.GetComponent <Furniture>().buyCost; if (g.GetComponent <Furniture>() is Trap) { (g.GetComponent <Furniture>() as Trap).Reset(); } } } quality = (totalcost / 100) + 1; // Debug.Log(name+" quality: "+quality); GameObject personGen = RandomPerson(true); GameObject pero = Instantiate(personGen, spawnPosition, Quaternion.identity) as GameObject; Person2 p = pero.GetComponent <Person2>(); p.SetRoom(this); occupants.Add(p); for (int i = 0; i < UnityEngine.Random.Range(1, 4); i++) { personGen = RandomPerson(false); pero = Instantiate(personGen, spawnPosition, Quaternion.identity) as GameObject; p = pero.GetComponent <Person2>(); p.SetRoom(this); occupants.Add(p); } game.money += quality * 5; return(true); } else { return(false); } }
// the priest or thug enters/exits a room public void AddEnemy(GameObject enemy) { GameObject g = Instantiate(enemy, spawnPosition, Quaternion.identity) as GameObject; g.transform.position = spawnPosition; Person2 p = g.GetComponent <Person2>(); p.SetRoom(this); occupants.Add(p); }