public void OnSelect(BaseEventData eventData)
    {
        GameObject             descriptionBox = transform.parent.parent.parent.parent.parent.parent.Find("Description Box").gameObject;
        WeaponButtonContatiner wbc            = GetComponent <WeaponButtonContatiner>();
        Weapon weapon = wbc.weapon;

        descriptionBox.gameObject.SetActive(true);
        Transform nameAndDesc = descriptionBox.transform.Find("Name and Desc");

        nameAndDesc.Find("Name").GetComponent <Text>().text        = weapon.weaponName;
        nameAndDesc.Find("Description").GetComponent <Text>().text = weapon.description;

        // Get attribute holder
        Transform attributes  = descriptionBox.transform.Find("Attributes");
        Transform dmg         = attributes.Find("Damage");
        Transform recoil      = attributes.Find("Recoil");
        Transform pushBack    = attributes.Find("PushBack");
        Transform variable    = attributes.Find("VariableAttribute");
        Transform ammoCap     = attributes.Find("AmmoCap");
        Transform reloadSpeed = attributes.Find("ReloadSpeed");

        // Zero vector
        Vector3 zeroed = new Vector3(0f, 0f, 0f);

        if (weapon is W_AutoGun)
        {
            // Set damage bar
            if (wbc.damage > 0)
            {
                dmg.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.damage / MenuManager.Instance().maxAutoDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.damage < 0)
            {
                dmg.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.damage / MenuManager.Instance().maxAutoDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set recoil bar
            if (wbc.recoil > 0)
            {
                recoil.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.recoil / MenuManager.Instance().maxAutoRecoil, 1f, 1f);
                recoil.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.recoil < 0)
            {
                recoil.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.recoil / MenuManager.Instance().maxAutoRecoil, 1f, 1f);;
                recoil.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set pushback bar
            if (wbc.pushback > 0)
            {
                pushBack.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.pushback / MenuManager.Instance().maxAutoPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.pushback < 0)
            {
                pushBack.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.pushback / MenuManager.Instance().maxAutoPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set Variable bar
            variable.Find("Text").GetComponent <Text>().text     = "Fire Rate";
            variable.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.variable / MenuManager.Instance().maxFireRate, 1f, 1f);

            // Set ammo capacity bar
            ammoCap.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.ammoCapacity / MenuManager.Instance().maxAutoAmmo, 1f, 1f);

            // Set reload speed bar
            reloadSpeed.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.reloadSpeed / MenuManager.Instance().maxAutoReloadSpeed, 1f, 1f);
        }
        else if (weapon is W_SemiGun)
        {
            // Set damage bar
            if (wbc.damage > 0)
            {
                dmg.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.damage / MenuManager.Instance().maxSemiDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.damage < 0)
            {
                dmg.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.damage / MenuManager.Instance().maxSemiDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set recoil bar
            if (wbc.recoil > 0)
            {
                recoil.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.recoil / MenuManager.Instance().maxSemiRecoil, 1f, 1f);
                recoil.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.recoil < 0)
            {
                recoil.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.recoil / MenuManager.Instance().maxSemiRecoil, 1f, 1f);;
                recoil.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set pushback bar
            if (wbc.pushback > 0)
            {
                pushBack.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.pushback / MenuManager.Instance().maxSemiPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.pushback < 0)
            {
                pushBack.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.pushback / MenuManager.Instance().maxSemiPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set Variable bar
            variable.Find("Text").GetComponent <Text>().text     = "Scatter Count";
            variable.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.variable / MenuManager.Instance().maxScatterCount, 1f, 1f);

            // Set ammo capacity bar
            ammoCap.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.ammoCapacity / MenuManager.Instance().maxSemiAmmo, 1f, 1f);

            // Set reload speed bar
            reloadSpeed.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.reloadSpeed / MenuManager.Instance().maxSemiReloadSpeed, 1f, 1f);
        }
        else if (weapon is W_Launcher)
        {
            // Set damage bar
            if (wbc.damage > 0)
            {
                dmg.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.damage / MenuManager.Instance().maxLauncherDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.damage < 0)
            {
                dmg.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.damage / MenuManager.Instance().maxLauncherDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set recoil bar
            if (wbc.recoil > 0)
            {
                recoil.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.recoil / MenuManager.Instance().maxLauncherRecoil, 1f, 1f);
                recoil.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.recoil < 0)
            {
                recoil.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.recoil / MenuManager.Instance().maxLauncherRecoil, 1f, 1f);;
                recoil.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set pushback bar
            if (wbc.pushback > 0)
            {
                pushBack.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.pushback / MenuManager.Instance().maxLauncherPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.pushback < 0)
            {
                pushBack.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.pushback / MenuManager.Instance().maxLauncherPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set Variable bar
            variable.Find("Text").GetComponent <Text>().text     = "Projectile Power";
            variable.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.variable / MenuManager.Instance().maxProjectilePower, 1f, 1f);

            // Set ammo capacity bar
            ammoCap.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.ammoCapacity / MenuManager.Instance().maxLauncherAmmo, 1f, 1f);

            // Set reload speed bar
            reloadSpeed.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.reloadSpeed / MenuManager.Instance().maxLauncherReloadSpeed, 1f, 1f);
        }
        else if (weapon is W_Sprayer)
        {
            // Set damage bar
            if (wbc.damage > 0)
            {
                dmg.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.damage / MenuManager.Instance().maxSprayerDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.damage < 0)
            {
                dmg.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.damage / MenuManager.Instance().maxSprayerDamage, 1f, 1f);
                dmg.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set recoil bar
            if (wbc.recoil > 0)
            {
                recoil.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.recoil / MenuManager.Instance().maxSprayerRecoil, 1f, 1f);
                recoil.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.recoil < 0)
            {
                recoil.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.recoil / MenuManager.Instance().maxSprayerRecoil, 1f, 1f);;
                recoil.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set pushback bar
            if (wbc.pushback > 0)
            {
                pushBack.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.pushback / MenuManager.Instance().maxSprayerPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Negative").localScale = zeroed;
            }
            else if (wbc.pushback < 0)
            {
                pushBack.Find("BarBack").Find("Negative").localScale = new Vector3(-1 * wbc.pushback / MenuManager.Instance().maxSprayerPushback, 1f, 1f);
                pushBack.Find("BarBack").Find("Positive").localScale = zeroed;
            }

            // Set Variable bar
            variable.Find("Text").GetComponent <Text>().text     = "Sprayer Distance";
            variable.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.variable / MenuManager.Instance().maxSprayDistance, 1f, 1f);

            // Set ammo capacity bar
            ammoCap.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.ammoCapacity / MenuManager.Instance().maxSprayerAmmo, 1f, 1f);

            // Set reload speed bar
            reloadSpeed.Find("BarBack").Find("Positive").localScale = new Vector3(wbc.reloadSpeed / MenuManager.Instance().maxSprayerReloadSpeed, 1f, 1f);
        }
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        lastVisitedMenu = MainMenu;

        foreach (Transform child in menuGroup.transform)
        {
            menuList.Add(child.gameObject);
        }

        // Clear selected object
        EventSystem.current.SetSelectedGameObject(null);
        // Set button to MainFirst
        EventSystem.current.SetSelectedGameObject(mainFirstButton);

        // Go through all register Achievements
        foreach (Achievement a in AchievementManager.Instance().achievements)
        {
            // Create a GameObject based on achDisplay prefab
            GameObject curr = Instantiate(achievementPrefab, achievementContent.transform);

            MakeDisplay(curr, a);
        }

        // Set up Weapon loadout
        order = new Dictionary <string, Dictionary <WeaponRarity, List <Weapon> > >();
        // Dictionary 1 - Type { Auto = 0, Semi = 1, Launcher = 2, Sprayer = 3, ... }
        for (int i = 0; i < System.Enum.GetValues(typeof(WeaponType)).Length - 1; i++)  // - 1 gets rid of "none" from enum
        {
            switch (i)
            {
            case 0:
                order.Add("Automatic", new Dictionary <WeaponRarity, List <Weapon> >());
                break;

            case 1:
                order.Add("Semiautomatic", new Dictionary <WeaponRarity, List <Weapon> >());
                break;

            case 2:
                order.Add("Launcher", new Dictionary <WeaponRarity, List <Weapon> >());
                break;

            case 3:
                order.Add("Sprayer", new Dictionary <WeaponRarity, List <Weapon> >());
                break;

            default:
                Debug.LogError("Something went wrong");
                break;
            }
            // Dictionary 2 - Rarity { Common = 0, Uncommon = 1, Rare = 2, Legenday = 3 }
            foreach (WeaponRarity rarity in System.Enum.GetValues(typeof(WeaponRarity)))
            {
                string type = "";
                switch (i)
                {
                case 0:
                    type = "Automatic";
                    break;

                case 1:
                    type = "Semiautomatic";
                    break;

                case 2:
                    type = "Launcher";
                    break;

                case 3:
                    type = "Sprayer";
                    break;

                default:
                    Debug.LogError("Something went wrong");
                    break;
                }
                order[type].Add(rarity, new List <Weapon>());
            }
        }

        // Load weapons
        WeaponManager.Instance().LoadLoadout();

        // Sort through existing Weapons
        List <Weapon> allWeapons = WeaponManager.Instance().weapons;

        foreach (Weapon w in allWeapons)
        {
            WeaponRarity wr = w.rarity;

            if (w is W_AutoGun) // ordering[0]
            {
                switch (wr)
                {
                case WeaponRarity.Common:
                    order["Automatic"][WeaponRarity.Common].Add(w);
                    break;

                case WeaponRarity.Uncommon:
                    order["Automatic"][WeaponRarity.Uncommon].Add(w);
                    break;

                case WeaponRarity.Rare:
                    order["Automatic"][WeaponRarity.Rare].Add(w);
                    break;

                case WeaponRarity.Legendary:
                    order["Automatic"][WeaponRarity.Rare].Add(w);
                    break;

                default:
                    Debug.LogError("Auto weapon does not have listed rarity");
                    break;
                }
            }
            else if (w is W_SemiGun) // ordering[1]
            {
                switch (wr)
                {
                case WeaponRarity.Common:
                    order["Semiautomatic"][WeaponRarity.Common].Add(w);
                    break;

                case WeaponRarity.Uncommon:
                    order["Semiautomatic"][WeaponRarity.Uncommon].Add(w);
                    break;

                case WeaponRarity.Rare:
                    order["Semiautomatic"][WeaponRarity.Rare].Add(w);
                    break;

                case WeaponRarity.Legendary:
                    order["Semiautomatic"][WeaponRarity.Legendary].Add(w);
                    break;

                default:
                    Debug.LogError("Semi weapon does not have listed rarity");
                    break;
                }
            }
            else if (w is W_Launcher) // ordering[2]
            {
                switch (wr)
                {
                case WeaponRarity.Common:
                    order["Launcher"][WeaponRarity.Common].Add(w);
                    break;

                case WeaponRarity.Uncommon:
                    order["Launcher"][WeaponRarity.Uncommon].Add(w);
                    break;

                case WeaponRarity.Rare:
                    order["Launcher"][WeaponRarity.Rare].Add(w);
                    break;

                case WeaponRarity.Legendary:
                    order["Launcher"][WeaponRarity.Legendary].Add(w);
                    break;

                default:
                    Debug.LogError("Launcher weapon does not have listed rarity");
                    break;
                }
            }
            else if (w is W_Sprayer) // ordering[3]
            {
                switch (wr)
                {
                case WeaponRarity.Common:
                    order["Sprayer"][WeaponRarity.Common].Add(w);
                    break;

                case WeaponRarity.Uncommon:
                    order["Sprayer"][WeaponRarity.Uncommon].Add(w);
                    break;

                case WeaponRarity.Rare:
                    order["Sprayer"][WeaponRarity.Rare].Add(w);
                    break;

                case WeaponRarity.Legendary:
                    order["Sprayer"][WeaponRarity.Legendary].Add(w);
                    break;

                default:
                    Debug.LogError("Sprayer weapon does not have listed rarity");
                    break;
                }
            }
        }   // Done with Sorting

        // Set the Maxes
        GetMaxes();

        // Construct the display
        foreach (KeyValuePair <string, Dictionary <WeaponRarity, List <Weapon> > > type in order)
        {
            // Create group
            GameObject typeGroup = Instantiate(groupPrefab, weaponContent.transform);

            // Put name in group
            typeGroup.transform.Find("Weapon Type").Find("Text").GetComponent <Text>().text = type.Key;

            // Get area for Weapons
            Transform weaponList = typeGroup.transform.Find("Weapons");

            foreach (KeyValuePair <WeaponRarity, List <Weapon> > rarity in type.Value)
            {
                Color background;
                switch (rarity.Key)
                {
                case WeaponRarity.Common:
                    background = Color.white;
                    break;

                case WeaponRarity.Uncommon:
                    background = Color.green;
                    break;

                case WeaponRarity.Rare:
                    background = Color.blue;
                    break;

                case WeaponRarity.Legendary:
                    background = Color.magenta;
                    break;

                default:
                    background = Color.black;
                    break;
                }

                foreach (Weapon w in rarity.Value)
                {
                    // Create Weapon Display
                    GameObject weapon = Instantiate(weaponPrefab, weaponList);
                    weapon.GetComponent <Button>().onClick.AddListener(() => ChooseWeapon(w));
                    if (!w.unlocked)
                    {
                        weapon.GetComponent <Button>().interactable = false;
                    }
                    weaponButtons.Add(weapon);

                    // Set Weapon & stats
                    WeaponButtonContatiner wbc = weapon.transform.GetComponent <WeaponButtonContatiner>();
                    wbc.weapon = w;
                    // assign attributes
                    if (w is W_AutoGun)
                    {
                        W_AutoGun auto = (W_AutoGun)w;
                        wbc.damage       = auto.bulletDamage;
                        wbc.recoil       = auto.recoil;
                        wbc.pushback     = auto.bulletPushback;
                        wbc.variable     = 1f / auto.fireRate;
                        wbc.ammoCapacity = auto.ammoCapacity;
                        wbc.reloadSpeed  = 1f / auto.reloadRate;
                    }
                    else if (w is W_SemiGun)
                    {
                        W_SemiGun semi = (W_SemiGun)w;
                        wbc.damage       = semi.bulletDamage;
                        wbc.recoil       = semi.recoil;
                        wbc.pushback     = semi.bulletPushback;
                        wbc.variable     = semi.burstCount;
                        wbc.ammoCapacity = semi.ammoCapacity;
                        wbc.reloadSpeed  = 1f / semi.reloadRate;
                    }
                    else if (w is W_Launcher)
                    {
                        W_Launcher launcher = (W_Launcher)w;
                        wbc.damage       = launcher.coreDamage;
                        wbc.recoil       = launcher.recoil;
                        wbc.pushback     = launcher.corePushback;
                        wbc.variable     = launcher.projectilePower;
                        wbc.ammoCapacity = launcher.ammoCapacity;
                        wbc.reloadSpeed  = 1f / launcher.reloadRate;
                    }
                    else if (w is W_Sprayer)
                    {
                        W_Sprayer sprayer = (W_Sprayer)w;
                        wbc.damage       = sprayer.bulletDamage;
                        wbc.recoil       = sprayer.recoil;
                        wbc.pushback     = sprayer.bulletPushback;
                        wbc.variable     = sprayer.sprayDistance;
                        wbc.ammoCapacity = sprayer.ammoCapacity;
                        wbc.reloadSpeed  = 1f / sprayer.reloadRate;
                    }

                    // Set image
                    weapon.transform.Find("Image").GetComponent <Image>().sprite = w.icon;

                    // Set Rarity
                    weapon.GetComponent <Image>().color = background;
                }
            }
        }
    }
