Esempio n. 1
0
    void SetBulletDamage(NameWeapon weaponName, GameObject bullet)
    {
        switch (weaponName)
        {
        case NameWeapon.PISTOL:
            bullet.GetComponent <BulletController>().damage = 2;
            break;

        case NameWeapon.MP5:
            bullet.GetComponent <BulletController>().damage = 3;

            break;

        case NameWeapon.M3:
            bullet.GetComponent <BulletController>().damage = 4;

            break;

        case NameWeapon.AK:
            bullet.GetComponent <BulletController>().damage = 5;

            break;

        case NameWeapon.AWP:
            bullet.GetComponent <BulletController>().damage = 10;

            break;

        case NameWeapon.ROCKET:
            bullet.GetComponent <BulletController>().damage = 10;

            break;
        }
    }
Esempio n. 2
0
    public void SpawnBullet(Vector3 position, Vector3 direction, Quaternion rotation, NameWeapon weaponName)
    {
        if (weaponName != NameWeapon.ROCKET)
        {
            for (int i = 0; i < bullet_Prefabs.Count; i++)
            {
                if (!bullet_Prefabs[i].activeInHierarchy)
                {
                    bullet_Prefabs[i].SetActive(true);
                    bullet_Prefabs[i].transform.position = position;
                    bullet_Prefabs[i].transform.rotation = rotation;

                    bullet_Prefabs[i].GetComponent <BulletController>().SetDirection(direction);


                    SetBulletDamage(weaponName, bullet_Prefabs[i]);

                    break;
                }
            }
        }
        else
        {
            for (int i = 0; i < rocket_Bullet_Prefabs.Count; i++)
            {
                if (!rocket_Bullet_Prefabs[i].activeInHierarchy)
                {
                    rocket_Bullet_Prefabs[i].SetActive(true);
                    rocket_Bullet_Prefabs[i].transform.position = position;
                    rocket_Bullet_Prefabs[i].transform.rotation = rotation;

                    rocket_Bullet_Prefabs[i].GetComponent <BulletController>().SetDirection(direction);

                    SetBulletDamage(weaponName, rocket_Bullet_Prefabs[i]);

                    break;
                }
            }
        }
    }