Esempio n. 1
0
    //Ship31 Secondary
    public void Ship31Secondary()
    {
        List <Transform> bulletSpecialSpawnPoints = new List <Transform>();
        int i = 0;

        foreach (Transform child in transform)
        {
            if (child.CompareTag("BulletSpawn") && child.name.Contains("BulletSpawnPointSecondary"))
            {
                bulletSpecialSpawnPoints.Add(child.transform);
                i++;
            }
        }

        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;


        if (shipHandling.currentBattery >= shipDetails.Secondary.BatteryCharge)
        {
            List <Transform> usedSpawnPoints = new List <Transform>();

            usedSpawnPoints = bulletSpecialSpawnPoints;



            foreach (Transform currBulletSpawnPoint in usedSpawnPoints)
            {
                GameObject bullet = (GameObject)Instantiate(
                    shipDetails.Secondary.SecondaryPrefab,
                    currBulletSpawnPoint.position,
                    currBulletSpawnPoint.rotation);
                bullet.GetComponent <BulletCollision>().bulletOwnerPlayerNumber = shipHandling.playerNumber;
                Transform transform = bullet.GetComponentInChildren <Transform>();
                transform.localScale = new Vector3(shipDetails.Secondary.Scale, shipDetails.Secondary.Scale, shipDetails.Secondary.Scale);
                bullet.GetComponent <BulletCollision>().bulletHitPoints = shipDetails.Secondary.HitPoints;
                bullet.gameObject.tag = "Bullet";

                // Add velocity to the bullet
                bullet.GetComponent <Rigidbody>().velocity = bullet.transform.forward * shipDetails.Secondary.Speed;

                BulletCollision bulletCol = bullet.GetComponentInChildren <BulletCollision>();

                bulletCol.setDamage(shipDetails.Secondary.Damage);

                createdBullets.Add(bullet);

                // Destroy the bullet after X seconds
                Destroy(bullet, shipDetails.Secondary.TimeToLive);

                CheckForMaxInstances();
            }


            shipHandling.currentBattery    = shipHandling.currentBattery - shipDetails.Secondary.BatteryCharge;
            shipHandling.lastSecondaryUsed = Time.time;
        }
    }
Esempio n. 2
0
    private void GenericPrimaryShoot()
    {
        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;
        float        usedFireRate = shipDetails.Primary.FireRate;


        if (Time.time > usedFireRate + shipHandling.lastShot)
        {
            if (shipHandling.currentBattery >= shipDetails.Primary.BatteryCharge)
            {
                List <Transform> usedSpawnPoints = new List <Transform>();

                usedSpawnPoints = bulletSpawnPoints;

                foreach (Transform currBulletSpawnPoint in usedSpawnPoints)
                {
                    GameObject bullet = (GameObject)Instantiate(
                        shipDetails.Primary.bulletPrefab,
                        currBulletSpawnPoint.position,
                        currBulletSpawnPoint.rotation);
                    bullet.transform.parent = gameObject.transform;
                    bullet.GetComponent <BulletCollision>().bulletOwnerPlayerNumber = shipHandling.playerNumber;
                    bullet.GetComponent <BulletCollision>().bulletHitPoints         = shipDetails.Primary.HitPoints;
                    bullet.gameObject.tag = "Bullet";

                    Transform transform = bullet.GetComponentInChildren <Transform>();
                    transform.localScale = new Vector3(shipDetails.Primary.Scale, shipDetails.Primary.Scale, shipDetails.Primary.Scale);


                    // Add velocity to the bullet
                    bullet.GetComponent <Rigidbody>().velocity = bullet.transform.forward * shipDetails.Primary.Speed;

                    BulletCollision bulletCol = bullet.GetComponentInChildren <BulletCollision>(); //transform.Find("BulletCollision");
                                                                                                   //ScriptB other = (ScriptB)go.GetComponent(typeof(ScriptB));
                    bulletCol.setDamage(shipDetails.Primary.Damage);

                    createdBullets.Add(bullet);

                    // Destroy the bullet after X seconds
                    Destroy(bullet, shipDetails.Primary.TimeToLive);

                    CheckForMaxInstances();
                }

                shipHandling.currentBattery = shipHandling.currentBattery - shipDetails.Primary.BatteryCharge;
                shipHandling.lastShot       = Time.time;
            }
        }
    }
Esempio n. 3
0
    public void DeployMine()
    {
        List <Transform> bulletSpecialSpawnPoints = new List <Transform>();
        int i = 0;

        foreach (Transform child in transform)
        {
            if (child.CompareTag("BulletSpawn") && child.name.Contains("BulletSpawnPointSecondary"))
            {
                bulletSpecialSpawnPoints.Add(child.transform);
                i++;
            }
        }

        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;


        foreach (Transform currBulletSpawnPoint in bulletSpecialSpawnPoints)
        {
            GameObject bullet = (GameObject)Instantiate(
                shipDetails.Secondary.SecondaryPrefab,
                currBulletSpawnPoint.position,
                currBulletSpawnPoint.rotation);
            bullet.GetComponent <BulletCollision>().bulletOwnerPlayerNumber = shipHandling.playerNumber;
            Transform transform = bullet.GetComponentInChildren <Transform>();
            transform.localScale = new Vector3(shipDetails.Secondary.Scale, shipDetails.Secondary.Scale, shipDetails.Secondary.Scale);
            bullet.GetComponent <BulletCollision>().bulletHitPoints = shipDetails.Secondary.HitPoints;
            bullet.gameObject.tag = "Bullet";
            bullet.GetComponent <BulletCollision>().isMine = true;
            bullet.transform.SetPositionAndRotation(currBulletSpawnPoint.position, Quaternion.identity);

            BulletCollision bulletCol = bullet.GetComponentInChildren <BulletCollision>();

            bulletCol.setDamage(shipDetails.Secondary.Damage);
            createdBullets.Add(bullet);

            Destroy(bullet, shipDetails.Secondary.TimeToLive);

            CheckForMaxInstances();
        }

        shipHandling.currentBattery    = shipHandling.currentBattery - shipDetails.Secondary.BatteryCharge;
        shipHandling.lastSecondaryUsed = Time.time;
    }