public void enter(MonsterUnit enemy) { self = enemy; target = GameObject.FindGameObjectWithTag("Player").transform; selfRigidbody = self.GetComponent <Rigidbody>(); attackHandler(self.centerPoint.spawnMonsterType.name); }
public void enter(MonsterUnit enemy) { self = enemy; target = GameObject.FindGameObjectWithTag("Player").transform; selfRigidbody = self.GetComponent<Rigidbody>(); attackHandler(self.centerPoint.spawnMonsterType.name); }
public void CompleteGenerate(bool monsters = true) { if (monsters) { List <Transform> possiblePositions = new List <Transform>(monsterPositions); int monsterCount = Random.Range(minMonsters, maxMonsters + 1); for (int i = 0; i < monsterCount && i < monsterPositions.Length; i++) { int index = Random.Range(0, possiblePositions.Count); Transform t = possiblePositions[index]; possiblePositions.RemoveAt(index); MonsterUnit prefab = monsterPrefabs[Random.Range(0, monsterPrefabs.Length)]; MonsterUnit unit = Instantiate(prefab, t.position, t.rotation); unit.GetComponent <UnitMovementController>().Enable(); unit.transform.parent = t; spawnedMonsters.Add(unit); } } GetComponentInChildren <NavMeshLink>(true).gameObject.SetActive(true); }