Пример #1
0
 void Init()
 {
     Root = Control("LevelTalk");
     WndObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(180, -180);
     vscrollBar = Control("Scrollbar Vertical").GetComponent <Scrollbar>();
     //soundPlay = gameObject.AddComponent<AudioSource>();
 }
Пример #2
0
    private void SetWndStyleExt()
    {
        switch (mWndStyleExt)
        {
        case StyleExt.Alpha:
        {
            if (null == WndObject.GetComponent <TweenAlpha>())
            {
                TweenAlpha Ta = WndObject.AddComponent <TweenAlpha>();
                Ta.to    = 0.0f;
                Ta.delay = 2.0f;
            }
            if (null == WndObject.GetComponent <AutoClose>())
            {
                WndObject.AddComponent <AutoClose>();
            }
        }
            ChangeWndStyleExt();
            break;

        case StyleExt.Toast:
        {
            if (null == WndObject.GetComponent <AutoClose>())
            {
                WndObject.AddComponent <AutoClose>();
            }
        }
            ChangeWndStyleExt();
            break;

        default:
            break;
        }
    }
    public void Add(int playerId, string message)
    {
        if (Root.transform.childCount >= 20)
        {
            GameObject.Destroy(Root.transform.GetChild(0).gameObject);
        }
        GameObject obj = new GameObject();

        obj.name = (Root.transform.childCount + 1).ToString();
        Text txt = obj.AddComponent <Text>();

        txt.text = string.Format("{0}:{1}", Main.Ins.NetWorkBattle.GetNetPlayerName(playerId), message);
        //00AAFFFF
        txt.font          = Main.Ins.TextFont;
        txt.fontSize      = 32;
        txt.alignment     = TextAnchor.MiddleLeft;
        txt.raycastTarget = false;
        txt.color         = new Color(1.0f, 1.0f, 1.0f, 1f);
        obj.transform.SetParent(Root.transform);
        obj.transform.localScale    = Vector3.one;
        obj.transform.localPosition = Vector3.zero;
        obj.transform.localRotation = Quaternion.identity;
        if (hide != null)
        {
            hide.Kill(false);
        }
        WndObject.GetComponent <CanvasGroup>().alpha = 1.0f;
        hide = DOTween.Sequence();
        hide.AppendInterval(8.0f);
        hide.Append(WndObject.GetComponent <CanvasGroup>().DOFade(0, 5.0f));
        hide.Play();
        vscrollBar.value = 0;
    }
    public void Add(int playerId, byte[] audio)
    {
        if (Root.transform.childCount >= 20)
        {
            if (audioCache.ContainsKey(0))
            {
                audioCache.Remove(0);
            }
            GameObject.Destroy(Root.transform.GetChild(0).gameObject);
        }
        GameObject obj = GameObject.Instantiate(Resources.Load("AudioMsg")) as GameObject;

        obj.name = (Root.transform.childCount + 1).ToString();
        obj.transform.GetChild(0).GetComponent <Text>().text = Main.Ins.NetWorkBattle.GetNetPlayerName(playerId) + "发来了一条语音信息";
        obj.transform.GetChild(1).GetComponent <UIFunCtrl>().SetEvent((int audioIdx) => { OnPlayAudio(audioIdx); }, Root.transform.childCount);
        obj.transform.SetParent(Root.transform);
        obj.transform.localScale    = Vector3.one;
        obj.transform.localPosition = Vector3.zero;
        obj.transform.localRotation = Quaternion.identity;
        if (hide != null)
        {
            hide.Kill(false);
        }
        WndObject.GetComponent <CanvasGroup>().alpha = 1.0f;
        hide = DOTween.Sequence();
        hide.AppendInterval(8.0f);
        hide.Append(WndObject.GetComponent <CanvasGroup>().DOFade(0, 5.0f));
        hide.Play();
        audioCache.Add(Root.transform.childCount - 1, audio);
        vscrollBar.value = 0;
    }
