Exemple #1
0
    private void DisplayText(AmmoText text)
    {
        switch (text)
        {
        case AmmoText.Eject:
            text_.text   = "EJECT!";
            text_.margin = new Vector4(0, 0, 0, 0);
            break;

        case AmmoText.Ejecting:
            text_.text   = "EJECTING...";
            text_.margin = new Vector4(28, 0, 0, 0);
            break;

        case AmmoText.Reload:
            text_.text   = "RELOAD!";
            text_.margin = new Vector4(10, 0, 0, 0);
            break;

        case AmmoText.Reloading:
            text_.text   = "RELOADING...";
            text_.margin = new Vector4(30, 0, 0, 0);
            break;

        default:
            text_.text = "";
            break;
        }
    }
        public void DrawHealth()
        {
            //HideHudAndRadarThisFrame();

            HideReticle();

            HealthText.Caption = Game.Player.Character.Health.ToString();


            AmmoText.Caption = Game.PlayerPed.Weapons.Current.AmmoInClip.ToString() + " + " + latestAmmo;

            if (Game.PlayerPed.IsReloading)
            {
                latestAmmo = Game.PlayerPed.Weapons.Current.Ammo - Game.PlayerPed.Weapons.Current.AmmoInClip;
            }

            DrawRectangle(0.025f, 0.9038f, 0.12f, 0.035f, 0, 0, 0, 200);
            float healthPercent = (float)Game.Player.Character.Health / Game.Player.Character.MaxHealth;

            if (healthPercent < 0)
            {
                healthPercent = 0;
            }
            if (healthPercent > 1)
            {
                healthPercent = 1;
            }
            DrawRectangle(0.025f, 0.9038f, healthPercent * 0.12f, 0.035f, 200, 46, 48, 255);
            DrawRectangle(0.025f, 0.9038f, 0.007f, 0.035f, 150, 1, 3, 255);

            float ammoPercent = (float)Game.PlayerPed.Weapons.Current.AmmoInClip / Game.PlayerPed.Weapons.Current.MaxAmmoInClip;

            DrawRectangle(0.025f, 0.94f, 0.12f, 0.03f, 0, 0, 0, 200);
            DrawRectangle(0.025f, 0.94f, ammoPercent * 0.12f, 0.03f, 206, 155, 1, 200);
            DrawRectangle(0.025f, 0.94f, 0.007f, 0.03f, 160, 106, 0, 255);

            HealthText.Draw();
            AmmoText.Draw();
        }
    public void ChangeAmmoUI(int AmmoValue, int num)
    {
        //num =0(r), =1(g), =2(b)
        GameObject[] AmmoTexts  = null;
        GameObject[] AmmoGauges = null;
        switch (num)
        {
        //赤
        case 0:
            AmmoTexts  = m_AmmoTexts_Red;
            AmmoGauges = m_AmmoGauges_Red;
            break;

        //緑
        case 1:
            AmmoTexts  = m_AmmoTexts_Green;
            AmmoGauges = m_AmmoGauges_Green;
            break;

        //青
        case 2:
            AmmoTexts  = m_AmmoTexts_Blue;
            AmmoGauges = m_AmmoGauges_Blue;
            break;
        }

        //UI更新
        foreach (GameObject AmmoText in AmmoTexts)
        {
            AmmoText.GetComponent <Text>().text = (AmmoValue).ToString() + "  /  255";
        }

        foreach (GameObject AmmoGauge in AmmoGauges)
        {
            AmmoGauge.GetComponent <Slider>().value = AmmoValue;
        }
    }
 private void Awake()
 {
     gameplayManager = GameObject.FindObjectOfType <AmmoText>();
 }