void Update() { speed = MathFormulas.GetSpeed(GameTimer.elapsedTime); spawnTime = MathFormulas.GetSpawnTime(GameTimer.elapsedTime); if (!PlayerInfluence.lostGame) { if (GameTimer.elapsedTime > spawnTime + spawnDeltaTime) { float randomValue = Random.Range(0F, 100F); if ((activeObjects.Count % 10 == 0 && playerInfluenceRef.GetLifePoints() == 2) || (activeObjects.Count % 5 == 0 && playerInfluenceRef.GetLifePoints() == 1)) { tempPlayable = Instantiate (facade, SpawnPosition.GetFacadeSpawn(), this.transform.rotation); clickableObject = tempPlayable.GetComponent <Facade>(); } else if (randomValue <= 25F && randomValue > 15F && this.activeObjects.Count > 7) { tempPlayable = Instantiate (fatGonzales, SpawnPosition.GetGonzalesSpawnPoint(), this.transform.rotation); clickableObject = tempPlayable.GetComponent <FatGonzales>(); } else if (randomValue <= 15F && randomValue > 5F && this.activeObjects.Count > 10) { tempPlayable = Instantiate (supremeLeader, SpawnPosition.GetBasicSpawnPoint(), this.transform.rotation); swipeableObject = tempPlayable.GetComponent <SupremeLeader>(); } else if (randomValue <= 5F && this.activeObjects.Count > 10) { tempPlayable = Instantiate (chinaman, SpawnPosition.GetBasicSpawnPoint(), this.transform.rotation); clickableObject = tempPlayable.GetComponent <Chinaman>(); } else { tempPlayable = Instantiate (mexican, SpawnPosition.GetBasicSpawnPoint(), this.transform.rotation); clickableObject = tempPlayable.GetComponent <BasicMexican>(); } spawnDeltaTime = GameTimer.elapsedTime; if (randomValue <= 15F && randomValue > 5F && activeObjects.Count > 10) { swipeableObject.SetSpeed(speed); } else { clickableObject.SetSpeed(speed); //print(GameTimer.elapsedTime + " " + speed); } activeObjects.Add(tempPlayable.gameObject); } } }
//Treba riješiti sranje s firstloseom da se ne zove stalno, vjv u lateupdateu private void LateUpdate() { if (!GameTimer.Pause) { if (Input.touches.Length > 0) { Touch touch = Input.touches[0]; float deltaX = 0F; float deltaY = 0F; if (touch.phase == TouchPhase.Began) { Vector3 position = Camera.main.ScreenToWorldPoint(touch.position); hitPoint = Physics2D.OverlapPoint(position); startPosition = touch.position; if (hitPoint != null) { swipeableObject = hitPoint.transform.GetComponent <ISwipeableObject>(); } } if (touch.phase == TouchPhase.Moved) { endPosition = touch.position; deltaX = endPosition.x - startPosition.x; deltaY = endPosition.y - startPosition.y; swipeableObject.Swipe(deltaX, deltaY); } } } //--------------------------------------------------- if (!PlayerInfluence.lostGame) { if (lifePoints == 3) { backgroundControl.SetHP3(); } else if (lifePoints == 2) { backgroundControl.SetHP2(); } else if (lifePoints == 1) { backgroundControl.SetHP1(); } else if (lifePoints == 0) { backgroundControl.SetHP0(); continuePanelCounter.text = GameTimer.continueTime.ToString(); if (!firstlose) { Time.timeScale = 0; GameTimer.Stop(); pauseButton.SetActive(false); if (Application.internetReachability != NetworkReachability.NotReachable && Advertisements.IsReady()) { OneMoreChance(); } else { LoseGame(); } } else if (GameTimer.continueTime < 1 && firstlose || AdHandler.ContinuePressed) { oneMoreChancePanel.SetActive(false); LoseGame(); } } } }