Пример #5
0
    void Init()
    {
        RectTransform rectTran = WndObject.GetComponent <RectTransform>();

        if (rectTran != null)
        {
            rectTran.anchoredPosition = new Vector2((1920f - rectTran.sizeDelta.x) / 2.0f, -(1080f - rectTran.sizeDelta.y) / 2.0f);
        }
        GameObject      obj       = Global.ldaControlX("3DParent", WndObject);
        GameObject      objPlayer = GameObject.Instantiate(Resources.Load("3DUIPlayer")) as GameObject;
        MeteorUnitDebug d         = objPlayer.GetComponent <MeteorUnitDebug>();

        objPlayer.transform.position   = Vector3.zero;
        objPlayer.transform.rotation   = Quaternion.identity;
        objPlayer.transform.localScale = Vector3.one;
        d.gameObject.layer             = obj.gameObject.layer;
        d.Init(0);
        WeaponBase weaponProperty = WeaponMng.Instance.GetItem(MeteorManager.Instance.LocalPlayer.weaponLoader.GetCurrentWeapon().Info().UnitId);

        d.weaponLoader.StrWeaponR = weaponProperty.WeaponR;
        d.weaponLoader.StrWeaponL = weaponProperty.WeaponL;
        d.weaponLoader.EquipWeapon();
        d.transform.SetParent(obj.transform);
        d.transform.localScale    = 8 * Vector3.one;
        d.transform.localPosition = new Vector3(0, 0, -45);
        d.transform.localRotation = Quaternion.identity;
        Global.ldaControlX("Close Button", WndObject).GetComponent <Button>().onClick.AddListener(Close);

        SetStat("Stat Label 1", MeteorManager.Instance.LocalPlayer.Attr.hpCur + "/" + MeteorManager.Instance.LocalPlayer.Attr.HpMax);
        SetStat("Stat Label 2", MeteorManager.Instance.LocalPlayer.AngryValue.ToString());
        SetStat("Stat Label 3", MeteorManager.Instance.LocalPlayer.CalcDamage().ToString());
        SetStat("Stat Label 4", MeteorManager.Instance.LocalPlayer.CalcDef().ToString());
        SetStat("Stat Label 5", MeteorManager.Instance.LocalPlayer.Speed.ToString());
        SetStat("Stat Label 6", string.Format("{0:f2}", MeteorManager.Instance.LocalPlayer.Speed / 1000.0f));

        //处理背包的点击
        UIItemSlot [] slots = Global.ldaControlX("Slots Grid", WndObject).GetComponentsInChildren <UIItemSlot>();
        for (int i = 0; i < slots.Length; i++)
        {
            slots[i].onClick.AddListener(OnClickItem);
        }
    }
Пример #6
0
    public void Close()
    {
        float delay = 0;

        if (WndObject != null)
        {
            var peekaboo = WndObject.GetComponent <UiPeeKaBoo>() ?? WndObject.GetComponentInChildren <UiPeeKaBoo>();

            if (peekaboo != null)
            {
                if (peekaboo.Tweens.Length > 0)
                {
                    foreach (var t in peekaboo.Tweens)
                    {
                        foreach (var tw in t.GetComponents <UITweener>())
                        {
                            if (tw.delay + tw.duration > delay)
                            {
                                delay = tw.delay + tw.duration;
                            }

                            tw.PlayReverse();
                        }
                    }
                }
                else
                {
                    foreach (var tw in WndObject.GetComponents <UITweener>())
                    {
                        if (tw.delay + tw.duration > delay)
                        {
                            delay = tw.delay + tw.duration;
                        }

                        tw.PlayReverse();
                    }
                }
            }
        }

        MainScript.Instance.StartCoroutine(CloseInternal(delay));
    }
Пример #7
0
    public void Add(int playerId, string message)
    {
        GameObject obj = new GameObject();

        obj.name = (Root.transform.childCount + 1).ToString();
        Text   txt = obj.AddComponent <Text>();
        string msg = string.Format("{0}[{1}]:{2}", U3D.GetNetPlayerName(playerId), playerId, message);

        txt.text = msg;
        msgHistory.Add(msg);
        //00AAFFFF
        txt.font          = Main.Ins.TextFont;
        txt.fontSize      = 32;
        txt.alignment     = TextAnchor.MiddleLeft;
        txt.raycastTarget = false;
        txt.color         = new Color(1.0f, 1.0f, 1.0f, 1f);
        obj.transform.SetParent(Root.transform);
        obj.transform.localScale    = Vector3.one;
        obj.transform.localPosition = Vector3.zero;
        obj.transform.localRotation = Quaternion.identity;
        WndObject.GetComponent <CanvasGroup>().alpha = 1.0f;
        vscrollBar.value = 0;
        StartCheck();
    }
Пример #8
0
    private IEnumerator OpenAsyc(OnOpenCallBack callBack)
    {
        if (mWndObject)
        {
            GameObject.Destroy(mWndObject);
        }

        if (!WindowList.ActiveWindowList.ContainsKey(PrefabName))
        {
            WindowList.ActiveWindowList.Add(PrefabName, this);
            WindowList.ActiveWindowTypeList.Add(PrefabName, GetType());
        }


        var req = Resources.LoadAsync <GameObject>(PrefabName);

        yield return(req);

        var scale    = (req.asset as GameObject).transform.localScale;
        var position = (req.asset as GameObject).transform.localPosition;

        mWndObject = GameObject.Instantiate(req.asset) as GameObject;

        if (mWndObject == null)
        {
            Debug.LogWarning("OpenAsyc win object is null");
            yield break;
        }

        WindowHelper    = mWndObject.AddComponent <WindowHelper>();
        mWndObject.name = PrefabName;
        mWndObject.SetActive(true);
        IsLoaded = true;

        mRootUI = GameObject.Find("WindowsRoot/Camera");

        if (FullWindows.Contains(PrefabName))
        {
            mCullingMask            = Camera.main.cullingMask;
            Camera.main.cullingMask = 0;

            //var original = Resources.Load("BackgroundExtWnd") as GameObject;
            var original = Resources.Load("BackgroundExtWndTransparent") as GameObject;
            mExtBackground = NGUITools.AddChild(mRootUI, original);
        }

        WndObject.transform.parent        = mRootUI.transform;
        WndObject.transform.localPosition = position;
        WndObject.transform.localScale    = scale;

        BindUi();

        if (AUi != null)
        {
            foreach (var aUiClass in AUi)
            {
                if (aUiClass != null)
                {
                    aUiClass.Bind(WndObject, this);
                }
            }
        }

        OnOpen();

        var e = OnAsyncOpen().GetEnumerator();

        while (e.MoveNext())
        {
            yield return(e.Current);
        }

        OnStart();

        var peekaboo = WndObject.GetComponent <UiPeeKaBoo>() ?? WndObject.GetComponentInChildren <UiPeeKaBoo>();

        if (peekaboo != null)
        {
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());

            if (peekaboo.Tweens.Length > 0)
            {
                foreach (var t in peekaboo.Tweens)
                {
                    foreach (var tw in t.GetComponents <UITweener>())
                    {
                        tw.PlayForward();
                    }
                }
            }
            else
            {
                foreach (var tw in WndObject.GetComponents <UITweener>())
                {
                    tw.PlayForward();
                }
            }
        }

        if (callBack != null)
        {
            callBack();
        }
    }
