예제 #1
0
    private void SelectWeapon(Items.WeaponData weaponData, GameObject player)
    {
        switch (weaponData.WeaponType)
        {
        case WeaponType.Rifle:
            player.AddComponent <Riffle>();
            break;

        case WeaponType.Laser:
            player.AddComponent <Laser>();
            break;

        case WeaponType.Shotgun:
            player.AddComponent <Shotgun>();
            break;

        case WeaponType.RocketLuncher:
            player.AddComponent <RocketLuncher>();
            break;
        }

        var weaponComponet = player.GetComponent <Weapon>();

        weaponComponet.Damage = weaponData.Damage;
        weaponComponet.SecondsBetweenShoot = weaponData.TimeBetweenShoot;
        weaponComponet.MaxAmmo             = weaponData.Ammo;
        weaponComponet.minRefillAmmo       = weaponData.MinRefillAmmo;
        weaponComponet.Range       = weaponData.Range;
        weaponComponet.Dispersion  = weaponData.Dispersion;
        weaponComponet.BulletSpeed = weaponData.Speed;
        weaponComponet.Bullet      = weaponData.Projectile;
        weaponComponet.Muzzle      = weaponData.Muzzle;
    }
예제 #2
0
    public void ChangeEquipedWeaponText(Items.WeaponData weaponData)
    {
        if (weaponData == null)
        {
            return;
        }

        damageValueText.text    = weaponData.Damage.ToString();
        rangeValueText.text     = weaponData.Range.ToString();
        fireSpeedValueText.text = weaponData.TimeBetweenShoot.ToString();
        ammoValueText.text      = weaponData.Ammo.ToString();
        weaponNameText.text     = weaponData.Name;
    }
예제 #3
0
        public static WeaponData DefaultWeapon()
        {
            WeaponData weapon = new WeaponData();

            weapon.WeaponType = WeaponType.Rifle;

            weapon.Name             = "RIFLE";
            weapon.Ammo             = 750;
            weapon.MinRefillAmmo    = 20;
            weapon.Damage           = 10;
            weapon.Dispersion       = 5;
            weapon.Range            = 25;
            weapon.TimeBetweenShoot = 0.15f;
            weapon.Speed            = 75;
            weapon.Projectile       = LoadItemPrefab("Weapons/Rifle");
            weapon.Muzzle           = LoadItemPrefab("Weapons/Muzzle");
            return(weapon);
        }
예제 #4
0
        private static WeaponData GenerateWeapon()
        {
            WeaponData weapon     = new WeaponData();
            WeaponType weaponType = (WeaponType)Random.Range(0, 4);

            weapon.WeaponType = weaponType;

            switch (weaponType)
            {
            case WeaponType.Rifle:
                weapon.Name             = "RIFLE";
                weapon.Ammo             = Random.Range(1200, 2000);  // TODO Consider about ranges of weapons
                weapon.MinRefillAmmo    = 25;
                weapon.Damage           = Random.Range(30, 50);      // TODO Consider about ranges of weapons
                weapon.Dispersion       = Random.Range(0, 10);       // TODO Consider about ranges of weapons
                weapon.Range            = Random.Range(50, 125);     // TODO Consider about ranges of weapons
                weapon.TimeBetweenShoot = Random.Range(0.15f, 0.3f); // TODO Consider about ranges of weapons
                weapon.Speed            = 75;
                weapon.Projectile       = LoadItemPrefab("Weapons/Rifle");
                weapon.Muzzle           = LoadItemPrefab("Weapons/Muzzle");
                break;

            case WeaponType.Laser:
                weapon.Name             = "LASER";
                weapon.Ammo             = Random.Range(3000, 10000); // TODO Consider about ranges of weapons
                weapon.MinRefillAmmo    = 200;
                weapon.Damage           = Random.Range(0.5f, 5f);    // TODO Consider about ranges of weapons
                weapon.Dispersion       = Random.Range(0, 0);        // TODO Consider about ranges of weapons
                weapon.Range            = Random.Range(50, 125);     // TODO Consider about ranges of weapons
                weapon.TimeBetweenShoot = 0.01f;
                weapon.Speed            = 0;
                weapon.Projectile       = LoadItemPrefab("Weapons/Laser");
                weapon.Muzzle           = LoadItemPrefab("Weapons/Muzzle");
                break;

            case WeaponType.Shotgun:
                weapon.Name             = "SHOTGUN";
                weapon.Ammo             = Random.Range(100, 500);   // TODO Consider about ranges of weapons
                weapon.MinRefillAmmo    = 5;
                weapon.Damage           = Random.Range(2f, 15f);    // TODO Consider about ranges of weapons
                weapon.Dispersion       = Random.Range(0, 15);      // TODO Consider about ranges of weapons
                weapon.Range            = Random.Range(25, 125);    // TODO Consider about ranges of weapons
                weapon.TimeBetweenShoot = Random.Range(0.2f, 0.8f); // TODO Consider about ranges of weapons
                weapon.Speed            = 100;
                weapon.Projectile       = LoadItemPrefab("Weapons/Shotgun");
                weapon.Muzzle           = LoadItemPrefab("Weapons/Muzzle");
                break;

            case WeaponType.RocketLuncher:
                weapon.Name             = "ROCKET LUNCHER";
                weapon.Ammo             = Random.Range(20, 250);  // TODO Consider about ranges of weapons
                weapon.MinRefillAmmo    = 1;
                weapon.Damage           = Random.Range(20f, 40f); // TODO Consider about ranges of weapons
                weapon.Dispersion       = Random.Range(0, 0);     // TODO Consider about ranges of weapons
                weapon.Range            = Random.Range(25, 125);  // TODO Consider about ranges of weapons
                weapon.TimeBetweenShoot = Random.Range(0.5f, 2f); // TODO Consider about ranges of weapons
                weapon.Speed            = 30;
                weapon.Projectile       = LoadItemPrefab("Weapons/Rocket");
                weapon.Muzzle           = LoadItemPrefab("Weapons/Muzzle");
                break;
            }

            return(weapon);
        }