Ejemplo n.º 1
0
    //TODO: modify this function to return a bullet from the Pool
    public GameObject GetBullet(Transform parent, BulletTypeEnum bulletType)
    {
        //Debug.Log(bulletType);
        if (bulletType == BulletTypeEnum.TOTAL)
        {
            return(null);
        }

        int t = (int)bulletType;

        //int firstChecked = lastActive;
        for (int i = 0; i < sceneBullets[t].Count; ++lastActive[t], ++i)
        {
            if (lastActive[t] >= sceneBullets[t].Count)
            {
                lastActive[t] -= sceneBullets[t].Count;
            }
            if (!sceneBullets[t][lastActive[t]].activeSelf)
            {
                sceneBullets[t][lastActive[t]].SetActive(true);
                sceneBullets[t][lastActive[t]].name = "ACTIVE " + bulletType.ToString();
                return(sceneBullets[t][lastActive[t]]);
            }
        }

        int previousSize = sceneBullets[t].Count;

        InstantiateBulletcluster(parent, bulletType);
        sceneBullets[t][previousSize].SetActive(true);
        //sceneBullets[previousSize].transform.SetParent(parent);
        sceneBullets[t][previousSize].name = "ACTIVE " + bulletType.ToString();
        return(sceneBullets[t][previousSize]);

        //return bullet;
    }
Ejemplo n.º 2
0
    IEnumerator FireEnumerator()
    {
        if (BulletLayerMask == "Enemy")
        {
            int random = Random.Range(1, 3);
            _bulletType = (BulletTypeEnum)random;
        }
        else
        {
            _bulletType = BulletTypeEnum.Player;
        }

        while (true)
        {
            if (_fire)
            {
                foreach (var weapon in Data.WeaponDataList)
                {
                    if (weapon.IsActive)
                    {
                        FireBullet(weapon.WeaponTransform, Data.BulletSpeed, null, false, Data.BulletDamage);
                    }
                }

                yield return(new WaitForSeconds(Data.BulletDelay));
            }

            yield return(new WaitUntil(() => _fire));
        }
    }
Ejemplo n.º 3
0
    public void SetBullet(BulletTypeEnum bulletType)
    {
        if (bulletType == BulletTypeEnum.Black)
        {
            pistolText.color = Color.black;

            pistolText.text = "∞";

            currentBulletPrefab.GetComponent <Renderer>().material = bulletMaterials[0];

            currentBulletPrefab.bulletType = BulletController.BulletTypeEnum.Black;

            currentBulletPrefab.GetComponent <TrailRenderer>().sharedMaterial.SetColor("_EmissionColor", new Color(0.0f, 0.0f, 0.0f));
        }

        if (bulletType == BulletTypeEnum.Blue)
        {
            pistolText.color = Color.blue;

            pistolText.text = "" + bulletsCounter[BulletController.BulletTypeEnum.Blue];

            currentBulletPrefab.GetComponent <Renderer>().material = bulletMaterials[1];

            currentBulletPrefab.bulletType = BulletController.BulletTypeEnum.Blue;

            currentBulletPrefab.GetComponent <TrailRenderer>().sharedMaterial.SetColor("_EmissionColor", new Color(0.0f, 0.0f, 1.0f));
        }

        if (bulletType == BulletTypeEnum.Red)
        {
            pistolText.color = Color.red;

            pistolText.text = "" + bulletsCounter[BulletController.BulletTypeEnum.Red];

            currentBulletPrefab.GetComponent <Renderer>().material = bulletMaterials[2];

            currentBulletPrefab.bulletType = BulletController.BulletTypeEnum.Red;

            currentBulletPrefab.GetComponent <TrailRenderer>().sharedMaterial.SetColor("_EmissionColor", new Color(1.0f, 0.0f, 0.0f));
        }

        if (bulletType == BulletTypeEnum.Yellow)
        {
            pistolText.color = Color.yellow;

            pistolText.text = "" + bulletsCounter[BulletController.BulletTypeEnum.Yellow];

            currentBulletPrefab.GetComponent <Renderer>().material = bulletMaterials[3];

            currentBulletPrefab.bulletType = BulletController.BulletTypeEnum.Yellow;

            currentBulletPrefab.GetComponent <TrailRenderer>().sharedMaterial.SetColor("_EmissionColor", new Color(1.0f, 1.0f, 0.0f));
        }
    }
Ejemplo n.º 4
0
 void InstantiateBulletcluster(Transform parent, BulletTypeEnum bulletType)
 {
     for (int i = 0; i < bulletCluster; ++i)
     {
         GameObject NEW_BULLET = BulletFactory.publicFactory.GetNewBullet(bulletType);
         //NEW_BULLET = GameObject.Instantiate(bullet);
         NEW_BULLET.name = "Inactive";
         NEW_BULLET.transform.SetParent(parent);
         sceneBullets[(int)bulletType].Add(NEW_BULLET);
     }
 }
Ejemplo n.º 5
0
    public GameObject GetNewBullet(BulletTypeEnum bulletType)
    {
        GameObject NEW_BULLET = null;

        switch (bulletType)
        {
        case BulletTypeEnum.BULLET:
            NEW_BULLET = GameObject.Instantiate(bullet);
            break;

        case BulletTypeEnum.PELLET:
            NEW_BULLET = GameObject.Instantiate(pellet);
            break;

        case BulletTypeEnum.JIMMY:
            NEW_BULLET = GameObject.Instantiate(jimmy);
            break;

        default:
            break;
        }

        return(NEW_BULLET);
    }