Exemple #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player" && isActive == true)
     {
         OnPlayerWin?.Invoke();
     }
 }
Exemple #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         OnPlayerWin?.Invoke();
     }
 }
Exemple #3
0
        /// <summary>
        /// Creates a new player for a specific level
        /// </summary>
        /// <param name="level">The Level that the player should play in</param>
        /// <param name="location">The starting location of the player</param>
        /// <param name="score">The initial score of the player. Default is 0.</param>
        public PlayerGameObject(Level level, Point location, int score = 0) : base(level.Tiles, level.TimeBetweenActions, "player@4x4", 0, "")
        {
            player = new DummyPlayer(level.Tiles, location, score);
            Level  = level;
            Teleport(location);
            TileField.RevealArea(location);
            soundFootsteps = GameEnvironment.AssetManager.Content.Load <SoundEffect>("footsteps").CreateInstance();

            player.OnPlayerAction += delegate(DummyPlayer player) { OnPlayerAction?.Invoke(this); };
            player.OnPlayerWin    += delegate(DummyPlayer player) { OnPlayerWin?.Invoke(this); };
            player.OnPlayerLose   += delegate(DummyPlayer player)
            {
                OnPlayerLose?.Invoke(this);
                GameEnvironment.AssetManager.PlaySound("scream");
            };
            player.OnMoveSmoothly += delegate(DummyPlayer player, Direction direction)
            {
                MoveSmoothly(direction);
                soundFootsteps.Play();
            };
            player.OnTeleport += delegate(DummyPlayer player)
            {
                Teleport(player.Location);
                GameEnvironment.AssetManager.PlaySound("climbing_sound");
            };
            StoppedMoving += delegate(GameObject obj)
            {
                player.EndMoveSmoothly();
                soundFootsteps.Stop();
            };
        }
        private void HandleEnemyKilled(EnemyData enemyData)
        {
            if (enemiesToKill.ContainsKey(enemyData))
            {
                enemiesToKill[enemyData]--;

                if (enemiesToKill[enemyData] == 0)
                {
                    enemiesToKill.Remove(enemyData);
                }
            }

            if (enemiesToKill.Count == 0)
            {
                currentWave++;

                if (currentWave == numberOfWaves)
                {
                    OnPlayerWin?.Invoke();
                    return;
                }

                GetNextWave();

                ResetTheCountdown();
            }
        }
Exemple #5
0
    private IEnumerator CalculateEnemynumber()
    {
        yield return(new WaitForSeconds(5.0f));

        if (TotalEnemies == 0)
        {
            OnPlayerWin?.Invoke();
        }
    }
Exemple #6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            OnPlayerWin?.Invoke();

            other.gameObject.GetComponent <PlayerController>().Disable();
        }
    }
 public void PlayerWinGame()
 {
     if (IsGameOver)
     {
         return;
     }
     GameState = GameStates.Finish;
     OnPlayerWin?.Invoke();
     GameOver();
 }
Exemple #8
0
        private void FixedUpdate()
        {
            if (player == null)
            {
                StopCoroutine(scoreCoroutine);
                OnAIWin?.Invoke();
            }

            if (score < 60 && enemy != null)
            {
                return;
            }
            OnPlayerWin?.Invoke();
            enemy.GetComponentInChildren <Health>().Die();
            StopCoroutine(scoreCoroutine);
        }
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.layer == LayerMask.NameToLayer(TagManager.CoinLayer))
     {
         Destroy(other.gameObject);
         AddCoin(1);
         OnPlayerGrabCoin?.Invoke();
         SoundManager.instance.PlaySound(coinSound);
     }
     else if (other.gameObject.layer == LayerMask.NameToLayer(TagManager.StarLayer))
     {
         Destroy(other.gameObject);
         gameObject.SetActive(false);
         GlobalVariables.totalCoins += coinAmount;
         OnPlayerWin?.Invoke();
         Instantiate(winEffect, transform.position, Quaternion.identity);
         SoundManager.instance.PlaySound(starSound);
     }
 }
Exemple #10
0
        private void FixedUpdate()
        {
            if (someoneWon)
            {
                return;
            }

            if (player == null)
            {
                SomeoneWon();
                OnAiWin?.Invoke();
            }

            if (score >= 60 || enemy == null)
            {
                SomeoneWon();
                OnPlayerWin?.Invoke();
                if (enemy != null)
                {
                    enemy.GetComponentInChildren <Health>().Die();
                }
            }
        }
    private IEnumerator LoadNewLevel()
    {
        // Disable previous wave coroutine
        StopCoroutine(_coroutine);

        _currentLevelIndex++;

        // Check if there is another level, if so, load it, otherwise finish the game
        if (IsGameFinished())
        {
            OnPlayerWin?.Invoke();
            yield return(null);
        }
        else
        {
            OnLevelChange?.Invoke(GetLevel());
            PrepareForNewLevel();

            // Add delay only between levels
            yield return(new WaitForSeconds(_delayBetweenLevels));

            LoadWave();
        }
    }
Exemple #12
0
 public static void PlayerWin() => OnPlayerWin?.Invoke();
Exemple #13
0
 /// <summary>
 /// Makes the player win the game
 /// </summary>
 public void Win()
 {
     OnPlayerWin?.Invoke(this);
 }
Exemple #14
0
 public void EndGame(Player winner) => OnPlayerWin?.Invoke(winner);
Exemple #15
0
 public void setPlayerWin()
 {
     OnPlayerWin.Invoke();
 }