Exemple #1
0
 bool EnemyInRange(Transform enemy, GunSettingsNetworked gun)
 {
     if (Vector3.Distance(enemy.position, transform.position) > gun.attackRangeMin && Vector3.Distance(enemy.position, transform.position) < gun.attackRangeMax)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
 bool withinRange(GunSettingsNetworked gun, TroopActorNetworked troop)
 {
     if (Vector3.Distance(troop.transform.position, transform.position) > gun.attackRangeMin && Vector3.Distance(troop.transform.position, transform.position) < gun.attackRangeMax)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
    TroopActorNetworked ClosestEnemy(GunSettingsNetworked gun)
    {
        float dis = 0f;
        TroopActorNetworked closestEnemy = null;

        foreach (TroopActorNetworked ta in op.allTroopActors)
        {
            if (ta.rankState != RankState.dead)
            {
                if ((dis == 0f || Vector3.Distance(ta.transform.position, transform.position) < dis) && EnemyInRange(ta.transform, gun) && ta != this && ta.team != team)
                {
                    dis          = Vector3.Distance(ta.transform.position, transform.position);
                    closestEnemy = ta;
                }
            }
        }
        return(closestEnemy);
    }
Exemple #4
0
    void Fire(GunSettingsNetworked gun)
    {
        gun.onShoot.Invoke();

        RaycastHit hit;

        if (gun.attackTarget.currentHealth - gun.damage <= 0)
        {
            gun.onKillShot.Invoke();
        }

        if (Physics.Raycast(transform.position, (gun.attackTarget.transform.position - transform.position), out hit, Vector3.Distance(transform.position, gun.attackTarget.transform.position)))
        {
            if (hit.transform.gameObject.GetComponent <TroopActorNetworked>() != null)
            {
                hit.transform.gameObject.GetComponent <TroopActorNetworked>().TakeDamage(10);
            }
        }
    }
Exemple #5
0
    bool EnemyInSights(GunSettingsNetworked gun)
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, (gun.attackTarget.transform.position - transform.position), out hit, Vector3.Distance(transform.position, gun.attackTarget.transform.position)))
        {
            if (hit.transform != gun.attackTarget.transform)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        else
        {
            return(true);
        }
    }
Exemple #6
0
 void ResetGunTimer(GunSettingsNetworked gun)
 {
     gun.m_gunTimer = Random.Range((gun.TimeBetweenShots - (gun.TimeBetweenShots * gun.m_gunTimerRandomiser)), (gun.TimeBetweenShots + (gun.TimeBetweenShots * gun.m_gunTimerRandomiser)));
 }