示例#1
0
        IEnumerator ReloadRoutine()
        {
            yield return(null);                         //in case the the previous weapon was switch while reloading, give it a frame to stop the ReloadRoutine

            reloading = true;
            uiButtonWeapon.button.interactable = false;
            uiButtonWeapon.labelAlt.alignment  = TextAnchor.MiddleLeft;

            UnitPlayer player = GameControl.GetPlayer();

            while (player != null && player.Reloading())
            {
                string dot   = "";
                int    count = (int)Mathf.Floor((Time.time * 3) % 4);
                for (int i = 0; i < count; i++)
                {
                    dot += ".";
                }
                for (int i = count; i < 3; i++)
                {
                    dot += " ";
                }
                uiButtonWeapon.labelAlt.text = "Reloading" + dot;

                float durationRemain = player.GetReloadDuration() - player.GetCurrentReload();
                uiButtonWeapon.labelAlt2.text = durationRemain <= 0 ? "" : durationRemain.ToString("f1") + "s";

                yield return(null);
            }

            uiButtonWeapon.labelAlt.text      = "";
            uiButtonWeapon.labelAlt.alignment = TextAnchor.MiddleRight;

            uiButtonWeapon.labelAlt2.text      = "";
            uiButtonWeapon.button.interactable = true;

            reloading = false;
        }
示例#2
0
        void Update()
        {
            UnitPlayer player = GameControl.GetPlayer();

            if (player == null)
            {
                return;
            }

            cursorT.localPosition = Input.mousePosition * UIMainControl.GetScaleFactor();

            rectDefaultCursor.sizeDelta = cursorDefaultSize + new Vector2(player.GetRecoil() * 2, player.GetRecoil() * 2);

            if (player.Reloading())
            {
                ShowReloading();
                imgReloading.fillAmount = player.GetCurrentReload() / player.GetReloadDuration();
            }
            else
            {
                HideReloading();
            }
        }