protected override void InitComponents()
    {
        sinstance = this;

        tipcell = FindWidget <Text>("tipcell");
        tipcell.gameObject.SetActive(false);
    }
Beispiel #2
0
 void OnShowNext(UICommonTips tips, GameObject go)
 {
     if (mCacheText.Count > 0)
     {
         ShowTips();
     }
 }
Beispiel #3
0
        void showFinish(UICommonTips tips, GameObject go)
        {
            tips.mLabel.text = "";
            tips.gameObject.SetActive(false);
            tips.transform.localPosition = Vector3.zero;
            tips.TipsAnimation.enabled   = true;

            GameObject parentObject = tips.gameObject.transform.parent.gameObject;

            parentObject.transform.localPosition = Vector3.zero;

            bool needToDispear = false;

            for (int i = (mDisplayingTips.Count - 1); i >= 0; --i)
            {
                UICommonTips commonTips = mDisplayingTips[i];
                if (needToDispear == true)
                {
                    HideTips(commonTips);
                }
                if (commonTips == tips)
                {
                    needToDispear = true;
                }
            }

            mDisplayingTips.Remove(tips);
            mDisplayingTipTransforms.Remove(tips.transform);
        }
Beispiel #4
0
 void DestroyFinish(UICommonTips tips, GameObject go)
 {
     tips.mLabel.text = "";
     tips.gameObject.SetActive(false);
     mIsLoad = false;
     mDisplayTips.Clear();
     mCacheText.Clear();
 }
 public static void AddTip(string content)
 {
     if (sinstance == null)
     {
         LoadUI <UICommonTips>(instance => { sinstance = instance; sinstance.DoAddTip(content); });
     }
     else
     {
         sinstance.DoAddTip(content);
     }
 }
Beispiel #6
0
    private void OnCreateAvatarCb(UEventBase obj)
    {
        var res = obj as EventCreateAvatar;

        UICommonTips.AddTip($"Create avatar {res.eResult}");
        if (res.eResult == PktCreateAvatarResult.EResult.Success)
        {
            OnUnloadThis();
            LoadAnotherUI <UIMinerMain>();
        }
    }
    private void OnCreateAvatarCb(UEventBase obj)
    {
        var res = obj as EventCreateAvatar;

        UICommonTips.AddTip($"Create avatar {res.eResult}");
        if (res.eResult == PktCreateAvatarResult.EResult.Success)
        {
            OnUnloadThis();
            AClientApis.OnGetSdata();
        }
    }
Beispiel #8
0
        /// <summary>
        /// 加载资源并进行实例化
        /// </summary>
        /// <returns></returns>
        IEnumerator InitLoad()
        {
            // 加载UICommonTips的资源
            SGameEngine.PrefabResource pr = new SGameEngine.PrefabResource();
            yield return(ui.ugui.UIManager.Instance.MainCtrl.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_prefab("Assets/Res/UI/Widget/Preset/UICommonTips.prefab", pr, false)));

            GameObject go = pr.obj_ as GameObject;

            GameObject.DontDestroyOnLoad(go);

            // 设置父节点
            go.transform.SetParent(UIMainCtrl.MainCam.transform);
            var canvas = go.GetComponent <Canvas>();

            if (canvas != null)
            {
                canvas.worldCamera   = UIMainCtrl.MainCam;
                canvas.planeDistance = 0;
                canvas.sortingOrder  = 10000 - 1;
            }

            // 实例化多个Tips的gameobject
            Transform  tips_trans        = go.transform.Find("TipsParent");
            Transform  tips_parent_trans = tips_trans.parent;
            GameObject tips_game_object  = tips_trans.gameObject;

            tips_game_object.SetActive(false);
            for (int i = 0; i < mTipsObjCount; i++)
            {
                GameObject parentObj = GameObject.Instantiate(tips_game_object) as GameObject;
                GameObject obj       = parentObj.transform.Find("Tips").gameObject;
                GameObject.DontDestroyOnLoad(parentObj);

                parentObj.name = "TipsParent";
                obj.name       = "Tips";
                parentObj.transform.SetParent(tips_parent_trans);
                parentObj.transform.localPosition = Vector3.one;
                parentObj.transform.localScale    = Vector3.one;

                Transform     localTrans = obj.transform;
                RectTransform rect       = localTrans.GetComponent <RectTransform>();
                rect.sizeDelta        = new Vector2(60, mTipsHeight);
                rect.anchoredPosition = Vector3.zero;
                UICommonTips commonTips = localTrans.gameObject.AddComponent <UICommonTips>();
                InitCallBack(commonTips);
                commonTips.Check();
                obj.SetActive(false);
                mDisplayTips.Add(commonTips);
            }

            mIsLoad = true;
        }
    public static void AddTip(string content)
    {
        if (sinstance == null)
        {
            sinstance = LoadAnotherUI <UICommonTips>();
        }
        if (sinstance == null)
        {
            return;
        }

        sinstance.DoAddTip(content);
    }