Пример #9
0
 protected override bool OnOpen()
 {
     WinStyle = WindowStyle.WS_Ext;
     loadbar  = WndObject.GetComponent <UILoadingBar>();
     return(base.OnOpen());
 }
 void Init()
 {
     Root = Control("LevelTalk");
     WndObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(145, 400);
     vscrollBar = Control("Scrollbar Vertical").GetComponent <Scrollbar>();
 }
Пример #11
0
    public void Open()
    {
        //Debug.Log("Open Window:"+PrefabName);
        if (mWndObject)
        {
            Debug.LogError("Window:" + PrefabName + "The window already opened!!!!");
            WindowMng.RemoveWindow(mWndObject, this);
            GameObject.Destroy(mWndObject);//这句话会导致一个界面上的成员变量没清理
            if (WindowStyle.WS_Ext <= mWindowStyle)
            {
                GameObject.Destroy(mExtBackground);
            }
            //return;
        }
#if UNITY_2017 || UNITY_5_5
        mRootUI = GameObject.Find("Canvas");
        if (mRootUI != null)
        {
            if (!CanvasMode())
            {
                mWndObject = GameObject.Instantiate(Resources.Load <GameObject>(PrefabName), Vector3.zero, Quaternion.identity, mRootUI.transform) as GameObject;
            }
            else
            {
                mWndObject = GameObject.Instantiate(Resources.Load <GameObject>(PrefabName));
            }
        }
        else
        {
            mWndObject = GameObject.Instantiate(Resources.Load <GameObject>(PrefabName));
        }
        if (mRootUI != null)
        {
            if (!CanvasMode())
            {
                WndObject.transform.SetParent(mRootUI.transform);
                WndObject.transform.localScale    = Vector3.one;
                WndObject.transform.localRotation = Quaternion.identity;
            }
            RectTransform rectTran = WndObject.GetComponent <RectTransform>();
            if (rectTran != null && rectTran.anchorMin == Vector2.zero && rectTran.anchorMax == Vector2.one)
            {
                if (rectTran.rect.width == 0 && rectTran.rect.height == 0)
                {
                    rectTran.sizeDelta = new Vector2(0, 0);
                }
            }
            if (rectTran != null)
            {
                rectTran.anchoredPosition3D = new Vector3(0, 0, 0);
            }
        }
        else
        {
            //mRootUI = GameObject.Find("Anchor");
            //if (mRootUI != null)
            //    WndObject.transform.SetParent(mRootUI.transform);
        }
#else
        mRootUI = GameObject.Find("Anchor");
        WndObject.transform.parent = mRootUI.transform;
#endif
        WndObject.transform.localScale = Vector3.one;
        //WndObject.transform.localPosition = new Vector3(GetX(), GetY(), GetZ());
        WindowMng.AddWindow(mWndObject, this);

        OnOpen();

        //attention Order
        //mCamera = GameObject.Find("Camera-CloseUp");
        //if (mCamera != null)
        //    mCullingMask = mCamera.GetComponent<Camera>().cullingMask;

        //阻挡UI之后其他的UI响应
        if (mWindowStyle >= WindowStyle.WS_Ext)
        {
            mExtBackground = GameObject.Instantiate(Resources.Load("BackgroundExtWnd")) as GameObject;
            mExtBackground.transform.SetParent(WndObject.transform);
            mExtBackground.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
            mExtBackground.transform.localScale    = Vector3.one;
            mExtBackground.transform.localRotation = Quaternion.identity;
            mExtBackground.transform.SetAsFirstSibling();
        }

        //if (WindowStyle.WS_CullingMask <= mWindowStyle)
        //{
        //    Debug.Log("LayerMask NGUI : = " + LayerMask.NameToLayer("NGUI"));
        //    //attention Order
        //    if (mCamera != null)
        //        mCamera.GetComponent<Camera>().cullingMask = LayerMask.NameToLayer("NGUI");
        //}
        //AutoAdaptGUI();
    }