/// <summary> /// Generation of Enemies /// </summary> private void GenerateEnemy(ENEMIES_SPAWN_STYLE _style, Lane_Mk2 _lane, int _index) { // Create Enemies AI_Controller tempEnemy = Instantiate(m_enemyPrefab, transform.parent, true); tempEnemy.transform.localScale = new Vector3(m_scaleMultiplier, m_scaleMultiplier, m_scaleMultiplier); // Offset Variables ---- HACK #3 KMS yes float m_offsetZ = 0.25f * transform.localScale.z; // Based on Style, position the enemies accordingly tempEnemy.transform.position = _lane.m_enemySpawnPoint.position; switch (_style) { case ENEMIES_SPAWN_STYLE.W_STYLE: switch (m_laneLayout) { case LANE_LAYOUT.HORIZONTAL: switch (_index % 2) { case 0: break; case 1: // Add a z offset tempEnemy.transform.localPosition -= _lane.m_enemySpawnPoint.forward * m_offsetZ; // Add a x offset tempEnemy.transform.localPosition += _lane.m_enemySpawnPoint.right * m_widthLane * 0.5f; Destroy(tempEnemy.transform.Find("ProjectileSpawner").gameObject); return; } break; case LANE_LAYOUT.CIRCULAR: // generate surrounding in a circle break; } break; default: break; } // Add a z offset //tempEnemy.transform.localPosition -= _lane.m_enemySpawnPoint.forward * m_offsetZ; // Make Enemy look accordingly to lane layout switch (m_laneLayout) { case LANE_LAYOUT.HORIZONTAL: tempEnemy.transform.forward = m_laneList[0].transform.forward; break; case LANE_LAYOUT.CIRCULAR: tempEnemy.transform.LookAt(transform); break; } }
/// <summary> /// Generation of Lanes in a Horizontal Layout /// </summary> private void GenerateHorizontalLayout() { // Set Starting Position for generating m_startingSpawnPos = new Vector3(((m_spawnPoint.localPosition.x - m_renderer.bounds.extents.x) / m_widthBounds) + m_widthLane * 0.5f, 0.0f, 0.0f); for (int i = 0; i < m_numLanes; ++i) { // Create a new Lane Lane_Mk2 tempLane = Instantiate(m_lanePrefab, transform); // Set Scale of Lane tempLane.transform.localScale = new Vector3(m_widthLane, tempLane.transform.localScale.y, 1f); // Set Position of Lane tempLane.transform.localPosition = m_startingSpawnPos + m_spawnPoint.localPosition; // HACK # 2 m_startingSpawnPos.x += m_widthLane; // Set Forward tempLane.transform.forward = -tempLane.transform.forward; // Add to list m_laneList.Add(tempLane); } }
/// <summary> /// Generation of Lanes in a Circular Layout /// </summary> private void GenerateCircularLayout() { // Angle in degrees between each lane float m_angleBetweenLanes = 360f / m_numLanes; // Radius of the circular area in the middle of lanes float m_radius = Mathf.Max(m_renderer.bounds.extents.x, m_renderer.bounds.extents.z); for (int i = 0; i < m_numLanes; ++i) { Lane_Mk2 tempLane = Instantiate(m_lanePrefab, transform.parent); float m_offsetPos = tempLane.GetComponent <Renderer>().bounds.extents.z; // Rotate Lane according to forward of transform - R tempLane.transform.rotation = transform.rotation; // Set position of lane - T tempLane.transform.position = m_spawnPoint.position; tempLane.transform.position += tempLane.transform.forward * (m_radius + m_offsetPos); // Set Forward tempLane.transform.forward = -tempLane.transform.forward; // Rotate transform to face next spawn direction transform.Rotate(Vector3.up, m_angleBetweenLanes); m_laneList.Add(tempLane); } }