示例#1
0
    void OnGUI()
    {
        //show mags
        if (weaponData.magazines > 0)
        {
            GUI.Label(new Rect(50, Screen.height - 90, 100, 40), new GUIContent(weaponData.magazines + " Magazines"));
        }
        else if (weaponData.magazines == 1)
        {
            GUI.Label(new Rect(50, Screen.height - 90, 100, 40), new GUIContent(weaponData.magazines + " Magazine"));
        }
        else
        {
            GUI.Label(new Rect(50, Screen.height - 90, 100, 40), new GUIContent("-- Magazines"));
        }


        if (!weaponData.GetReloading())
        {
            //show bullets
            if (weaponData.GetBullets() > 0)
            {
                GUI.Label(new Rect(50, Screen.height - 70, 100, 20), new GUIContent(weaponData.GetBullets() + " Bullets"));
            }
            else if (weaponData.GetBullets() == 1)
            {
                GUI.Label(new Rect(50, Screen.height - 70, 100, 20), new GUIContent(weaponData.GetBullets() + " Bullet"));
            }
            else
            {
                GUI.Label(new Rect(50, Screen.height - 70, 100, 20), new GUIContent("-- Bullet"));
            }
        }
        else
        {
            //show cooldown
            if (weaponData.magazines != -1)
            {
                GUI.Label(new Rect(50, Screen.height - 70, 100, 20), new GUIContent("RELOADING " + weaponData.GetReloadingTimer() + " seconds"));
            }
            else
            {
                GUI.Label(new Rect(50, Screen.height - 70, 100, 20), new GUIContent("COOLDOWN " + weaponData.GetReloadingTimer() + " seconds"));
            }
        }
    }
示例#2
0
    void Update()
    {
        GameObject curWeapon     = weapons.GetComponent <WeaponManager>().GetWeapon();
        WeaponData curWeaponData = curWeapon.GetComponent <WeaponData>();

        //This is much more efficient than before
        switch (curWeapon.name)
        {
        default:
            text.SetText("Mike f****d up somewhere");
            break;

        case "EmptyHand":
            text.SetText("");
            break;

        case "Sword":
            text.SetText("");
            break;

        case "pistol":

            if (curWeaponData.GetReloading())
            {
                text.SetText("Reloading...");
            }
            else
            {
                text.SetText(curWeaponData.GetLoadedAmmo() + "/" + curWeaponData.GetMaxLoadedAmmo());
            }
            break;

        case "grenade":
            text.SetText(curWeaponData.GetLoadedAmmo() + "/" + curWeaponData.GetMaxLoadedAmmo());
            break;
        }
    }