///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void Eraser_Weapon()
    {
        //-----------

        Class_Controller.eraserMouseButtonDown = true;

        Class_Controller.playerDistanceWeapon = 300;
        GameObject bullet = WeaponsPool.GiveWeapons(11);

        if (Class_Interface.powerEnabled == false)
        {
            bullet.transform.localScale = Vector3.one * 10;
        }
        else
        {
            bullet.transform.localScale = Vector3.one * 12;
        }
        bullet.transform.SetPositionAndRotation(aim.position, aim.rotation);
        bullet.SetActive(true);
        if (Class_Interface.powerEnabled == false)
        {
            bullet.GetComponent <Rigidbody>().AddForce(aim.forward * 400);
        }
        else
        {
            bullet.GetComponent <Rigidbody>().AddForce(aim.forward * 500);
        }

        //-----------

        Class_Interface.eraserCounter -= 1;

        //-----------
    }
    public static IEnumerator BulletLifetime(Rigidbody thisRigidbody, GameObject gameObject)
    {
        //--------------

        yield return(delay0);

        thisRigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete;
        thisRigidbody.detectCollisions       = false;
        thisRigidbody.isKinematic            = true;

        WeaponsPool.TakeWeapons(gameObject);

        //--------------
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void Lightning_Weapon()
    {
        //-----------

        Class_Controller.lightningMouseButtonDown = true;

        if (weaponsLightSparks.activeSelf == false)
        {
            weaponsLightSparks.SetActive(true);
            Invoke("Lightning_Weapon_Add", 0.65f);
        }

        //-----------

        GameObject bulletFx = WeaponsPool.GiveWeapons(5);

        if (Physics.CapsuleCast(aim.position, aim.position, 5, aim.forward, out weaponsRaycastHit, 200, 1 << 10 | 1 << 28 | 1 << 29 | 1 << 19 | 1 << 20 | 1 << 21 | 1 << 31))
        {
            hitPointVector3 = weaponsRaycastHit.point;
            Class_Controller.playerDistanceWeapon = weaponsRaycastHit.distance;

            GameObject bullet = WeaponsPool.GiveWeapons(1);
            bullet.transform.SetPositionAndRotation(hitPointVector3, Quaternion.LookRotation(weaponsRaycastHit.normal));
            bullet.SetActive(true);

            bulletFx.transform.position = pointOfShotStart.position;
            bulletFx.transform.LookAt(hitPointVector3);
            bulletFx.SetActive(true);
            bulletFx.GetComponent <Rigidbody>().AddForce(bulletFx.transform.forward * (500 + Class_Controller.currentSpeed * 9));
        }
        else
        {
            Class_Controller.playerDistanceWeapon = 100;
            bulletFx.transform.position           = pointOfShotStart.position;
            bulletFx.SetActive(true);
            bulletFx.GetComponent <Rigidbody>().AddForce(aim.forward * (500 + Class_Controller.currentSpeed * 9));
        }

        //-----------

        if (lightningCounterAdd++ >= 2)
        {
            lightningCounterAdd = 0;
            Class_Interface.lightningCounter -= 1;
        }

        //-----------
    }
Esempio n. 4
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void DestrBool()
    {
        //--------------

        if (bulletFx == true)
        {
            thisRigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete;
            thisRigidbody.isKinematic            = true;
        }

        if (sparks == true)
        {
            sparks.SetActive(false);
        }

        WeaponsPool.TakeWeapons(gameObject);

        //--------------
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void Default_Weapon()
    {
        //-----------

        Class_Controller.defaultMouseButtonDown = true;

        if (weaponsDefaultSparks.activeSelf == false)
        {
            weaponsDefaultSparks.SetActive(true);
            Invoke("Default_Weapon_Add", 0.5f);
        }

        //-----------

        GameObject bulletFx = WeaponsPool.GiveWeapons(3);

        if (Physics.CapsuleCast(aim.position, aim.position, 2.5f, aim.forward, out weaponsRaycastHit, 350, 1 << 10 | 1 << 28 | 1 << 29 | 1 << 19 | 1 << 20 | 1 << 21 | 1 << 31))
        {
            hitPointVector3 = weaponsRaycastHit.point;
            Class_Controller.playerDistanceWeapon = weaponsRaycastHit.distance;

            GameObject bullet = WeaponsPool.GiveWeapons(0);
            bullet.transform.SetPositionAndRotation(hitPointVector3, Quaternion.LookRotation(weaponsRaycastHit.normal));
            bullet.SetActive(true);

            bulletFx.transform.position = pointOfShotStart.position;
            bulletFx.transform.LookAt(hitPointVector3);
            bulletFx.SetActive(true);
            bulletFx.GetComponent <Rigidbody>().AddForce(bulletFx.transform.forward * (500 + (Class_Controller.currentSpeed * 9) + weaponsRaycastHit.distance));
        }
        else
        {
            Class_Controller.playerDistanceWeapon = 100;
            bulletFx.transform.SetPositionAndRotation(pointOfShotStart.position, pointOfShotStart.rotation);
            bulletFx.SetActive(true);
            bulletFx.GetComponent <Rigidbody>().AddForce(aim.forward * (500 + Class_Controller.currentSpeed * 9));
        }

        //-----------
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    public static void Explosion(Transform thisTransform, GameObject collisionObject, GameObject gameObject, Rigidbody thisRigidbody, float explosionPower, float explosionRadius)
    {
        //--------------

        if (collisionObject.layer == 8 || collisionObject.layer == 10 || collisionObject.layer == 14 || collisionObject.layer == 28 || collisionObject.layer == 29 || collisionObject.layer == 30 || collisionObject.layer == 31)
        {
            if (collisionObject.layer == 10 || collisionObject.layer == 14 || collisionObject.layer == 28)
            {
                Rigidbody collisionRigidbody = collisionObject.GetComponent <Rigidbody>();
                if (collisionRigidbody != null)
                {
                    collisionRigidbody.AddExplosionForce(explosionPower, thisTransform.position, explosionRadius, 3.0F);
                }
            }

            thisRigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete;
            thisRigidbody.detectCollisions       = false;
            thisRigidbody.isKinematic            = true;

            WeaponsPool.TakeWeapons(gameObject);
        }

        //--------------
    }
Esempio n. 7
0
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    void Shooting(float distanceC)
    {
        //--------------

        if (distanceC < atackDistancePow0 && distanceC > atackDistance1)
        {
            speed = 7 * speedBehavior;
            if (aiAgr == true || attack == true)
            {
                aiAgr = attack = false;
            }
        }
        else if (distanceC < atackDistance1 && distanceC > atackDistance2)
        {
            speed = 20 * speedBehavior;
            if (aiAgr == true || attack == true)
            {
                aiAgr = attack = false;
            }
        }
        else if (distanceC < atackDistance2 && distanceC > atackDistance3)
        {
            speed = 5 * speedBehavior;
            if (aiAgr == true)
            {
                aiAgr = false;
            }
            if (counter5++ > counter19)
            {
                counter5  = 0;
                counter19 = Random.Range(15, 25);
                attack    = true;
            }
            else if (attack == true)
            {
                attack = false;
            }
        }
        else if (distanceC < atackDistance3 && distanceC > atackDistance4 * randomAtackDistance)
        {
            speed = 3 * speedBehavior;
            if (Class_Interface.tamingEnabled == false)
            {
                aiAgr = true;
            }
            if (counter5++ > counter19)
            {
                counter5  = 0;
                counter19 = Random.Range(6, 16);
                attack    = true;
            }
            else if (attack == true)
            {
                attack = false;
            }
        }
        else if (distanceC < atackDistance4 * randomAtackDistance)
        {
            if (dodge == false)
            {
                speed = -12 * speedBehavior;
            }
            else
            {
                speed = 6 * speedBehavior;
            }

            if (Class_Interface.tamingEnabled == false)
            {
                aiAgr = true;
            }
            if (counter5++ > counter19)
            {
                counter5  = 0;
                counter19 = Random.Range(3, 7);
                attack    = true;
            }
            else if (attack == true)
            {
                attack = false;
            }
        }

        //--------------

        if (attack == true && contusion == false && Class_Interface.tamingEnabled == false && dodge == false)
        {
            if (Mathf.Sqrt(Class_Controller.SqrMagnitudeToPlayer(thisTransform)) < thisAudioSource.maxDistance)
            {
                thisAudioSource.pitch     = Random.Range(0.7f, 1.15f);
                thisAudioSource.panStereo = Random.Range(-0.1f, 0.1f);
                thisAudioSource.PlayOneShot(soundsFx[Random.Range(0, 2)], Random.Range(0.1f, 0.25f));
            }
            if (weaponSparks != null && weaponSparks.activeSelf == false && lodUpdate0 == false && lodUpdate1 == false)
            {
                weaponSparks.SetActive(true);
            }
            GameObject bullet = WeaponsPool.GiveWeapons(9);
            bullet.transform.parent   = null;
            bullet.transform.position = thisTransform.position + (thisTransform.forward * 1.5f);
            bullet.SetActive(true);
            bullet.GetComponent <Rigidbody>().AddForce(thisTransform.forward * bulletSpeed);
        }

        //--------------
    }
Esempio n. 8
0
 private void Awake()
 {
     weaponsPool   = new WeaponsPool(new Weapon(Weapon.Type.Torpedo, Weapon.Status.Disarmed), 3);
     explosionPool = new ExplosionPool(new Explosion(Explosion.Type.Large), 3);
 }
 private void Awake()
 {
     TorpedoTestHarness.torpedoPool   = new WeaponsPool(new Weapon(Weapon.Type.Torpedo, Weapon.Status.Disarmed), 3);
     TorpedoTestHarness.explosionPool = new ExplosionPool(new Explosion(Explosion.Type.Large), 3);
 }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



    IEnumerator Laser_Weapon()
    {
        //-----------

        if (laserTrigger0 == false)
        {
            Class_Controller.laserMouseButtonDown = true;
        }

        weaponsLaserSparks.SetActive(true);

        if (Physics.CapsuleCast(aim.position, aim.position, 2.5f, aim.forward, out weaponsRaycastHit, 500, 1 << 10 | 1 << 28 | 1 << 29 | 1 << 19 | 1 << 20 | 1 << 21 | 1 << 31))
        {
            laserColliderObject = weaponsRaycastHit.collider.gameObject;
            Class_Controller.playerDistanceWeapon = weaponsRaycastHit.distance;
            laserTrigger1 = true;
        }
        else
        {
            Class_Controller.playerDistanceWeapon = 100;
            laserTrigger1 = false;
        }

        laserTrigger0 = true;
        int stopCounter = 0;

        //-----------

        while (laserTrigger0 == true)
        {
            yield return(delay0);

            GameObject bulletFx = WeaponsPool.GiveWeapons(4);
            bulletFx.transform.position = pointOfShotStart.position;
            bulletFx.SetActive(true);

            if (laserTrigger1 == true)
            {
                GameObject bullet = WeaponsPool.GiveWeapons(2);
                bullet.transform.SetPositionAndRotation(hitPointVector3, Quaternion.LookRotation(weaponsRaycastHit.normal));
                bullet.SetActive(true);
                bulletFx.transform.LookAt(hitPointVector3);
                bulletFx.GetComponent <Rigidbody>().AddForce(bulletFx.transform.forward * (1000 + Class_Controller.currentSpeed * 9));
            }
            else
            {
                bulletFx.GetComponent <Rigidbody>().AddForce(aim.forward * (1000 + Class_Controller.currentSpeed * 9));
            }

            if (stopCounter++ > 3)
            {
                stopCounter = 0;
                laserLineRenderer.enabled = laserTrigger0 = false;
                weaponsLaserSparks.SetActive(false);
            }
        }

        //-----------

        if (laserCounterAdd++ >= 10)
        {
            laserCounterAdd = 0;
            Class_Interface.laserCounter -= 1;
        }

        //-----------
    }