public AttackState(TownspersonClass ch) : base(ch) { this.hitbox = ch.hitbox; didAttack = false; dashTimer = 0f; recoveryTimer = 0f; }
//resuses/generates villagers/guards that live in this building public void Populate() { int count = type == BuildingType.HOME ? UnityEngine.Random.Range(1, 5) : UnityEngine.Random.Range(3, 6); List <Vector2> points = world.GetValidPoints(nodeID, count); List <GameObject> pool = type == BuildingType.HOME ? villagerPool : guardPool; for (int i = 0; i < pool.Count; i++) { if (points.Count == 0) { for (int j = i; j < pool.Count; j++) { pool[j].SetActive(false); } break; } Vector2 point = points[0]; TownspersonClass townie = pool[i].GetComponent <TownspersonClass>(); townie.trans.position = townie.SetFloorPosition(point); townie.Reset();//does not do specific townie reset, just base reset pool[i].SetActive(true); points.Remove(point); } for (int i = 0; i < points.Count; i++) { GameObject obj = type == BuildingType.HOME ? Instantiate(world.villagerPrefabs[UnityEngine.Random.Range(0, world.villagerPrefabs.Count)], trans) : Instantiate(world.guardPrefabs[UnityEngine.Random.Range(0, world.guardPrefabs.Count)], trans); TownspersonClass townie = obj.GetComponent <TownspersonClass>(); townie.Init(); townie.SetNodeID(nodeID); townie.SetBuilding(this); townie.trans.position = townie.SetFloorPosition(points[i]); pool.Add(obj); } }