public void OnHit(bool isBullseye = false) { movement.Stop(); PlayHitAnimations(isBullseye); PlayHitParticles(isBullseye); Stop(); StartCoroutine(MyUtils.DelayedAction(Despawn, despawnTimer)); }
private void ShootArrow(Vector2 direction, float force) { var forceVector = direction.normalized * force; SetArrowParticles(); arrow.GetComponent <Arrow>().Shoot(forceVector); isArrowFlying = true; arrow = null; StartCoroutine(MyUtils.DelayedAction(RespawnArrow, arrowRespawnInterval)); }
public void TargetHit(bool isBullseye, Vector3 position) { targetHits++; bullseyeStreak = isBullseye ? bullseyeStreak + 1 : 0; score += 1 + bullseyeStreak; _pointsBalloonManager.Add(bullseyeStreak + 1, Camera.main.WorldToScreenPoint(position)); scoreText.text = score.ToString(); GlobalEvents <OnTargetHit> .Call(new OnTargetHit { score = score, totalScore = PlayerPrefs.GetInt("TotalScore", 0) + score, bullseyeStreak = bullseyeStreak, targetHits = targetHits, timerLeft = timerBar.TimeLeft, isTargetMoving = targetSpawner.spawnStrategy == SpawnerStrategy.SimpleMoving || targetSpawner.spawnStrategy == SpawnerStrategy.SimpleMovingVertical }); scoreText.transform.localScale = Vector3.one; scoreText.transform.DOPunchScale(Vector3.one * Mathf.Min(minScorePunch + bullseyeStreak / 10f, maxScorePunch), scorePunchDuration); timerBar.StartTimer(Mathf.Max(timerMaxTime - timerReductionPerHit * targetHits, timerMinTime)); SetArrowParticles(); if (isBullseye) { GlobalEvents <OnIventPerfect> .Call(new OnIventPerfect()); } else { GlobalEvents <OnIventSimple> .Call(new OnIventSimple()); } SetSpawnerStrategy(); StartCoroutine(MyUtils.DelayedAction(targetSpawner.Spawn, targetRespawnInterval)); isArrowFlying = false; if (!gameStarted) { StartGame(); } }
public void Show(Vector3 position) { transform.localScale = Vector3.one; var game = GameObject.Find("Game").GetComponent <Gameplay>(); var render = GetComponent <Renderer>(); position.x = Mathf.Min(position.x, game.gameBounds.width / 2f - render.bounds.extents.x - padding); position.x = Mathf.Max(position.x, game.gameBounds.x + render.bounds.extents.x + padding); position.y = Mathf.Min(position.y, game.gameBounds.height / 2f - render.bounds.extents.y - padding); position.y = Mathf.Max(position.y, game.gameBounds.y + render.bounds.extents.y + padding); transform.position = position; transform.DOKill(); StopAllCoroutines(); gameObject.SetActive(true); transform.localScale = Vector3.zero; transform.DOScale(Vector3.one, fadeInDuration).SetEase(Ease.OutElastic); StartCoroutine(MyUtils.DelayedAction(Hide, displayDuration)); }
private void GameOver() { if (!_isReviveShowed) { _isReviveShowed = true; if (score > 10) { GlobalEvents <OnScreenReviveShow> .Call(new OnScreenReviveShow()); PauseGame(); return; } if (_gameplayCounter > 1 && _gameplayCounter % 3 == 0) { GlobalEvents <OnAdsVideoShow> .Call(new OnAdsVideoShow()); PauseGame(); } } GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, "Archer", score); PlayerPrefs.SetInt("LastScore", score); PlayerPrefs.SetInt("TotalScore", PlayerPrefs.GetInt("TotalScore", 0) + score); CheckHighScore(); score = 0; bullseyeStreak = 0; targetHits = 0; gameStarted = false; isArrowFlying = false; SetArrowParticles(); crown.DOKill(); crown.DOFade(1f, crownFadeInDuration); StopAllCoroutines(); if (targetSpawner.spawnStrategy != SpawnerStrategy.First) { foreach (var target in targetSpawner.SpawnedObjects()) { target.GetComponent <Target>().Stop(); target.GetComponent <Target>().Despawn(); } targetSpawner.spawnStrategy = SpawnerStrategy.First; targetSpawner.scale = Vector3.one; targetSpawner.Spawn(); } timerBar.PauseTimer(); StartCoroutine(MyUtils.DelayedAction(timerBar.ResetTimer, 0.3f)); if (arrow == null) { RespawnArrow(); } scoreText.text = PlayerPrefs.GetInt("Highscore").ToString(); if (_gameplayCounter <= 3) { Invoke("ShowHintHand", 2f); } gamePaused = false; PlayerPrefs.SetInt("TotalGamesPlayed", PlayerPrefs.GetInt("TotalGamesPlayed", 0) + 1); PlayerPrefs.Save(); GlobalEvents <OnGameOver> .Call(new OnGameOver()); }