void SpawnCharacters() { Vector3[] spawnPoints = m_map.GetSpawnPoints(10); Vector3 playerSpawnPoint, exitSpawnPoint; Helper.FindFurthestPoints(spawnPoints, out playerSpawnPoint, out exitSpawnPoint); // playerSpawnPoint = spawnPoints[0]; // exitSpawnPoint = spawnPoints[1]; m_player = Instantiate(m_playerPrefab, playerSpawnPoint, Quaternion.identity); m_player.m_map = m_map; m_exit = Instantiate(m_exitPrefab, exitSpawnPoint, Quaternion.identity); List <Ant> ants = new List <Ant>(); foreach (Vector3 spawn in spawnPoints) { if (spawn != playerSpawnPoint && spawn != exitSpawnPoint) { CardinalDirections randomDirection = (CardinalDirections)Random.Range(0, (int)CardinalDirections.END); Debug.Log(spawn); Debug.Log(randomDirection); Ant newAnt = Instantiate(m_antPrefab, spawn, Quaternion.Euler(0, (int)randomDirection * -90, 0)); m_map.WorldToGrid(spawn, out newAnt.m_row, out newAnt.m_col); newAnt.m_direction = randomDirection; ants.Add(newAnt); } } m_ants = new Ant[ants.Count]; ants.CopyTo(m_ants); }
void Start() { m_map.WorldToGrid(transform.position, out m_row, out m_col); }