Exemple #1
0
    // Use this for initialization
	void Start () {
       controlScript =  GameObject.FindGameObjectWithTag(StateManager.CONTROL_SCRIPT_TAG);
       loadAssetBundle = controlScript.GetComponent<LoadAssetBundle>();
       saveProgress = controlScript.GetComponent<SaveProgress>();
       loadProgress = controlScript.GetComponent<LoadProgress>();
       stateManager = controlScript.GetComponent<StateManager>();
	}
 void Awake()
 {
     assetPath = Application.streamingAssetsPath;
     expandedName = ".unity3d";
     if(Instance == null)
     {
         Instance = this;
     }
 }
Exemple #3
0
    void Awake()
    {
        if (_instance == null)
        {
            //If I am the first instance, make me the Singleton
            _instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            //If a Singleton already exists and you find
            //another reference in scene, destroy it!
            if (this != _instance)
            {
                Destroy(this.gameObject);
            }
        }

        //Res.list_avata = Resources.LoadAll<Sprite>("Avata");
        //for (int i = 0; i < Res.list_avata.Length; i++) {

        //}
        // Res.list_avata = LoadAssetBundle.LoadSprite()
        // Res.list_emotions = Resources.LoadAll<Sprite>("Emotions");
        Res.list_cards = Resources.LoadAll <Sprite>("Cards/cardall");
        IMEI           = "357238040933272";//SystemInfo.deviceUniqueIdentifier;
        if (panelWaiting == null)
        {
            LoadAssetBundle.LoadPrefab(Res.AS_PREFABS, Res.AS_PREFABS_WAITING, (obj) => {
                panelWaiting = obj.GetComponent <PanelWaiting>();
                panelWaiting.transform.SetParent(parentUI);
                panelWaiting.transform.localScale    = Vector3.one;
                panelWaiting.transform.localPosition = Vector3.zero;
                panelWaiting.gameObject.SetActive(false);
            });
        }
        if (panelMessageSytem == null)
        {
            LoadAssetBundle.LoadPrefab(Res.AS_PREFABS, Res.AS_PREFABS_MESSAGE_SYSTEM, (obj) => {
                panelMessageSytem = obj.GetComponent <PanelMessageSytem>();
                panelMessageSytem.transform.SetParent(parentUI);
                panelMessageSytem.transform.localScale    = Vector3.one;
                panelMessageSytem.transform.localPosition = Vector3.zero;
                panelMessageSytem.gameObject.SetActive(false);
            });
        }
        if (toast == null)
        {
            LoadAssetBundle.LoadPrefab(Res.AS_PREFABS, Res.AS_PREFABS_TOAST, (obj) => {
                toast = obj.GetComponent <Toast>();
                toast.transform.SetParent(parentUI);
                toast.transform.localScale    = Vector3.one;
                toast.transform.localPosition = Vector3.zero;
                toast.gameObject.SetActive(false);
            });
        }
    }
    public void SetInfo(int result)
    {
        this.result = result;

        for (int i = 0; i < img_dices.Length; i++)
        {
            LoadAssetBundle.LoadSprite(img_dices[i], BundleName.UI, i < result ? UIName.UI_XD_RED : UIName.UI_XD_WHITE);
        }
    }
Exemple #5
0
 public void SetCardWithId(int _id)
 {
     if (_id > 52 || _id < 0)
     {
         _id = 52;
     }
     ID = _id;
     LoadAssetBundle.LoadSprite(img_card, BundleName.CARDS, "bai" + cardPaint[_id]);
 }
Exemple #6
0
    public IEnumerator SetGameName(int gameId)
    {
        yield return(new WaitForEndOfFrame());

        //Debug.LogError("Game ID " + gameId);
        LoadAssetBundle.LoadSprite(logoImg, Res.AS_UI, Res.logoName[gameId], () => {
            logoImg.SetNativeSize();
        });
    }
 public void onDisConnect()
 {
     PopupAndLoadingScript.instance.HideLoading();
     PopupAndLoadingScript.instance.messageSytem.OnShow(ClientConfig.Language.GetText("reconect_disconnect"), delegate {
         NetworkUtil.GI().close();
         LoadAssetBundle.LoadScene(SceneName.SCENE_MAIN, SceneName.SCENE_MAIN);
     });
     Debug.Log("Mất kết nối!");
 }
