void SpawnDrop(WeaponNames weaponDrop, Transform spawn, Vector2Int ammo)
    {
        GameObject drop = PlayerWeaponLoader.GetWeapon(weaponDrop).dropPrefab;

        drop = Instantiate(drop, spawn.position, spawn.rotation);
        drop.GetComponent <WeaponPickup>().SetAmmo(ammo);
    }
Ejemplo n.º 2
0
 public static WeaponPrefab GetWeapon(WeaponNames name)
 {
     if (WeaponSet.ContainsKey(name))
     {
         return(WeaponSet[name]);
     }
     return(new WeaponPrefab());
 }
Ejemplo n.º 3
0
 private void AddWeaponNames()
 {
     WeaponNames.Add("Schwert");
     WeaponNames.Add("Breitschwert");
     WeaponNames.Add("Shamshir");
     WeaponNames.Add("Katana");
     WeaponNames.Add("Leichtschwert");
     WeaponNames.Add("Breitschwert");
 }
Ejemplo n.º 4
0
 public Weapon(WeaponNames weaponName)
 {
     this.weaponName = weaponName;
     if (weaponName == WeaponNames.handgun)
     {
         GunDefinition();
     }
     if (weaponName == WeaponNames.rifle)
     {
         RifleDefinition();
     }
 }
    public bool SwapWeapon(WeaponNames newWeapon, Transform pickup, int totalAmmo, int clipAmmo = -1)
    {
        WeaponPrefab newPrefab = PlayerWeaponLoader.GetWeapon(newWeapon);
        Weapon       old       = weapons[currentWeapon];
        int          slot      = (currentWeapon == 0) ? 1 : 0;

        if (!old.Ready || !old.gameObject.activeSelf || switchingWeapons || newPrefab.weaponPrefab == null || old.gunLocked)
        {
            return(false);
        }

        if (weapons[1] != null)
        {
            if (weapons[slot] != null)
            {
                slot = currentWeapon;
            }

            old = weapons[slot];
            switchingWeapons = true;

            Vector2Int dropAmmo = new Vector2Int();
            dropAmmo.x = old.GetAmmo();
            dropAmmo.y = old.ammunition.AmmoLeft();

            if (dropAmmo.magnitude > 0)
            {
                SpawnDrop(old.thisWeapon, pickup, dropAmmo);
            }

            StartCoroutine(SwapWeaponSequence(newPrefab, old, (slot == currentWeapon), slot, clipAmmo, totalAmmo));
        }
        else
        {
            Weapon instance = Instantiate(newPrefab.weaponPrefab, transform.position, transform.rotation, transform);
            weapons[1] = instance;
            instance.SetAmmo(clipAmmo);
            instance.ammunition.SetAmmo(totalAmmo);
            instance.gameObject.SetActive(false);
            SwitchWeapon();
        }

        if (OnPickedUpWeapon != null)
        {
            OnPickedUpWeapon();
        }
        return(true);
    }
Ejemplo n.º 6
0
        public void WeaponManage(Player player, WeaponNames weaponName)
        {
            if (player.GetFirstWeapon().GetWeaponName() == WeaponNames.unarmed)
            {
                player.SetFirstWeapon(new Weapon(weaponName));
            }

            else if (player.GetSecondWeapon().GetWeaponName() == WeaponNames.unarmed)
            {
                player.WeaponSwap();
                player.SetFirstWeapon(new Weapon(weaponName));
            }
            else if (player.GetFirstWeapon().GetWeaponName() != WeaponNames.unarmed && player.GetSecondWeapon().GetWeaponName() != WeaponNames.unarmed)
            {
                player.SetFirstWeapon(new Weapon(weaponName));
            }
        }
 public static string GetWeaponKey(WeaponNames w)
 {
     return(w.ToString() + "Skin");
 }
Ejemplo n.º 8
0
 public void SetWeaponName(WeaponNames weaponName)
 {
     this.weaponName = weaponName;
 }