void Attack()
    {
        timer = 0f;

        CharacterStatistics playerStatistics = player.GetComponent <CharacterStatistics>();

        playerStatistics.TakeDamage(attackDamage);
    }
예제 #2
0
    public void Fire(float angle)
    {
        Debug.LogError("Time between bullet" + timeBetweenBullets);
        anim_weapon.Play();

        Debug.LogError("Je tire Gatling");
        gunAudio.Play();

        // Enable the light.
        //gunLight.enabled = true;

        // Stop the particles from playing if they were, then start the particles.
        gunParticles.Stop();
        gunParticles.Play();

        // Enable the line renderer and set it's first position to be the end of the gun.
        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);

        // Set the shootRay so that it starts at the end of the gun and points forward from the barrel.
        shootRay.origin = transform.position;
        //TO DO : A modifier en fonction de langle
        //shootRay.direction = transform.forward;

        float random = (float)(Random.NextDouble() * (2) - 1);

        Vector3 point = Quaternion.AngleAxis(random * angle, Vector3.up) * transform.forward;

        point.y = 0f;

        shootRay.direction = point;

        // Perform the raycast against gameobjects on the shootable layer and if it hits something...
        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            //Enemmy interaction
            // Try and find an EnemyHealth script on the gameobject hit.
            if (shootHit.collider.CompareTag("Zombie"))
            {
                CharacterStatistics zombieStatistics = shootHit.collider.GetComponent <CharacterStatistics>();
                zombieStatistics.TakeDamage(damage);

                // Set the second position of the line renderer to the point the raycast hit.
                gunLine.SetPosition(1, shootHit.point);
            }
            else
            {
                gunLine.SetPosition(1, shootHit.point);
            }
        }
        // If the raycast didn't hit anything on the shootable layer...
        else
        {
            // ... set the second position of the line renderer to the fullest extent of the gun's range.
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
예제 #3
0
 public void OnTriggerStay(Collider other)
 {
     if (canHit)
     {
         if (other.gameObject.tag == "Zombie")
         {
             CharacterStatistics zombieStatistics = other.GetComponent <CharacterStatistics>();
             zombieStatistics.TakeDamage(damage);
             Debug.LogError("J'attaque au Lance Flamme");
             canHit = false;
         }
     }
 }
예제 #4
0
 public void OnTriggerEnter(Collider other)
 {
     if (canHit)
     {
         if (other.gameObject.tag == "Zombie")
         {
             CharacterStatistics zombieStatistics = other.GetComponent <CharacterStatistics>();
             zombieStatistics.TakeDamage(damage);
             if (name_player == "Gaara")
             {
                 Debug.LogError("Je passe ici");
                 owner.GetComponent <Gaara>().AddFureur(40);
             }
             Debug.LogError("J'attaque au Katana");
             canHit = false;
         }
     }
 }
    void HurtPuddle()
    {
        CharacterStatistics playerStatistics = player.GetComponent <CharacterStatistics>();

        playerStatistics.TakeDamage(damagePerTime);
    }
    void Hurt()
    {
        CharacterStatistics playerStatistics = player.GetComponent <CharacterStatistics>();

        playerStatistics.TakeDamage(damagePerShot);
    }