Exemple #8
0
 private void showDatcuoc(long min, long max)
 {
     //gameControl.panelCuoc.onShow(min, max);
     LoadAssetBundle.LoadScene(Res.AS_SUBSCENES, Res.AS_SUBSCENES_CUOC, () => {
         PanelCuoc.instance.onShow(min, max);
     });
     //btn_bocuoc.gameObject.SetActive(false);
     //btn_cuoc.gameObject.SetActive(false);
     //showButtonCuoc(false);
 }
Exemple #9
0
 public void clickAvatar()
 {
     SoundManager.instance.startClickButtonAudio();
     LoadAssetBundle.LoadScene("sub_info_player", "subInfoPlayer", () =>
     {
         PanelInfoPlayer.instance.InfoMe();
     });
     //gameControl.panelInfoPlayer.infoMe();
     //gameControl.panelInfoPlayer.onShow();
 }
Exemple #10
0
 public void clickAvatar()
 {
     GameControl.instance.sound.startClickButtonAudio();
     //gameControl.panelInfoPlayer.infoMe();
     //gameControl.panelInfoPlayer.onShow();
     LoadAssetBundle.LoadScene(Res.AS_SUBSCENES, Res.AS_SUBSCENES_PLAYER_INFO, () => {
         gameControl.panelWaiting.onHide();
         PanelInfoPlayer.instance.infoMe();
     });
 }
Exemple #11
0
 public void clickButtonChat()
 {
     if (!BaseInfo.gI().isView)
     {
         // gameControl.panelChat.onShow();
         LoadAssetBundle.LoadScene(Res.AS_SUBSCENES, Res.AS_SUBSCENES_CHAT, () => {
             PanelChat.instance.onShow();
         });
     }
 }
Exemple #12
0
 private void LoadSprite(bool isOn, Image bg)
 {
     if (isOn)
     {
         LoadAssetBundle.LoadSprite(bg, "ui", "icon_on");
     }
     else
     {
         LoadAssetBundle.LoadSprite(bg, "ui", "icon_off");
     }
 }
Exemple #13
0
    public void InstanceItem(int rank, int idAvata, string playername, long money)
    {
        LoadAssetBundle.LoadPrefab(Res.AS_PREFABS, "ItemRank", (prefabAB) => {
            GameObject go = (GameObject)Instantiate(prefabAB);
            go.transform.SetParent(parentItem);
            go.transform.localScale = Vector3.one;
            go.GetComponent <ItemRanking>().SetData(rank, idAvata, playername, money);

            list_top.Add(go);
        });
    }
Exemple #14
0
    IEnumerator LoadSmile(List <Image> list)
    {
        yield return(new WaitForEndOfFrame());

        for (int i = 0; i < list.Count; i++)
        {
            yield return(new WaitForSeconds(0.1f));

            LoadAssetBundle.LoadSprite(list[i], BundleName.EMOTIONS, "a" + (i + 1));
        }
    }
Exemple #15
0
 public void OnMoneyFree(long money)
 {
     Debug.LogError("Nhan dc tien nhe: " + money);
     LoadAssetBundle.LoadScene(SceneName.SUB_GIFT_MONEY, SceneName.SUB_GIFT_MONEY, () => {
         ClientConfig.UserInfo.CASH_FREE += money;
         if (LobbyControl.instance != null)
         {
             LobbyControl.instance.SetMoney();
         }
     });
 }
 /// <summary>
 /// 加载(AB 包中)资源
 /// </summary>
 /// <param name="scenesName">场景名称</param>
 /// <param name="abName">AssetBundle 包名称</param>
 /// <param name="assetName">资源名称</param>
 /// <param name="isCache">是否使用缓存</param>
 /// <returns></returns>
 public UnityEngine.Object LoadAsset(string assetName, bool isCache)
 {
     Debug.Log(GetType() + "\t加载资源文件");
     if (_DicAllAB.ContainsKey(assetName))
     {
         LoadAssetBundle multObj = _DicAllAB[assetName];
         return(multObj.LoadAsset(assetName, isCache));
     }
     Debug.LogError(GetType() + "/LoadAsset()ab包  或者资源  assetName=" + assetName);
     return(null);
 }
    public override void OnInspectorGUI()
    {
        LoadAssetBundle Lab = (LoadAssetBundle)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Generate"))
        {
            Lab.Generate();
        }
    }
