zoukankan      html  css  js  c++  java
  • 随机Loading

    using UnityEngine;
    using System.Collections;
    
    public class Loading : MonoBehaviour
    {
        public bool m_IsReset;
        public GameObject[] m_CurBgs;
        private UI_ViewDur m_Progress;
        void Start()
        {
            if (m_IsReset)
            {
                PlayerPrefs.SetInt("CurLoadingBg", 0);
            }
    
            m_Progress = GetComponent<UI_ViewDur>();
            int curBgIndex = PlayerPrefs.GetInt("CurLoadingBg");
            int index1 = curBgIndex, index2 = curBgIndex, index3 = curBgIndex;
            bool b1 = false, b2 = false, b3 = false;
    
            Debug.Log("当前Idengx" + curBgIndex);
            if (curBgIndex != 0)
            {
                switch (curBgIndex)
                {
                    case 1:
                        b1 = false;
                        b2 = true;
                        b3 = false;
                        index1 -= 1;
                        index2 += 0;
                        index3 += 1;
                        PlayerPrefs.SetInt("CurLoadingBg", index2+1);//2
                        break;
                    case 2:
                        b1 = false;
                        b2 = false;
                        b3 = true;
                        index1 -= 2;
                        index2 += -1;
                        index3 += 0;
                        PlayerPrefs.SetInt("CurLoadingBg", index3+1);//3
                        break;
                    case 3:
                        b1 = true;
                        b2 = false;
                        b3 = false;
                        index1 -= 3;
                        index2 += -2;
                        index3 += -1;
                        PlayerPrefs.SetInt("CurLoadingBg", index1+1);//1
                        break;
                }
                m_CurBgs[index1].SetActive(b1);
                m_CurBgs[index2].SetActive(b2);
                m_CurBgs[index3].SetActive(b3);
            }
            else
            {
                for (int i = 1; i < m_CurBgs.Length + 1; i++)
                {
                    if (m_CurBgs[i - 1].activeSelf)
                    {
                        Debug.Log("当前CurLoadingBg=" + i);
                        PlayerPrefs.SetInt("CurLoadingBg", i);
                    }
                }
            }
            //StartCoroutine(LoadLevel());
        }
        public AsyncOperation async;
        IEnumerator LoadLevel()
        {
            //async = Application.LoadLevelAsync(Global.s_Instance.CurLoadSceneName);
            async = Application.LoadLevelAsync("moou");
            yield return async;
        }
        public int progress = 0;
        public float m_Var = 0;
        void Update()
        {
            if (Random.RandomRange(0, 10) == 1)
            {
                m_Var += Random.RandomRange(0f, 0.06f);
            }
    
            m_Progress.ViewBlood(m_Var);
            //m_Progress.ViewBlood(async.progress + 0.1f);
            if (m_Var >= 1f)
            {
                Debug.Log("GIC: " + Global.s_Instance.CurLoadSceneName);
                Application.LoadLevel(Global.s_Instance.CurLoadSceneName);
            }
            //m_Progress.value = async.progress + 0.1f;
            // progress = (int)(async.progress * 100);
            //Debug.Log(progress);
            //Debug.Log(async.progress);
        }
    }
  • 相关阅读:
    二:虚拟游戏摇杆
    一:AndEngine的小例子
    打造属于自己的安卓Metro界面
    linux设备驱动第四篇:驱动调试方法
    C# 二叉查找树实现
    初识 Angular 体会
    C# 霍夫曼二叉树压缩算法实现
    TypeScript笔记[5]泛型+Dictionary 转
    Axiom3D学习日记 5.Frame Listeners, and Input Handling
    Axiom3D学习日记 4.地形,天空,雾
  • 原文地址:https://www.cnblogs.com/123ing/p/4054246.html
Copyright © 2011-2022 走看看