Beispiel #10
0
        void HideTips(UICommonTips tips)
        {
            xc.ui.ugui.TweenAlpha tweenAlpha = xc.ui.ugui.TweenAlpha.Begin(tips.gameObject, 0.1f, 0f);
            tweenAlpha.onFinished = (t) =>
            {
                UnityEngine.Object.Destroy(t);

                t.gameObject.SetActive(false);
                t.gameObject.transform.parent.gameObject.SetActive(false);
                tips.mLabel.text = "";
                tips.onFinish(tips, tips.gameObject);
                tips.IsPlayEnd = true;
            };
        }
    private void OnLoginCb(UEventBase obj)
    {
        btnLogin.enabled = true;
        var cb = obj as EventLogin;

        if (cb.bSuccess)
        {
            UICommonTips.AddTip($"登录成功,正在进入游戏世界!");
            CachedUsername = inputUsername.text;
        }
        else
        {
            UICommonTips.AddTip($"登录失败!");
        }
    }
Beispiel #12
0
    protected override void InitComponents()
    {
        mycard = FindWidget <RawImage>("mycard");
        mycard.gameObject.SetActive(false);
        var btn = mycard.gameObject.AddComponent <Button>();

        btn.onClick.AddListener(() =>
        {
            if (whosTurn != UILogin.CachedUsername)
            {
                UICommonTips.AddTip("还没轮到你出牌。");
                return;
            }
            mycard.color = Color.grey;
            WebSocketConnector.Instance.OnRemoteCall("roomOp", "");
        });
        othercard = FindWidget <RawImage>("othercard");
        othercard.gameObject.SetActive(false);
        var bgpath = new string[] { "Images/Pai/bg1", "Images/Pai/bg2" };

        UHotAssetBundleLoader.Instance.OnDownloadResources(() =>
        {
            mycard.texture    = UHotAssetBundleLoader.Instance.OnLoadAsset <Texture2D>(bgpath[random.Next(bgpath.Length)]);
            othercard.texture = UHotAssetBundleLoader.Instance.OnLoadAsset <Texture2D>(bgpath[random.Next(bgpath.Length)]);
        }, bgpath);

        textMyCardCount      = FindWidget <Text>("textMyCardCount");
        textMyCardCount.text = "0";

        textMyAvatarname      = FindWidget <Text>("textMyAvatarname");
        textMyAvatarname.text = URemoteData.AvatarName;

        textMyLevel = FindWidget <Text>("textMyLevel");
        ShowLevel();

        textOtherCardCount      = FindWidget <Text>("textOtherCardCount");
        textOtherCardCount.text = "0";

        textOtherLevel      = FindWidget <Text>("textOtherLevel");
        textOtherAvatarname = FindWidget <Text>("textOtherAvatarname");

        RegisterReturnButton();

        btnJoinRoom = FindWidget <Button>("btnJoinRoom");
        btnJoinRoom.onClick.AddListener(() =>
        {
            WebSocketConnector.Instance.OnRemoteCall("joinRoom", "老牛赶大车");
        });

        cardcell = FindWidget <Transform>("cardcell");
        cardcell.gameObject.SetActive(false);

        otherinfo = FindWidget <Transform>("otherinfo");
        otherinfo.gameObject.SetActive(false);
        URemoteData.ListeningParam(InfoNameDefs.AvatarLevel, ShowLevel);

        UICommonWait.Show();
        WebSocketConnector.Instance.OnInit(Utils.WebSocketURL + UILogin.CachedUsernameAndTokenArguments, evt =>
        {
            UICommonWait.Hide();
        }, msgEvt =>
        {
        }, errEvt =>
        {
        }, closeEvt =>
        {
        });

        WebSocketConnector.Instance.OnRegisterResponse("enter", OnJoinRoomCB);
        WebSocketConnector.Instance.OnRegisterResponse("cardsync", OnCardsSync);
        WebSocketConnector.Instance.OnRegisterResponse("result", OnResult);
        WebSocketConnector.Instance.OnRegisterResponse("dismissed", OnDismissed);
    }
 private void OnLoginFailedCb(UEventBase obj)
 {
     btnLogin.enabled = true;
     UICommonTips.AddTip($"登录失败!");
 }
Beispiel #14
0
 private void InitCallBack(UICommonTips commonTips)
 {
     commonTips.onFinish = showFinish;
     //commonTips.onNext = OnShowNext;
     commonTips.onDestroy = DestroyFinish;
 }