Exemple #18
0
    public IEnumerator load(string path)
    {
        WWW www = new WWW(path);

        while (!www.isDone)
        {
            yield return(www);
        }

        lab = new LoadAssetBundle(www.assetBundle);
    }
Exemple #19
0
    public override void setRank(int rank)
    {
        sp_typeCard.StopAllCoroutines();
        sp_typeCard.gameObject.transform.position = new Vector3(0, -25, 0);

        switch (rank)
        {
        case 0:
            if (pos == 0)
            {
                SoundManager.instance.startLostAudio();
            }
            break;

        case 1:
            LoadAssetBundle.LoadPrefab(Res.AS_PREFABS, "Win_Effect", (obj) => {
                objWinEffect = obj;
                objWinEffect.transform.SetParent(gameObject.transform);
                objWinEffect.transform.localPosition = Vector3.zero;
                //Debug.LogError("Load Win Effect 55");
            });
            if (pos == 0)
            {
                SoundManager.instance.startWinAudio();
            }
            break;

        case 2:
        case 3:
        case 4:
            if (pos == 0)
            {
                SoundManager.instance.startLostAudio();
            }
            break;

        case 5:
            LoadAssetBundle.LoadPrefab(Res.AS_PREFABS, "Win_Effect", (obj) => {
                objWinEffect = obj;
                objWinEffect.transform.SetParent(gameObject.transform);
                objWinEffect.transform.localPosition = Vector3.zero;
                //Debug.LogError("Load Win Effect 55");
            });
            if (pos == 0)
            {
                SoundManager.instance.startWinAudio();
            }
            break;

        default:
            break;
        }
        Invoke("setVisibleThang", 3f);
    }
 /// <summary>
 /// 释放资源。
 /// </summary>
 /// <param name="scenesName">资源名称</param>
 public void DisAssets(string assetName)
 {
     if (_DicAllAB.ContainsKey(assetName))
     {
         LoadAssetBundle multObj = _DicAllAB[assetName];
         multObj.Dispose();
     }
     else
     {
         Debug.LogError(GetType() + "/DisposeAllAssets()/找不到资源名称,无法释放资源,请检查!  assetName=" + assetName);
     }
 }
Exemple #21
0
 public void ClickLock()
 {
     isLock = !isLock;
     if (isLock)
     {
         LoadAssetBundle.LoadSprite(lockImg, "ui", "icon_lock");
     }
     else
     {
         LoadAssetBundle.LoadSprite(lockImg, "ui", "icon_unlock");
     }
 }
Exemple #22
0
    /// <summary>
    /// Awake function of GameManager. Checks if another instance of this GameObject exists and
    /// if not, initializes all required atributes and values of the GameManager, creating a new
    /// one.
    ///
    /// If the GameManager already exists, destroy this gameObject.
    /// </summary>
    private void Awake()
    {
        // If GameManager is not created and initialized...
        if (_instance == null)
        {
            // Set this GameManager as instance
            _instance = this;

            // Set this gameObject to not Destroy when changing between scenes
            DontDestroyOnLoad(gameObject);

            _gc = LoadingFiles.ReadGameConfig();

            // Store canvas' scaling reference resolution
            _scalingReferenceResolution = _cnv.GetComponent <CanvasScaler>().referenceResolution;

            // Initialize Scaling with cam values and scalingreference values
            _scalator = new Scaling(new Vector2(Screen.width, Screen.height), _scalingReferenceResolution, (int)_cam.orthographicSize);

            // Search all panels for later calculation
            ReloadPanels();

            // Load all AssetBundles
            _lab = new LoadAssetBundle();

            // Depending on OS system, load from a different path and using different techniques
#if !UNITY_EDITOR && UNITY_ANDROID
            _lab.LoadBundlesAndroid(Application.streamingAssetsPath + "/AssetBundles/");
#else
            _lab.LoadBundlesWindows(Application.streamingAssetsPath + "/AssetBundles/");
#endif

            // Initialize random value
            _rnd = new Random();

            // Load gameInfo previously generated, data driven information
            _gi = LoadingFiles.ReadGameInfo();

            // Set all values of this information
            SetGameInfo();

            // Get Player information and store it
            _currentPlayerData = LoadingFiles.ReadPlayerData(_maxDifficulty);

            // Set the time waiting for challenge info
            SetTimeForChallenge();
        }
        else if (_instance != this)
        {
            Destroy(gameObject);
        }
    }
