public void UFOIsShot(GameObject ufo) { levelManager.curScore += ufo.GetComponent <UFOController>().score; visibleUfos.Remove(ufo); ufoFactory.Withdraw(ufo); var actions = startedActions.FindAll(action => action.gameObject == ufo); if (actions.Count != 0) { actionManager.RemoveAction(actions[0]); } levelManager.CheckScore(); }
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(); } }