예제 #1
0
 private void Attack()
 {
     //_recoilTime = this._fireRate - 0.1f;
     //_recoiling = true;
     AttackSound.Play();
     _projectileManager.FireSpreadProjectile(this.gameObject, _currentTarget.GetComponent <CapsuleCollider>(), _bullet, _force, _damage, Num);
 }
예제 #2
0
파일: Weapon.cs 프로젝트: Jypeli-JYU/Jypeli
        /// <summary>
        /// Ampuu aseella, ja palauttaa ammuksen tai <c>null</c>, jos
        /// ampuminen ei onnistu (esimerkiksi jos panokset ovat lopussa).
        /// </summary>
        /// <remarks>
        /// Tätä metodia käyttämällä pääsee muokkaamaan ammusta, esimerkiksi muuttamaan
        /// sen fysiikkaominaisuuksia. Huomaa kuitenkin, että tällöin tulee aina
        /// tarkistaa että ammus ei ole <c>null</c>.
        /// </remarks>
        /// <returns>Ammuttu panos tai <c>null</c>.</returns>
        public PhysicsObject Shoot()
        {
            if (IsReady)
            {
                timeOfLastUse = Game.Time.SinceStartOfGame;

                if (AttackSound != null)
                {
                    AttackSound.Play(Volume, 0, 0);
                }

                PhysicsObject p = CreateProjectile();

                SetCollisionHandler(p, ProjectileCollision);
                p.IgnoresGravity    = AmmoIgnoresGravity;
                p.IgnoresExplosions = AmmoIgnoresExplosions;
                p.MaximumLifetime   = MaxAmmoLifetime;
                ShootProjectile(p, Power.Value);
                if (!InfiniteAmmo)
                {
                    Ammo.Value--;
                }
                Power.Reset();
                OnShooting(p);

                return(p);
            }

            return(null);
        }
예제 #3
0
    void Update()
    {
        // if the enemy has taken damage than play the corresponding sound
        if (fEnemyHealth < fLastHealth)
        {
            TakingDamageSound.Play();
            fLastHealth = fEnemyHealth;
        }
        else
        {
            fLastHealth = fEnemyHealth;
        }


        if (fEnemyHealth > 0)                                                                                            // if the enemies health is greater than zero this logic will be executed
        {
            if (LineOfSightCheck() == true && tPlayer.GetComponent <PlayerController>().bBossFightCameraActive == false) // if the line of sight returns true or the enemy is damaged
            {
                if (AttackSound.isPlaying == false)                                                                      // check to see if the attack sound is playing because we dont want overlaping sounds
                {
                    AttackSound.Play();
                }
                Attack();                 // the enemy attacks the player
            }
            else
            {
                Patrol();                 // if the enemy is spotted than the enemy goes back to patrolling
                AttackSound.Stop();       // stop playing the attack sound if it is playing
            }
        }
        else                                                                          // if the health is less than zero than the enemy is dead
        {
            Vector3 v3DeathPosition = transform.position;                             // set the death position
            DropFuel(v3DeathPosition);                                                // drop the fuel on this position
            Instantiate(DeathXplosionEffect, transform.position, transform.rotation); // create a particle system that plays on awake
            Destroy(gameObject);                                                      // destroy this enemy
        }

        float fDistanceBetweenThisAndPlayer = Vector3.Distance(transform.position, tPlayer.transform.position);

        if (fDistanceBetweenThisAndPlayer < 12f)
        {
            if (BuzzingSound.isPlaying == false)
            {
                BuzzingSound.Play();
            }
            BuzzingSound.volume = Mathf.Clamp((1 * fDistanceBetweenThisAndPlayer), 0.01f, 0.065f);
        }
        else
        {
            BuzzingSound.Stop();
        }
    }
예제 #4
0
 private void Attack(GameObject target)
 {
     if (CanAttack == true)
     {
         AttackSound.Play();
         GameObject bullet = BulletPool.GetBullet(Damage);
         bullet.transform.position = _bulletSpawn.transform.position;
         bullet.SetActive(true);
         bullet.GetComponent <RangedEnemyProjectile>().Shoot(target.transform.position);
         CanAttack = false;
     }
 }
예제 #5
0
    private void Attack()
    {
        _pulseEffect.Play();

        AttackSound.Play();

        foreach (GameObject enemy in _inRangeEnemies)
        {
            bool killed = enemy.GetComponent <Enemy>().TakeDamage(_damage);

            _stats.TowerStats[Num - 1].Damage = _stats.TowerStats[Num - 1].Damage + _damage;
            if (killed == true)
            {
                _stats.TowerStats[Num - 1].Kills = _stats.TowerStats[Num - 1].Kills + 1;
            }
        }
    }
예제 #6
0
    private void Attack(GameObject target)
    {
        if (CanAttack == true)
        {
            AttackSound.Play();
            _meleeWeapon.MeleeAttack();
            CanAttack = false;

            if (target.gameObject.activeSelf == false)
            {
                GameObject newTarget = FindObjectOfType <Objective>().gameObject;

                EnemyTarget   = newTarget;
                FaceObjective = newTarget;
                gameObject.GetComponent <NavMeshAgent>().SetDestination(EnemyTarget.transform.position);
                GetComponent <NavMeshAgent>().isStopped = false;
            }
        }
    }
예제 #7
0
    void Update()
    {
        if (fEnemyHealth < fLastHealth)
        {
            TakingDamageSound.Play();
            fLastHealth = fEnemyHealth;
        }
        else
        {
            fLastHealth = fEnemyHealth;
        }

        if (fEnemyHealth > 0)
        {
            RaycastHit2D blockedInfoRight = Physics2D.Raycast(transform.position, Vector2.right, 5.1f, blockLayerMask);
            RaycastHit2D blockedInfoLeft  = Physics2D.Raycast(transform.position, Vector2.left, 5.1f, blockLayerMask);
            if (LineOfSightCheck() == true && tPlayer.GetComponent <PlayerController>().bBossFightCameraActive == false || fEnemyHealth < fEnemyMaxHealth)
            {
                animator.SetBool("AttackPlayer", true);
                //Debug.Log("Player Sighted");
                if (AttackSound.isPlaying == false)
                {
                    AttackSound.Play();
                }
                Attack();
            }
            else
            {
                animator.SetBool("AttackPlayer", false);
                AttackSound.Stop();
                Patrol();
                //Debug.Log("Patrol");
            }
        }
        else
        {
            Vector3 v3DeathPosition = transform.position;
            DropFuel(v3DeathPosition);
            Instantiate(DeathXplosionEffect, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
예제 #8
0
    private IEnumerator Explode()
    {
        MeshRenderer[] children = GetComponentsInChildren <MeshRenderer>();
        _explode.Play();
        AttackSound.Play();

        for (int i = 0; i < children.Length; i++)
        {
            children[i].gameObject.SetActive(false);
        }

        yield return(new WaitForSeconds(3.0f));

        for (int i = 0; i < children.Length; i++)
        {
            children[i].gameObject.SetActive(true);
        }
        CreditsOnDeath = 0;
        Death();
    }
예제 #9
0
 private void Attack()
 {
     AttackSound.Play();
     _projectileManager.FireArcProjectile(this.gameObject, _currentTarget.GetComponent <CapsuleCollider>(), _bullet, _force, _damage, Num);
 }