Exemple #23
0
    public void BackToLogin()
    {
        SoundManager.instance.startClickButtonAudio();
        PopupAndLoadingScript.instance.popup.ShowPopupTwoButton("", ClientConfig.Language.GetText("lobby_quit"), () =>
        {
            //FB.LogOut();
            NetworkUtil.GI().close();
            bg_change_scene.gameObject.SetActive(true);
            LoadAssetBundle.LoadScene(Res.LOGIN_AB, Res.LOGIN_NAME);
        });

        //StartCoroutine(WaitToFade(1f));
    }
Exemple #24
0
 internal void OnBeGinXocDia_MoBat(int quando)
 {
     timeCountDown.SetTime(0);
     MoBat();
     SetEnableButton(false, false, false, false, false);
     Debug.LogError("so quan do:   " + quando);
     for (int i = 0; i < img_dices.Length; i++)
     {
         img_dices[i].gameObject.SetActive(true);
         LoadAssetBundle.LoadSprite(img_dices[i], BundleName.UI, i < quando ? UIName.UI_XD_RED : UIName.UI_XD_WHITE);
     }
     UpdateHistory(quando);
 }
    /// <summary>
    /// 清单文件
    /// </summary>
    /// <param name="dataName"></param>
    /// <param name="callBack"></param>
    /// <returns></returns>
    public IEnumerator LoadAssetBundlePack(LoadABDataCompleteHandle callBack)
    {
        //等待maniFest清单文件加载完成
        while (!LoadABManiFest.GetInstance()._isLoadManiFestFinshed)
        {
            yield return(null);
        }
        _currentManiFest = LoadABManiFest.GetInstance().GetABManiFest();
        if (_currentManiFest == null)
        {
            Debug.LogError(GetType() + "\t   _currentManiFest      为空   ");
            yield return(null);
        }
        string[] abName = LoadABManiFest.GetInstance().GetAllABName();


        for (int i = 0; i < abName.Length; i++)
        {
            string[] name = abName[i].Split('.');
            Debug.Log("ab包的名字:\t" + name[0]);
        }


        for (int i = 0; i < abName.Length; i++)
        {
            string[] name = abName[i].Split('.');
            if (!_DicAllAB.ContainsKey(name[0]))
            {
                Debug.Log("存储加载的 ab资源:\t" + name[0]);
                LoadAssetBundle loadAB = new LoadAssetBundle(name[0]);
                _DicAllAB.Add(name[0], loadAB);
            }
        }
        Debug.Log("一共存储了这么多个  ab包:\t" + _DicAllAB.Count);

        for (int i = 0; i < abName.Length; i++)
        {
            string[] name = abName[i].Split('.');
            Debug.Log(name[0]);
            if (_DicAllAB.ContainsKey(name[0]))
            {
                LoadAssetBundle loadAB = _DicAllAB[name[0]];
                yield return(loadAB.LoadAssetBundleIE());
            }
        }
        ///此时调用委托  全局只调用一次
        if (callBack != null)
        {
            callBack();
        }
    }
Exemple #26
0
    public void SetUI()
    {
        img_rank.gameObject.SetActive((item.Rank == 1 || item.Rank == 2 || item.Rank == 3));
        if (item.Rank == 1 || item.Rank == 2 || item.Rank == 3)
        {
            LoadAssetBundle.LoadSprite(img_rank, BundleName.UI, "rank_" + item.Rank);
        }

        txt_name.text  = item.Name;
        txt_money.text = MoneyHelper.FormatRelativelyWithoutUnit(item.Money);
        txt_rank.text  = item.Rank + "";

        LoadAssetBundle.LoadSprite(img_avata, BundleName.AVATAS, item.Avata_Id + "");
    }
