예제 #1
0
    void Hitcheck()
    {
        Ray        ray = new Ray(shootOrigin[0].position, shootOrigin[0].forward);
        RaycastHit hitinfo;

        if (Physics.Raycast(ray, out hitinfo, range))
        {
            if (teamToHit == GameController.Teams.Player)
            {
                LifeManager_Player lifeMan = hitinfo.transform.GetComponent <LifeManager_Player>();
                if (lifeMan != null)
                {
                    lifeMan.ReceiveDamage(damage, hitinfo.point);
                }
            }
            else if (teamToHit == GameController.Teams.Enemy)
            {
                LifeManager lifeMan = hitinfo.transform.GetComponent <LifeManager>();
                if (lifeMan != null)
                {
                    lifeMan.ReceiveDamage(damage, hitinfo.point);
                }
            }
        }
        chargeTotal = 0;
        GameObject laser = Instantiate(laserPrefab, shootOrigin[0].position, shootOrigin[0].rotation) as GameObject;

        laser.GetComponent <Raygun_Laser>().Initialize(Vector3.zero, hitinfo.point, laserColor);
    }
예제 #2
0
 void OnTriggerEnter(Collider col)
 {
     if (col.isTrigger)
     {
         return;
     }
     if (teamToHit == GameController.Teams.Player)
     {
         LifeManager_Player lifeMan = col.gameObject.GetComponent <LifeManager_Player>();
         if (lifeMan != null)
         {
             lifeMan.ReceiveDamage(damage, transform.position);
         }
         else
         {
             SpawnParticles();
         }
     }
     else if (teamToHit == GameController.Teams.Enemy)
     {
         LifeManager lifeMan = col.gameObject.GetComponent <LifeManager>();
         if (lifeMan != null)
         {
             lifeMan.ReceiveDamage(damage, transform.position);
         }
         else
         {
             SpawnParticles();
         }
     }
     Destroy(gameObject);
 }
예제 #3
0
 void Explode()
 {
     Collider[] hits = Physics.OverlapSphere(transform.position, explosionRadius);
     foreach (Collider col in hits)
     {
         if (teamToHit == GameController.Teams.Player)
         {
             LifeManager_Player lifeMan = col.gameObject.GetComponent <LifeManager_Player>();
             if (lifeMan != null)
             {
                 lifeMan.ReceiveDamage(damage, transform.position);
             }
         }
         else if (teamToHit == GameController.Teams.Enemy)
         {
             LifeManager lifeMan = col.gameObject.GetComponent <LifeManager>();
             if (lifeMan != null)
             {
                 lifeMan.ReceiveDamage(damage, transform.position);
             }
         }
     }
     Instantiate(explosionEffect, transform.position, Quaternion.identity);
     Destroy(gameObject);
 }