void Update() { if (_isPlayerActive) { //Debug.Log(Input.inputString); if (transform.position.z > PlaneList[_positionIndex].ZPosition + 10) { PlaneList[_positionIndex].ZPosition += 50; Vector3 newPosition = new Vector3(0, 0, PlaneList[_positionIndex].ZPosition); PlaneList[_positionIndex].ThisGameObject.transform.position = newPosition; _positionIndex++; _passedPlaneCountModded++; _positionIndex = _positionIndex % (GlobalPlaneNumber); _score += 10; //10 points for griffindor ScoreTextController.UpdateScoreText(_score); } if (_passedPlaneCountModded >= PlaneCountToIncreaseSpeed) { IncreaseSpeed(); EnemySpawnIntervalBegin *= 5f / 8f; EnemySpawnIntervalEnd *= 5f / 8f; } if (_newEnemyCanSpawn) { _newEnemyCanSpawn = false; //Debug.Log(EnemySpawnIntervalBegin); float randomTimeToSpawn = UnityEngine.Random.Range(EnemySpawnIntervalBegin, EnemySpawnIntervalEnd); StartCoroutine(SpawnEnemy(randomTimeToSpawn)); } #if UNITY_EDITOR if ((Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) && _isAvailableToChangeDirection) { StartCoroutine(MoveLeft()); } if ((Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) && _isAvailableToChangeDirection) { StartCoroutine(MoveRight()); } if (Input.GetKeyDown(KeyCode.R)) { RestartGame(); } if ((Input.GetMouseButtonDown(0) && _isAvailableToAttack)) { _isAvailableToAttack = false; StartCoroutine(AttackFront()); } #else ScreenSwipeManager.DetectSwipe(); if (ScreenSwipeManager.swipeDirection == Swipe.Left) { // do something... StartCoroutine(MoveLeft()); } if (ScreenSwipeManager.swipeDirection == Swipe.Right) { // do something... StartCoroutine(MoveRight()); } if (ScreenSwipeManager.swipeDirection == Swipe.Tap && _isAvailableToAttack) { // do something... _isAvailableToAttack = false; StartCoroutine(AttackFront()); } #endif if (_score >= _highScore) { _highScore = _score; HighScoreTextController.UpdateHighScoreText(_highScore); } MovePlayer(); } if (Input.GetKeyDown(KeyCode.Escape)) { RestartPanelController.ToggleStaticPanel(); } }
void Start() { InitiliazePlaneList(); _isPlayerActive = true; HighScoreTextController.UpdateHighScoreText(_highScore); }