public override void Spawn(TrackSegment segment, float t) { //the tutorial very firts barricade need to be center and alone, so player can swipe safely in bother direction to avoid it bool isTutorialFirst = TrackManager.instance.isTutorial && TrackManager.instance.segments.Count == 0; int count = isTutorialFirst ? 1 : Random.Range(k_MinObstacleCount, k_MaxObstacleCount + 1); int startLane = isTutorialFirst ? 0 : Random.Range(k_LeftMostLaneIndex, k_RightMostLaneIndex + 1); Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); for (int i = 0; i < count; ++i) { int lane = startLane + i; lane = lane > k_RightMostLaneIndex ? k_LeftMostLaneIndex : lane; GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.position += obj.transform.right * lane * segment.manager.laneOffset; obj.transform.SetParent(segment.objectRoot, true); //TODO : remove that hack related to #issue7 Vector3 oldPos = obj.transform.position; obj.transform.position += Vector3.back; obj.transform.position = oldPos; } }
public override IEnumerator Spawn(TrackSegment segment, float t) { Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); AsyncOperationHandle op = Addressables.InstantiateAsync(gameObject.name, position, rotation); yield return(op); if (op.Result == null || !(op.Result is GameObject)) { Debug.LogWarning(string.Format("Unable to load obstacle {0}.", gameObject.name)); yield break; } GameObject obj = op.Result as GameObject; obj.transform.SetParent(segment.objectRoot, true); //TODO : remove that hack related to #issue7 Vector3 oldPos = obj.transform.position; obj.transform.position += Vector3.back; obj.transform.position = oldPos; }
public override void Spawn(TrackSegment segment, float t, int l) { Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.SetParent(segment.objectRoot, true); }
public override void Spawn(TrackSegment segment, float t) { Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.SetParent(segment.objectRoot, true); obj.GetComponent <PatrollingObstacle>().m_Segement = segment; }
public override IEnumerator Spawn(TrackSegment segment, float t) { //the tutorial very firts barricade need to be center and alone, so player can swipe safely in bother direction to avoid it bool isTutorialFirst = TrackManager.instance.isTutorial && TrackManager.instance.firstObstacle && segment == segment.manager.currentSegment; if (isTutorialFirst) { TrackManager.instance.firstObstacle = false; } int count = isTutorialFirst ? 1 : Random.Range(k_MinObstacleCount, k_MaxObstacleCount + 1); int startLane = isTutorialFirst ? 0 : Random.Range(k_LeftMostLaneIndex, k_RightMostLaneIndex + 1); Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); for (int i = 0; i < count; ++i) { int lane = startLane + i; lane = lane > k_RightMostLaneIndex ? k_LeftMostLaneIndex : lane; AsyncOperationHandle op = Addressables.InstantiateAsync(gameObject.name, position, rotation); yield return(op); if (op.Result == null || !(op.Result is GameObject)) { Debug.LogWarning(string.Format("Unable to load obstacle {0}.", gameObject.name)); yield break; } GameObject obj = op.Result as GameObject; if (obj == null) { Debug.Log(gameObject.name); } else { obj.transform.position += obj.transform.right * lane * segment.manager.laneOffset; obj.transform.SetParent(segment.objectRoot, true); //TODO : remove that hack related to #issue7 Vector3 oldPos = obj.transform.position; obj.transform.position += Vector3.back; obj.transform.position = oldPos; } } }
public void SpawnNewSegment() { numbSegsMade++; int nextSegmentID = getNextSegment(); segmentIDs.Add(nextSegmentID); TrackSegment segmentToUse = m_CurrentThemeData.zones[m_CurrentZone].prefabList[nextSegmentID]; TrackSegment newSegment = Instantiate(segmentToUse, Vector3.zero, Quaternion.identity); Vector3 currentExitPoint; Quaternion currentExitRotation; if (m_Segments.Count > 0) { m_Segments[m_Segments.Count - 1].GetPointAt(1.0f, out currentExitPoint, out currentExitRotation); } else { currentExitPoint = transform.position; currentExitRotation = transform.rotation; } newSegment.transform.rotation = currentExitRotation; Vector3 entryPoint; Quaternion entryRotation; newSegment.GetPointAt(0.0f, out entryPoint, out entryRotation); Vector3 pos = currentExitPoint + (newSegment.transform.position - entryPoint); newSegment.transform.position = pos; newSegment.manager = this; //newSegment.transform.localScale = new Vector3((Random.value > 0.5f ? -1 : 1), 1, 1); //newSegment.objectRoot.localScale = new Vector3(1.0f/newSegment.transform.localScale.x, 1, 1); if (m_SafeSegementLeft <= 0) { SpawnObstacle(newSegment); } else { m_SafeSegementLeft -= 1; } m_Segments.Add(newSegment); }
public override void Spawn(TrackSegment segment, float t, int l) { Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); int lane = l; GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.position += obj.transform.right * lane * segment.manager.laneOffset; obj.transform.SetParent(segment.objectRoot, true); }
public override void Spawn(TrackSegment segment, float t, int l) { Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.SetParent(segment.objectRoot, true); obj.transform.position += obj.transform.right * l * segment.manager.laneOffset; obj.transform.forward = -obj.transform.forward; obj.GetComponent <Missile>().m_OwnSegement = segment; }
public override void Spawn(TrackSegment segment, float t) { Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.SetParent(segment.objectRoot, true); //TODO : remove that hack related to #issue7 Vector3 oldPos = obj.transform.position; obj.transform.position += Vector3.back; obj.transform.position = oldPos; }
public override void Spawn(TrackSegment segment, float t) { int lane = Random.Range(k_LeftMostLaneIndex, k_RightMostLaneIndex + 1); Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.SetParent(segment.objectRoot, true); obj.transform.position += obj.transform.right * lane * 1f; obj.transform.forward = -obj.transform.forward; obj.GetComponent <Missile>().m_OwnSegement = segment; }
public override void Spawn(TrackSegment segment, float t) { int count = Random.Range(k_MinObstacleCount, k_MaxObstacleCount + 1); int startLane = Random.Range(k_LeftMostLaneIndex, k_RightMostLaneIndex + 1); Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); for (int i = 0; i < count; ++i) { int lane = startLane + i; lane = lane > k_RightMostLaneIndex ? k_LeftMostLaneIndex : lane; GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.position += obj.transform.right * lane * 1; obj.transform.SetParent(segment.objectRoot, true); } }
//public void SpawnNewSegment() //{ // int segmentUse = Random.Range(0, prefabList.Length); // TrackSegment segmentToUse = prefabList[segmentUse]; // TrackSegment newSegment = Instantiate(segmentToUse, Vector3.zero, Quaternion.identity); // Vector3 currentExitPoint; // Quaternion currentExitRotation; // if (m_Segments.Count > 0) // { // m_Segments[m_Segments.Count - 1].GetPointAt(1.0f, out currentExitPoint, out currentExitRotation); // } // else // { // currentExitPoint = transform.position; // currentExitRotation = transform.rotation; // } // newSegment.transform.rotation = currentExitRotation; // Vector3 entryPoint; // Quaternion entryRotation; // newSegment.GetPointAt(0.0f, out entryPoint, out entryRotation); // Vector3 pos = currentExitPoint + (newSegment.transform.position - entryPoint); // newSegment.transform.position = pos; // newSegment.manager = this; // newSegment.transform.localScale = new Vector3(1, 1, 1); // newSegment.objectRoot.localScale = new Vector3(1.0f/newSegment.transform.localScale.x, 1, 1); // if (m_SafeSegementLeft <= 0) // SpawnDifferencies(newSegment); // else // m_SafeSegementLeft -= 1; // m_Segments.Add(newSegment); //} // public void SpawnDifferencies(TrackSegment segment) // { // if (segment.possibleDifferencies.Length != 0) // { // for (int i = 0; i < segment.possibleDifferencies.Length; ++i) // { // //segment.possibleDifferencies[Random.Range(0, segment.possibleDifferencies.Length)].Spawn(segment, segment.differencePositions[i]); // segment.possibleDifferencies[i].Spawn(segment, Random.value > 0.5 ? true : false); // } // } // } public void SpawnNewSegment() { totalSegmentCount++; TrackSegment newSegment = Instantiate(trackSeg); newSegment.name = totalSegmentCount.ToString(); newSegment.GenerateSegment(); Vector3 currentExitPoint; Quaternion currentExitRotation; if (m_Segments.Count > 0) { m_Segments[m_Segments.Count - 1].GetPointAt(1.0f, out currentExitPoint, out currentExitRotation); } else { currentExitPoint = transform.position; currentExitRotation = transform.rotation; } newSegment.transform.rotation = currentExitRotation; Vector3 entryPoint; Quaternion entryRotation; newSegment.GetPointAt(0.0f, out entryPoint, out entryRotation); Vector3 pos = currentExitPoint + (newSegment.transform.position - entryPoint); newSegment.transform.position = pos; newSegment.manager = this; m_Segments.Add(newSegment); }
public override IEnumerator Spawn(TrackSegment segment, float t) { int lane = Random.Range(k_LeftMostLaneIndex, k_RightMostLaneIndex + 1); Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); AsyncOperationHandle op = Addressables.InstantiateAsync(gameObject.name, position, rotation); yield return(op); if (op.Result == null || !(op.Result is GameObject)) { Debug.LogWarning(string.Format("Unable to load obstacle {0}.", gameObject.name)); yield break; } GameObject obj = op.Result as GameObject; obj.transform.SetParent(segment.objectRoot, true); obj.transform.position += obj.transform.right * lane * segment.manager.laneOffset; obj.transform.forward = -obj.transform.forward; Missile missile = obj.GetComponent <Missile>(); missile.m_OwnSegement = segment; //TODO : remove that hack related to #issue7 Vector3 oldPos = obj.transform.position; obj.transform.position += Vector3.back; obj.transform.position = oldPos; missile.Setup(); }
public override void Spawn(TrackSegment segment, float t) { int lane = Random.Range(k_LeftMostLaneIndex, k_RightMostLaneIndex + 1); Vector3 position; Quaternion rotation; segment.GetPointAt(t, out position, out rotation); GameObject obj = Instantiate(gameObject, position, rotation); obj.transform.SetParent(segment.objectRoot, true); obj.transform.position += obj.transform.right * lane * segment.manager.laneOffset; obj.transform.forward = -obj.transform.forward; obj.GetComponent <Missile>().m_OwnSegement = segment; //TODO : remove that hack related to #issue7 Vector3 oldPos = obj.transform.position; obj.transform.position += Vector3.back; obj.transform.position = oldPos; }
public IEnumerator SpawnNewSegment() { if (!m_IsTutorial) { if (m_CurrentThemeData.zones[m_CurrentZone].length < m_CurrentZoneDistance) { ChangeZone(); } } int segmentUse = Random.Range(0, m_CurrentThemeData.zones[m_CurrentZone].prefabList.Length); if (segmentUse == m_PreviousSegment) { segmentUse = (segmentUse + 1) % m_CurrentThemeData.zones[m_CurrentZone].prefabList.Length; } AsyncOperationHandle segmentToUseOp = m_CurrentThemeData.zones[m_CurrentZone].prefabList[segmentUse].InstantiateAsync(_offScreenSpawnPos, Quaternion.identity); yield return(segmentToUseOp); if (segmentToUseOp.Result == null || !(segmentToUseOp.Result is GameObject)) { Debug.LogWarning(string.Format("Unable to load segment {0}.", m_CurrentThemeData.zones[m_CurrentZone].prefabList[segmentUse].Asset.name)); yield break; } TrackSegment newSegment = (segmentToUseOp.Result as GameObject).GetComponent <TrackSegment>(); Vector3 currentExitPoint; Quaternion currentExitRotation; if (m_Segments.Count > 0) { m_Segments[m_Segments.Count - 1].GetPointAt(1.0f, out currentExitPoint, out currentExitRotation); } else { currentExitPoint = transform.position; currentExitRotation = transform.rotation; } newSegment.transform.rotation = currentExitRotation; Vector3 entryPoint; Quaternion entryRotation; newSegment.GetPointAt(0.0f, out entryPoint, out entryRotation); Vector3 pos = currentExitPoint + (newSegment.transform.position - entryPoint); newSegment.transform.position = pos; newSegment.manager = this; newSegment.transform.localScale = new Vector3((Random.value > 0.5f ? -1 : 1), 1, 1); newSegment.objectRoot.localScale = new Vector3(1.0f / newSegment.transform.localScale.x, 1, 1); if (m_SafeSegementLeft <= 0) { SpawnObstacle(newSegment); } else { m_SafeSegementLeft -= 1; } m_Segments.Add(newSegment); if (newSegmentCreated != null) { newSegmentCreated.Invoke(newSegment); } }
public void SpawnNewSegment() { if (!m_IsTutorial) { if (m_CurrentThemeData.zones[m_CurrentZone].length < m_CurrentZoneDistance) { ChangeZone(); } } int segmentUse = Random.Range(0, m_CurrentThemeData.zones[m_CurrentZone].prefabList.Length); if (segmentUse == m_PreviousSegment) { segmentUse = (segmentUse + 1) % m_CurrentThemeData.zones[m_CurrentZone].prefabList.Length; } TrackSegment segmentToUse = m_CurrentThemeData.zones[m_CurrentZone].prefabList[segmentUse]; TrackSegment newSegment = Instantiate(segmentToUse, Vector3.zero, Quaternion.identity); Vector3 currentExitPoint; Quaternion currentExitRotation; if (m_Segments.Count > 0) { m_Segments[m_Segments.Count - 1].GetPointAt(1.0f, out currentExitPoint, out currentExitRotation); } else { currentExitPoint = transform.position; currentExitRotation = transform.rotation; } newSegment.transform.rotation = currentExitRotation; Vector3 entryPoint; Quaternion entryRotation; newSegment.GetPointAt(0.0f, out entryPoint, out entryRotation); Vector3 pos = currentExitPoint + (newSegment.transform.position - entryPoint); newSegment.transform.position = pos; newSegment.manager = this; newSegment.transform.localScale = new Vector3((Random.value > 0.5f ? -1 : 1), 1, 1); newSegment.objectRoot.localScale = new Vector3(1.0f / newSegment.transform.localScale.x, 1, 1); if (m_SafeSegementLeft <= 0) { SpawnObstacle(newSegment); } else { m_SafeSegementLeft -= 1; } m_Segments.Add(newSegment); if (newSegmentCreated != null) { newSegmentCreated.Invoke(newSegment); } }
public void SpawnNewSegment() { if (m_CurrentThemeData.zones[m_CurrentZone].length < m_CurrentZoneDistance) { m_CurrentZone += 1; if (m_CurrentZone >= m_CurrentThemeData.zones.Length) { m_CurrentZone = 0; } m_CurrentZoneDistance = 0; } int segmentUse = Random.Range(0, m_CurrentThemeData.zones[m_CurrentZone].prefabList.Length); if (segmentUse == m_PreviousSegment) { segmentUse = (segmentUse + 1) % m_CurrentThemeData.zones[m_CurrentZone].prefabList.Length; } TrackSegment segmentToUse = m_CurrentThemeData.zones[m_CurrentZone].prefabList[segmentUse]; TrackSegment newSegment = Instantiate(segmentToUse, Vector3.zero, Quaternion.identity); foreach (Transform part in newSegment.transform) { if (part.name != "ObjectRoot") { part.gameObject.isStatic = true; foreach (Transform childpart in part) { childpart.gameObject.isStatic = true; foreach (Transform childchildpart in childpart) { childchildpart.gameObject.isStatic = true; } } } } Vector3 currentExitPoint; Quaternion currentExitRotation; if (m_Segments.Count > 0) { m_Segments[m_Segments.Count - 1].GetPointAt(1.0f, out currentExitPoint, out currentExitRotation); } else { currentExitPoint = transform.position; currentExitRotation = transform.rotation; } newSegment.transform.rotation = currentExitRotation; Vector3 entryPoint; Quaternion entryRotation; newSegment.GetPointAt(0.0f, out entryPoint, out entryRotation); Vector3 pos = currentExitPoint + (newSegment.transform.position - entryPoint); newSegment.transform.position = pos; newSegment.manager = this; newSegment.transform.localScale = new Vector3((/*Random.value > 0.5f ? -1 :*/ 1), 1, 1); newSegment.objectRoot.localScale = new Vector3(1.0f / newSegment.transform.localScale.x, 1, 1); if (m_SafeSegementLeft <= 0) { SpawnObstacle(newSegment); } else { m_SafeSegementLeft -= 1; } m_Segments.Add(newSegment); }