Ejemplo n.º 3
0
    public void OnPlayerJoined(PlayerInput loadoutLayout)
    {
        int playerId = MenuManager.Instance().numPlayers++;

        loadoutLayout.GetComponent <TempFix>().playerId = playerId;

        // Put layout in correct spot
        loadoutLayout.transform.SetParent(transform, false);
        loadoutLayout.gameObject.name = "Player Loadout " + playerId;

        // set button onClick()'s
        // Back Arm
        Transform backArm = loadoutLayout.transform.Find("Loadouts").Find("Back Arm Loadout");

        backArm.Find("Weapon A").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "BA"));
        backArm.Find("Weapon B").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "BB"));
        backArm.Find("Weapon C").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "BC"));
        backArm.Find("Weapon D").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "BD"));
        // Front Arm
        Transform frontArm = loadoutLayout.transform.Find("Loadouts").Find("Front Arm Loadout");

        frontArm.Find("Weapon A").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "FA"));
        frontArm.Find("Weapon B").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "FB"));
        frontArm.Find("Weapon C").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "FC"));
        frontArm.Find("Weapon D").GetComponent <Button>().onClick.AddListener(() => DisplayWeapons(playerId + "FD"));

        WeaponManager.Instance().LoadLoadout();

        // Update Loadouts
        for (int i = 0; i < WeaponManager.Instance().playerLoadouts[playerId][0].Length; i++)
        {
            backArm.GetChild(i + 1).Find("Image").GetComponent <Image>().sprite  = WeaponManager.Instance().playerLoadouts[playerId][0][i].icon;
            frontArm.GetChild(i + 1).Find("Image").GetComponent <Image>().sprite = WeaponManager.Instance().playerLoadouts[playerId][1][i].icon;
        }

        Dictionary <string, Dictionary <WeaponRarity, List <Weapon> > > order = MenuManager.Instance().order;

        // Check that Display not already made
        if (weaponButtons.ContainsKey(playerId))
        {
            return;
        }
        // Construct the display
        List <GameObject> temp = new List <GameObject>();

        foreach (KeyValuePair <string, Dictionary <WeaponRarity, List <Weapon> > > type in order)
        {
            // Create group
            Transform  weaponContent = loadoutLayout.transform.Find("Selection").Find("Scroll View").Find("Viewport").Find("Content");
            GameObject typeGroup     = Instantiate(groupPrefab, weaponContent);

            // Put name in group
            typeGroup.transform.Find("Weapon Type").Find("Text").GetComponent <Text>().text = type.Key;

            // Get area for Weapons
            Transform weaponList = typeGroup.transform.Find("Weapons");

            foreach (KeyValuePair <WeaponRarity, List <Weapon> > rarity in type.Value)
            {
                Color background;
                switch (rarity.Key)
                {
                case WeaponRarity.Common:
                    background = Color.white;
                    break;

                case WeaponRarity.Uncommon:
                    background = Color.green;
                    break;

                case WeaponRarity.Rare:
                    background = Color.blue;
                    break;

                case WeaponRarity.Legendary:
                    background = Color.magenta;
                    break;

                default:
                    background = Color.black;
                    break;
                }

                foreach (Weapon w in rarity.Value)
                {
                    // Create Weapon Display
                    GameObject weapon = Instantiate(weaponPrefab, weaponList);
                    weapon.GetComponent <Button>().onClick.AddListener(() => ChooseWeapon(playerId, w));
                    if (!w.unlocked)
                    {
                        weapon.GetComponent <Button>().interactable = false;
                    }
                    temp.Add(weapon);

                    // Set Weapon & stats
                    WeaponButtonContatiner wbc = weapon.transform.GetComponent <WeaponButtonContatiner>();
                    wbc.weapon = w;
                    // assign attributes
                    if (w is W_AutoGun)
                    {
                        W_AutoGun auto = (W_AutoGun)w;
                        wbc.damage       = auto.bulletDamage;
                        wbc.recoil       = auto.recoil;
                        wbc.pushback     = auto.bulletPushback;
                        wbc.variable     = 1f / auto.fireRate;
                        wbc.ammoCapacity = auto.ammoCapacity;
                        wbc.reloadSpeed  = 1f / auto.reloadRate;
                    }
                    else if (w is W_SemiGun)
                    {
                        W_SemiGun semi = (W_SemiGun)w;
                        wbc.damage       = semi.bulletDamage;
                        wbc.recoil       = semi.recoil;
                        wbc.pushback     = semi.bulletPushback;
                        wbc.variable     = 1f / semi.burstCount;
                        wbc.ammoCapacity = semi.ammoCapacity;
                        wbc.reloadSpeed  = 1f / semi.reloadRate;
                    }
                    else if (w is W_Launcher)
                    {
                        W_Launcher launcher = (W_Launcher)w;
                        wbc.damage       = launcher.coreDamage;
                        wbc.recoil       = launcher.recoil;
                        wbc.pushback     = launcher.corePushback;
                        wbc.variable     = 1f / launcher.projectilePower;
                        wbc.ammoCapacity = launcher.ammoCapacity;
                        wbc.reloadSpeed  = 1f / launcher.reloadRate;
                    }
                    else if (w is W_Sprayer)
                    {
                        W_Sprayer sprayer = (W_Sprayer)w;
                        wbc.damage       = sprayer.bulletDamage;
                        wbc.recoil       = sprayer.recoil;
                        wbc.pushback     = sprayer.bulletPushback;
                        wbc.variable     = 1f / sprayer.sprayDistance;
                        wbc.ammoCapacity = sprayer.ammoCapacity;
                        wbc.reloadSpeed  = 1f / sprayer.reloadRate;
                    }

                    // Set image
                    weapon.transform.Find("Image").GetComponent <Image>().sprite = w.icon;

                    // Set Rarity
                    weapon.GetComponent <Image>().color = background;
                }
            }
        }

        weaponButtons.Add(playerId, temp);
    }