예제 #1
0
파일: Enemy.cs 프로젝트: RobLacey/GameDevHQ
    private void CreateDeathFX()
    {
        if (_shrapnel != null)
        {
            _poolingAgent.InstantiateFromPool(_shrapnel, transform.position, Quaternion.identity);
        }

        GameObject newObject = _poolingAgent.InstantiateFromPool(_expolsion, transform.position, Quaternion.identity);

        newObject.GetComponent <IScaleable>().I_SetScale(new Vector3(_expolsionSize, _expolsionSize, _expolsionSize));
    }
예제 #2
0
 private void Fire()
 {
     if (Input.GetKey(KeyCode.Space) && Time.time > _canFireTimer)
     {
         _canFireTimer = Time.time + _currentWeapon.FireRate();
         _poolingAgent.InstantiateFromPool(_currentWeapon._weaponPrefab, transform.position, Quaternion.identity);
         _audioSource.Play();
     }
 }
예제 #3
0
 private IEnumerator SpawnObjects()
 {
     while (_canSpawn)
     {
         float      timer   = Random.Range(_minSpawnTime, _maxSpawnTime);
         GameObject toSpawn = _spawnArray[Random.Range(0, _spawnArray.Length)];
         Vector3    newPos  = SpawnPosition();
         _poolingAgent.InstantiateFromPool(toSpawn, newPos, Quaternion.identity);
         yield return(new WaitForSeconds(timer));
     }
 }
예제 #4
0
    private IEnumerator Fire()
    {
        while (_allowFiring)
        {
            yield return(new WaitForSeconds(_fireRate));

            _poolingAgent.InstantiateFromPool(_weaponPrefab, transform.position + _laserOffset, Quaternion.identity);
            _audioSource.Play();
            _fireRate = UnityEngine.Random.Range(_fireRateMin, _fireRateMax);
        }
    }
예제 #5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IDamageable canDamage = collision.GetComponentInParent <IDamageable>();

        if (canDamage != null && _teamTag != canDamage.I_TeamTag)
        {
            canDamage.I_ProcessCollision(_damage);
            _shrapnelController.DeactivateChildObjects();
            _poolingAgent.InstantiateFromPool(_damageFX, transform.position, Quaternion.identity);
            gameObject.SetActive(false);
        }
    }
예제 #6
0
    public void I_ProcessCollision(float damage)
    {
        Damage(damage);

        if (_health <= 0)
        {
            GameObject explosion = _poolingAgent.InstantiateFromPool(_deathFX, transform.position, Quaternion.identity);
            explosion.GetComponent <IScaleable>().I_SetScale(_explosionSize);
            _Event_PlayerDead.Invoke(this);
            gameObject.SetActive(false);
        }
    }
예제 #7
0
 public void I_LostEnemyFromWave(int score, Vector3 lastEnemiesPosition)
 {
     enemiesLeft--;
     if (enemiesLeft <= 0)
     {
         _Event_WaveWiped.Invoke(score, true, this);
         gameObject.SetActive(false);
         GameObject newObject = _poolingAgent.InstantiateFromPool(_wipeUI, transform.position, Quaternion.identity);
         newObject.GetComponentInChildren <Text>().transform.position = GetScreenPosition(lastEnemiesPosition);
     }
     else
     {
         _Event_AddToScore.Invoke(score, this);
     }
 }
예제 #8
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IDamageable canDealDamage = collision.GetComponentInParent <IDamageable>();
        bool        isAPowerUp    = collision.GetComponent <PowerUp>();

        if (canDealDamage != null && !isAPowerUp)
        {
            if (canDealDamage.I_TeamTag != I_TeamTag)
            {
                canDealDamage.I_ProcessCollision(damage);
                _poolingAgent.InstantiateFromPool(_hiteffect, transform.position, Quaternion.identity);
                CheckOtherProjectiles();
            }
        }
    }