Exemple #27
0
 private void LoadSceneGame(string scene_ab, string scene_name)
 {
     LoadAssetBundle.LoadScene(scene_ab, scene_name, () =>
     {
         for (int i = 0; i < SceneManager.GetSceneByName(scene_name).rootCount; i++)
         {
             if (SceneManager.GetSceneByName(scene_name).GetRootGameObjects()[i].name.Equals("Canvas"))
             {
                 SceneManager.GetSceneByName(scene_name).GetRootGameObjects()[i].transform.GetChild(0).gameObject.SetActive(false);
                 break;
             }
         }
     });
 }
Exemple #28
0
 // Use this for initialization
 void Start()
 {
     LoadAssetBundle.LoadPrefab(BundleName.PREFAPS, PrefabsName.PRE_ITEM_RANK, (objPre) => {
         for (int i = 0; i < GameControl.instance.ListRank.Count; i++)
         {
             GameObject obj = Instantiate(objPre);
             obj.transform.SetParent(tf_parent);
             obj.transform.localScale = Vector3.one;
             ItemRankUI it            = obj.GetComponent <ItemRankUI>();
             it.item = GameControl.instance.ListRank[i];
             it.SetUI();
         }
     });
 }
Exemple #29
0
 private void LoadLobby()
 {
     //bg_change_scene.gameObject.SetActive(true);
     LoadAssetBundle.LoadScene(Res.MAIN_AB, Res.MAIN_NAME);
     //for (int i = 0; i < objListRoom.transform.childCount; i++)
     //{
     //    objListRoom.transform.GetChild(i).transform.DOScale(0, 0.4f);
     //    yield return new WaitForSeconds(.1f);
     //    if (i == objListRoom.transform.childCount - 1)
     //    {
     //        LoadAssetBundle.LoadScene(Res.MAIN_AB, Res.MAIN_NAME);
     //    }
     //}
 }
Exemple #30
0
 public void clickButtnRutTien()
 {
     if (ClientConfig.UserInfo.CASH_FREE < GameConfig.BetMoney * 10)
     {
         PopupAndLoadingScript.instance.messageSytem.OnShow("Không đủ tiền để rút, bạn có muốn nạp thêm?");
     }
     else
     {
         //Show rut tien
         Debug.LogError("Show rut tien");
         LoadAssetBundle.LoadScene(SceneName.SUB_RUT_TIEN, SceneName.SUB_RUT_TIEN, () => {
         });
     }
 }
Exemple #31
0
 void SetImage(GameObject btn)
 {
     for (int i = 0; i < Res.EMOTION_COUNT; i++)
     {
         GameObject obj = Instantiate(btn) as GameObject;
         obj.transform.SetParent(parentSmile);
         obj.transform.localScale = Vector3.one;
         obj.name = "" + i;
         LoadAssetBundle.LoadSprite(obj.GetComponent <Button>().image, Res.AS_UI, "a" + (i + 1));
         obj.GetComponent <Button>().onClick.AddListener(delegate {
             sendSmile(obj);
         });
     }
 }
Exemple #32
0
    public void onMoveto(long money, int type)
    {
        soChip = money;
        if (money <= 0)
        {
            gameObject.SetActive(false);
        }
        else
        {
            gameObject.SetActive(true);
            string name;
            if (money > BaseInfo.gI().moneyTable * 20)
            {
                name = "chip44";
            }
            else if (money > BaseInfo.gI().moneyTable * 10)
            {
                name = "chip43";
            }
            else if (money > BaseInfo.gI().moneyTable * 5)
            {
                name = "chip42";
            }
            else if (money > BaseInfo.gI().moneyTable * 1)
            {
                name = "chip41";
            }
            else
            {
                name = "chip40";
            }

            LoadAssetBundle.LoadSprite(chip1, Res.AS_UI_ICON_CHIP, name);
            LoadAssetBundle.LoadSprite(chip2, Res.AS_UI_ICON_CHIP, name);
            LoadAssetBundle.LoadSprite(chip3, Res.AS_UI_ICON_CHIP, name);
            //chip1.sprite = GameControl.instance.getChipByName(name);
            //chip2.sprite = GameControl.instance.getChipByName(name);
            //chip3.sprite = GameControl.instance.getChipByName(name);

            if (type == 1)
            {
                StartCoroutine(Moveto());
            }
            else
            {
                StartCoroutine(Moveback());
            }
        }
    }