public override GameObject GetObject() { int randVal = UnityEngine.Random.Range(0, gameObjectList.Count - 1); tempController = gameObjectList[randVal].GetComponent <FEController>(); if (tempController != null && !tempController.IsMoving) { gameObjectList[randVal].SetActive(true); return(gameObjectList[randVal]); } else { return(GetObject()); } }
public override void MoveNext() { if (!CanGen) { return; } if (IsPaused) { movingFE.Clear(); foreach (var v in listOfFEControllers) { v.PauseFE(); int i = 0; if (v.isMoving) { movingFE.Add(v); } } wasPaused = true; return; } if (prevGO.transform.position.z < tempGO.transform.position.z - tempGO.GetComponent <Collider>().bounds.size.z || wasPaused) { //Starting all FE that already was in way if (wasPaused) { foreach (FEController v in movingFE) { v.StartFE(SpeedVecFE); } } Debug.Log("set speed to FEController"); tempFEScript.StartFE(SpeedVecFE); prevGO = tempGO; tempGO = poolObjectManager.GetObject(); tempGO.transform.position = StartPointAllFE; tempFEScript = tempGO.GetComponent <FEController>(); wasPaused = false; } }
public void Init() { poolObjectManager.Number = PoolSizeFE; poolObjectManager.ShouldExtend = ShouldExtend; prevGO = new GameObject(); prevGO.name = "PrevGO"; prevGO.transform.SetParent(poolObjectManager.ParentGO.transform); prevGO.transform.position = StartPointAllFE - StartPointAllFE / 2; if (TargetGameObjects != null) { poolObjectManager.SetTargetList(TargetGameObjects); } else { Debug.Log("FEManager: Set FETarget!"); IsInit = false; return; } poolObjectManager.Init(); foreach (var v in poolObjectManager.gameObjectList) { tempFEScript = v.AddComponent <FEController>(); listOfFEControllers.Add(tempFEScript); tempFEScript.Init(); tempFEScript.SetID(FEID++); } tempGO = poolObjectManager.GetObject(); tempGO.transform.position = StartPointAllFE; tempFEScript = tempGO.GetComponent <FEController>(); IsInit = true; }