예제 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag(PROJECTILE_TAG))
        {
            GetDamage(damagePerBullet);
        }
        else if (other.CompareTag(SPELL_TAG))
        {
            switch (other.GetComponent <Spell>().spellName)
            {
            case "FireStrike":
                GetDamage(other.GetComponent <FireStrike>().damage);
                break;

            case "IceBlast":
                var iceBlast = other.GetComponent <IceBlast>();
                movementController.ApplyMovementSpeedMultiplier(iceBlast.speedMultiplier, iceBlast.duration);
                break;

            default:
                Debug.LogError("Unknown spell name");
                break;
            }
        }
        else if (other.CompareTag(PLAYER_TAG))
        {
            onPlayerHit.RaiseEvent();
            other.GetComponent <PlayerController>().HitPlayer(desiredEnemy.enemyDamage);
            onEnemyKilled.RaiseEvent();
            gameObject.SetActive(false);
        }
    }
예제 #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag(CONST_VALUES.ENEMY_BULLET_TAG))
     {
         playerDestroyed.RaiseEvent();
     }
 }
    private IEnumerator AwaitPlayerDying()
    {
        yield return(new WaitUntil(() => currentHP <= 0));

        onPlayerDied.RaiseEvent();
        Debug.Log("Player died!");
        Time.timeScale = 0;
    }
예제 #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag(CONST_VALUES.BALL_TAG))
     {
         SceneLoader.Instance.LoadGameOver();
         resetStats.RaiseEvent();
     }
 }
예제 #5
0
 private void Start()
 {
     audioSource = GetComponent <AudioSource>();
     coll        = GetComponent <BoxCollider2D>();
     rend        = GetComponent <SpriteRenderer>();
     if (CompareTag(CONST_VALUES.BREAKABLE_TAG))
     {
         increaseblockNumber.RaiseEvent();
     }
     maxHits = damageSprites.Length + 1;
 }
    private IEnumerator SpawnInterval()
    {
        yield return(waitForIntervalDuration);

        for (int i = 0; i < enemiesPerSpawn; i++)
        {
            newEnemy = poolingManager.SpawnFromPool(desiredEnemy.enemyTag, GetRandomPositionOnCircle() * RADIUS, Quaternion.identity);
            newEnemy.GetComponent <EnemyController>().desiredEnemy = desiredEnemy;
            onEnemySpawned.RaiseEvent();
        }
        yield return(SpawnInterval());
    }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag(CONST_VALUES.PLAYER_TAG))
     {
         enemyController.GotHit();
         onEnemyDestroyed.Play(src);
         destroyPlayer.RaiseEvent();
     }
     else if (collision.CompareTag(CONST_VALUES.BULLET_TAG))
     {
         addPoints.RaiseEvent();
         onEnemyDestroyed.Play(src);
         enemyController.GotHit();
         coll.enabled = false;
     }
 }
예제 #8
0
 private void RaiseEvents()
 {
     grantPoints.RaiseEvent();
     decreaseBlockNumber.RaiseEvent();
 }