예제 #1
0
파일: Main.cs 프로젝트: mengtest/UnityMMO
        private void Update()
        {
            switch (cur_state)
            {
            case State.CheckExtractResource:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    this.gameObject.AddComponent <AssetsHotFixManager>();
                    AssetsHotFixManager.Instance.CheckExtractResource(delegate() {
                        Debug.Log("Main.cs CheckExtractResource OK!!!");
                        JumpToState(State.UpdateResourceFromNet);
                    });
                }
                break;

            case State.UpdateResourceFromNet:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    AssetsHotFixManager.Instance.UpdateResource(delegate() {
                        Debug.Log("Main.cs UpdateResourceFromNet OK!!!");
                        JumpToState(State.InitAssetBundle);
                    });
                }
                break;

            case State.InitAssetBundle:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    ResourceManager.GetInstance().Initialize(AppConfig.AssetDir, delegate() {
                        Debug.Log("Main.cs ResourceManager Initialize OK!!!");
                        JumpToState(State.StartGame);
                    });
                }
                break;

            case State.StartGame:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    this.gameObject.AddComponent <XLuaManager>();
                    UnityMMO.MainWorld.GetInstance().Initialize();
                    UnityMMO.MainWorld.GetInstance().StartGame();
                }
                break;
            }
        }
예제 #2
0
 public static void SetRawImage(RawImage img, string file_path, bool is_auto_size=false, LuaFunction func = null)
 {
     file_path = FillUIResPath(file_path);
     ResourceManager.GetInstance().LoadAsset<Texture>(file_path, delegate(UnityEngine.Object[] objs){
         if (img != null && objs != null && objs.Length>=1)
         {
             img.texture = objs[0] as Texture;
             if (is_auto_size)
                 img.SetNativeSize();
             if (func!=null)
                 func.Call();
         }
     });
     
 }
예제 #3
0
 public static void SetImage(Image img, string file_path, bool is_auto_size = false, LuaFunction func = null)
 {
     ResourceManager.GetInstance().LoadAsset <Sprite>(file_path, delegate(UnityEngine.Object[] objs){
         if (img != null && objs != null && objs.Length >= 1)
         {
             img.sprite = objs[0] as Sprite;
             if (is_auto_size)
             {
                 img.SetNativeSize();
             }
             if (func != null)
             {
                 func.Call();
             }
         }
     });
 }
예제 #4
0
파일: Main.cs 프로젝트: zj831007/UnityMMO
        private void Update()
        {
            if (cur_state == State.Playing)
            {
                return;
            }
            switch (cur_state)
            {
            case State.CheckExtractResource:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    loadingView.SetData(0.0f, "首次解压游戏数据(不消耗流量)");
                    this.gameObject.AddComponent <AssetsHotFixManager>();
                    AssetsHotFixManager.Instance.CheckExtractResource(delegate(float percent){
                        loadingView.SetData(0.3f * percent, "首次解压游戏数据(不消耗流量)");
                    }, delegate() {
                        Debug.Log("Main.cs CheckExtractResource OK!!!");
                        JumpToState(State.UpdateResourceFromNet);
                    });
                }
                break;

            case State.UpdateResourceFromNet:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    loadingView.SetData(0.3f, "从服务器下载最新的资源文件...");
                    AssetsHotFixManager.Instance.UpdateResource(delegate(float percent, string tip){
                        loadingView.SetData(0.3f + 0.5f * percent, tip);
                    }, delegate(string result) {
                        if (result == "")
                        {
                            Debug.Log("Main.cs UpdateResourceFromNet OK!!!");
                        }
                        else
                        {
                            Debug.Log(result);
                        }
                        JumpToState(State.InitAssetBundle);
                    });
                }
                break;

            case State.InitAssetBundle:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    loadingView.SetData(0.8f, "初始化游戏资源...");
                    ResourceManager.GetInstance().Initialize(AppConfig.AssetDir, delegate(float percent){
                        loadingView.SetData(0.8f + 0.2f * percent, "初始化游戏资源...");
                    }, delegate() {
                        Debug.Log("Main.cs ResourceManager Initialize OK!!!");
                        JumpToState(State.StartLogin);
                    });
                }
                break;

            case State.StartLogin:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    loadingView.SetData(1, "初始化游戏资源完毕");
                    XLuaManager.Instance.InitLuaEnv();
                    loadingView.SetActive(false, 0.5f);
                    XLuaManager.Instance.StartLogin(delegate() {
                        Debug.Log("Main.cs XLuaManager StartLogin OK!!!");
                        JumpToState(State.StartGame);
                    });
                }
                break;

            case State.StartGame:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    this.gameObject.AddComponent <UnityMMO.MainWorld>();
                    UnityMMO.MainWorld.Instance.StartGame();
                    JumpToState(State.Playing);
                }
                break;

            case State.Playing:
                break;
            }
        }
예제 #5
0
파일: Main.cs 프로젝트: stealdream/UnityMMO
        private void Update()
        {
            if (cur_state == State.Playing)
            {
                return;
            }
            switch (cur_state)
            {
            case State.CheckExtractResource:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    this.gameObject.AddComponent <AssetsHotFixManager>();
                    AssetsHotFixManager.Instance.CheckExtractResource(delegate() {
                        Debug.Log("Main.cs CheckExtractResource OK!!!");
                        JumpToState(State.UpdateResourceFromNet);
                    });
                }
                break;

            case State.UpdateResourceFromNet:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    AssetsHotFixManager.Instance.UpdateResource(delegate() {
                        Debug.Log("Main.cs UpdateResourceFromNet OK!!!");
                        JumpToState(State.InitAssetBundle);
                    });
                }
                break;

            case State.InitAssetBundle:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    ResourceManager.GetInstance().Initialize(AppConfig.AssetDir, delegate() {
                        Debug.Log("Main.cs ResourceManager Initialize OK!!!");
                        JumpToState(State.StartLogin);
                    });
                }
                break;

            case State.StartLogin:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    XLuaManager.Instance.InitLuaEnv();
                    XLuaManager.Instance.StartLogin(delegate() {
                        Debug.Log("Main.cs XLuaManager StartLogin OK!!!");
                        JumpToState(State.StartGame);
                    });
                }
                break;

            case State.StartGame:
                if (cur_sub_state == SubState.Enter)
                {
                    cur_sub_state = SubState.Update;
                    Debug.Log("main.cs start game");
                    this.gameObject.AddComponent <UnityMMO.MainWorld>();
                    Debug.Log("main.cs start game2");
                    UnityMMO.MainWorld.Instance.StartGame();
                    Debug.Log("main.cs start game3");
                    JumpToState(State.Playing);
                }
                break;

            case State.Playing:
                break;
            }
        }