void Update() { if (gameState != GameState.Playing) { return; } for (; visibleUfos.Count < levelManager.curLevel + 2;) { GameObject newUfo = ufoFactory.Launch(levelManager.curLevel); levelManager.modifyUfoLevel(newUfo); visibleUfos.Add(newUfo); runAction(newUfo, this); } }
void Update() { if (gameState != GameState.Playing) { return; } List <GameObject> invisibleUfos = new List <GameObject>(); foreach (var obj in visibleUfos) { if (!isInView(obj.transform.position)) { invisibleUfos.Add(obj); //Debug.Log("one ufo went outside"); } } foreach (var ufo in invisibleUfos) { ufoFactory.Withdraw(ufo); visibleUfos.Remove(ufo); } if (Input.GetButtonDown("Fire1")) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject ufo = hit.transform.gameObject; curScore = curScore + ufo.GetComponent <UFOController>().score; this.visibleUfos.Remove(ufo); ufoFactory.Withdraw(ufo); } } for (; visibleUfos.Count < curLevel + 2;) { GameObject newUfo = ufoFactory.Launch(this.curLevel); modifyUfoLevel(newUfo); visibleUfos.Add(newUfo); } if (curScore > curLevel * 10) { levelUp = true; curScore = 0; NextRound(); } }