private void InitializeIncenseNode(IncenseNode node) { node.transform.SetParent(transform); node.transform.position = spawnPos.position; node.gameObject.SetActive(true); Vector3 driftTarget = new Vector3( node.transform.position.x + Random.Range(xDrift.x, xDrift.y), node.transform.position.y + Random.Range(yDrift.x, yDrift.y), node.transform.position.z + Random.Range(zDrift.x, zDrift.y)); node.StartCoroutine(node.Travel(driftTime, driftTarget)); StartCoroutine(RecycleNode(node, fadeTime)); }
private void InitializeIncenseNode(IncenseNode node) { node.transform.SetParent(transform); node.transform.position = spawnPos.position; node.gameObject.SetActive(true); Vector3 driftTarget = new Vector3( node.transform.position.x + Random.Range(xDrift.x, xDrift.y), node.transform.position.y + Random.Range(yDrift.x, yDrift.y), node.transform.position.z + Random.Range(zDrift.x, zDrift.y)); node.StartCoroutine(node.Travel(driftTime, driftTarget)); StartCoroutine(RecycleNode(node, fadeTime)); }
private IEnumerator RecycleNode(IncenseNode node, float time) { yield return new WaitForSeconds(time); for (int i = 0; i < activeNodes.Count; i++) { if (activeNodes[i].GetInstanceID() == node.GetInstanceID()) { activeNodes.RemoveAt(i); break; } } inactiveNodes.Add(node); node.Stop(); node.gameObject.SetActive(false); }
private IEnumerator RecycleNode(IncenseNode node, float time) { yield return(new WaitForSeconds(time)); for (int i = 0; i < activeNodes.Count; i++) { if (activeNodes[i].GetInstanceID() == node.GetInstanceID()) { activeNodes.RemoveAt(i); break; } } inactiveNodes.Add(node); node.Stop(); node.gameObject.SetActive(false); }
public IncenseNode GetNode() { IncenseNode newNode = null; if (inactiveNodes.Count > 0) { newNode = inactiveNodes[0]; activeNodes.Add(newNode); inactiveNodes.RemoveAt(0); } else { newNode = Instantiate(nodePrefab, spawnPos.position, Quaternion.identity) as IncenseNode; activeNodes.Add(newNode); } return(newNode); }