Ejemplo n.º 1
0
        //公用动画播放函数:找到gameobject,初始化系数。
        public void UIaminition(string data)
        {
            return;

            var mytTrigger = gameObject.GetComponent <MainButtonAnimeTrigger>();

            mainScreenButton = gameObject.GetComponent <MainScreenButtonFrame>();
            Transform root;
            var       objTransform = gameObject.transform;

            for (int i = 0, imax = objTransform.childCount; i < imax; ++i)
            {
                root = objTransform.GetChild(i);
                var rootTrans = root.transform;
                if (rootTrans.Find(data) != null)
                {
                    gameObj = rootTrans.Find(data).gameObject;
                    if (gameObj)
                    {
                        objTrans = gameObj.transform;
                    }
                }
            }
            if (gameObj != null)
            {
                switch (objTrans.parent.name)
                {
                case "C1":
                    if (mytTrigger.MainBtn[0].activeSelf == false)
                    {
                        if (mainScreenButton.BtnList[0].gameObject == mytTrigger.MainBtn[0])
                        {
                            isFlying    = true;
                            curPosition =
                                transform.Find("C").Find(mainScreenButton.BtnList[0].gameObject.name).localPosition +
                                new Vector3(MainBtnOffset, 0f, 0f);

                            mainScreenButton.BtnList.RemoveAt(0);
                            mainScreenButton.BtnList.Insert(0, gameObj.GetComponent <UIButton>());
                        }
                        else
                        {
                            mainScreenButton.BtnList[0].gameObject.SetActive(false);
                            mainScreenButton.BtnList[0].gameObject.transform.parent = objTrans.parent;
                            if (1 == thePos && 0 == objTrans.name.CompareTo("BtnSkill"))
                            {
                                thePos = 0;         //暂时先临时解决
                            }
                            mainScreenButton.BtnList1.Insert(thePos, mainScreenButton.BtnList[0].gameObject);
                            mainScreenButton.BtnList[0] = mytTrigger.MainBtn[0].GetComponent <UIButton>();
                            mainScreenButton.BtnList[0].gameObject.SetActive(true);
                            if (mainScreenButton.mNowLook == 0)
                            {
                                break;
                            }
                            mainScreenButton.OnClickType1();
                        }
                        break;
                    }
                    if (mainScreenButton.mNowLook == 0)
                    {
                        break;
                    }
                    mainScreenButton.OnClickType1();
                    break;

                case "C2":
                    if (mytTrigger.MainBtn[1].activeSelf == false)
                    {
                        if (mainScreenButton.BtnList[1].gameObject == mytTrigger.MainBtn[1])
                        {
                            isFlying    = true;
                            curPosition =
                                transform.Find("C").Find(mainScreenButton.BtnList[1].gameObject.name).localPosition +
                                new Vector3(MainBtnOffset, 0f, 0f);

                            mainScreenButton.BtnList.RemoveAt(1);
                            mainScreenButton.BtnList.Insert(1, gameObj.GetComponent <UIButton>());
                        }
                        else
                        {
                            mainScreenButton.BtnList[1].gameObject.SetActive(false);
                            mainScreenButton.BtnList[1].gameObject.transform.parent = objTrans.parent;
                            mainScreenButton.BtnList1.Insert(thePos, mainScreenButton.BtnList[1].gameObject);
                            mainScreenButton.BtnList[1] = mytTrigger.MainBtn[1].GetComponent <UIButton>();
                            mainScreenButton.BtnList[1].gameObject.SetActive(true);
                            if (mainScreenButton.mNowLook == 1)
                            {
                                break;
                            }
                            mainScreenButton.OnClickType2();
                        }
                        break;
                    }
                    if (mainScreenButton.mNowLook == 1)
                    {
                        break;
                    }
                    mainScreenButton.OnClickType2();
                    break;

                case "C3":
                    if (mytTrigger.MainBtn[2].activeSelf == false)
                    {
                        if (mainScreenButton.BtnList[2].gameObject == mytTrigger.MainBtn[2])
                        {
                            isFlying    = true;
                            curPosition =
                                transform.Find("C").Find(mainScreenButton.BtnList[2].gameObject.name).localPosition +
                                new Vector3(MainBtnOffset, 0f, 0f);

                            mainScreenButton.BtnList.RemoveAt(2);
                            mainScreenButton.BtnList.Insert(2, gameObj.GetComponent <UIButton>());
                        }
                        else
                        {
                            mainScreenButton.BtnList[2].gameObject.SetActive(false);
                            mainScreenButton.BtnList[2].gameObject.transform.parent = objTrans.parent;
                            mainScreenButton.BtnList1.Insert(thePos, mainScreenButton.BtnList[2].gameObject);
                            mainScreenButton.BtnList[2] = mytTrigger.MainBtn[2].GetComponent <UIButton>();
                            mainScreenButton.BtnList[2].gameObject.SetActive(true);
                            if (mainScreenButton.mNowLook == 2)
                            {
                                break;
                            }
                            mainScreenButton.OnClickType3();
                        }
                        break;
                    }
                    if (mainScreenButton.mNowLook == 2)
                    {
                        break;
                    }
                    mainScreenButton.OnClickType3();
                    break;

                case "C4":
                    if (mytTrigger.MainBtn[3].activeSelf == false)
                    {
                        if (mainScreenButton.BtnList[3].gameObject == mytTrigger.MainBtn[3])
                        {
                            isFlying    = true;
                            curPosition =
                                transform.Find("C").Find(mainScreenButton.BtnList[3].gameObject.name).localPosition +
                                new Vector3(MainBtnOffset, 0f, 0f);
                            mainScreenButton.BtnList.RemoveAt(3);
                            mainScreenButton.BtnList.Insert(3, gameObj.GetComponent <UIButton>());
                        }
                        else
                        {
                            mainScreenButton.BtnList[3].gameObject.SetActive(false);
                            mainScreenButton.BtnList[3].gameObject.transform.parent = objTrans.parent;
                            mainScreenButton.BtnList1.Insert(thePos, mainScreenButton.BtnList[3].gameObject);
                            mainScreenButton.BtnList[3] = mytTrigger.MainBtn[3].GetComponent <UIButton>();
                            mainScreenButton.BtnList[3].gameObject.SetActive(true);
                            if (mainScreenButton.mNowLook == 3)
                            {
                                break;
                            }
                            mainScreenButton.OnClickType4();
                        }
                        break;
                    }
                    if (mainScreenButton.mNowLook == 3)
                    {
                        break;
                    }
                    mainScreenButton.OnClickType4();
                    break;

                default:
                    return;
                }
                inAnim          = true;
                thePos          = mytTrigger.FindBtnByname(data);
                isShining       = true;
                shiningContinue = DateTime.Now.AddSeconds(ShineDelayTime);
                gameObj.SetActive(true);
                objTrans.position = Vector3.zero;
                startPos          = objTrans.localPosition;
                gameObj.gameObject.SetActive(true);
                theName = objTrans.parent.name;
                var notice = objTrans.FindChild("NoticeStatus");
                if (notice != null)
                {
                    isActive = notice.gameObject.activeSelf;
                    notice.gameObject.SetActive(false);
                }
            }
        }
Ejemplo n.º 2
0
        private void Update()
        {
        #if !UNITY_EDITOR
            try
            {
        #endif

            if (inAnim)
            {
                if (isShining)
                {
                    if (theAnim == null)
                    {
                        if (UiAnim != null)
                        {
                            theAnim = Instantiate(UiAnim, Vector3.zero, Quaternion.identity) as GameObject;
                            if (theAnim != null)
                            {
                                var myAnimTrans = theAnim.transform;
                                myAnimTrans.parent     = gameObj.gameObject.transform;
                                myAnimTrans.localScale = new Vector3(1f, 1f, 1f);
                                var TiShiAnNiu = myAnimTrans.FindChild("TiShiAnNiu");
                                TiShiAnNiu.GetComponent <UISprite>().depth = 100;
                            }
                        }
                    }
                    if (DateTime.Now > shiningContinue)
                    {
                        if (theAnim != null)
                        {
                            Destroy(theAnim);
                        }
                        Transform childTransform;
                        int       count;
                        if (isFlying)
                        {
                            ischange = true;
                            if (accuFly <= FlyTick)
                            {
                                objTrans.localPosition =
                                    Vector3.Lerp
                                    (
                                        startPos,
                                        curPosition,
                                        accuFly / FlyTick
                                    );
                                accuFly++;
                            }
                            else
                            {
                                objTrans.parent =
                                    gameObject.GetComponent <MainButtonAnimeTrigger>().MainBtn[0].transform.parent;
                                switch (theName)
                                {
                                case "C1":

                                    mainScreenButton.OnClickType1();
                                    break;

                                case "C2":

                                    mainScreenButton.OnClickType2();
                                    break;

                                case "C3":

                                    mainScreenButton.OnClickType3();
                                    break;

                                case "C4":

                                    mainScreenButton.OnClickType4();
                                    break;

                                default:
                                    return;
                                }
                                isShining = false;
                            }
                        }
                        else
                        {
                            for (var i = 0; i < thePos; i++)
                            {
                                switch (objTrans.parent.name)
                                {
                                case "C1":
                                    childTransform = mainScreenButton.BtnList1[i].transform;
                                    break;

                                case "C2":
                                    childTransform = mainScreenButton.BtnList2[i].transform;
                                    break;

                                case "C3":
                                    childTransform = mainScreenButton.BtnList3[i].transform;
                                    break;

                                case "C4":
                                    childTransform = mainScreenButton.BtnList4[i].transform;
                                    break;

                                default:
                                    return;
                                }
                                if (accumulateHit < 10)
                                {
                                    childTransform.localPosition = new Vector3(childTransform.localPosition.x - 8f, 0f, 0f);
                                }
                            }
                            accumulateHit++;
                            switch (objTrans.parent.name)
                            {
                            case "C1":
                                count = mainScreenButton.BtnList1.Count;
                                break;

                            case "C2":
                                count = mainScreenButton.BtnList2.Count;
                                break;

                            case "C3":
                                count = mainScreenButton.BtnList3.Count;
                                break;

                            case "C4":
                                count = mainScreenButton.BtnList4.Count;
                                break;

                            default:
                                return;
                            }
                            if (accuFly <= FlyTick)
                            {
                                objTrans.localPosition =
                                    Vector3.Lerp
                                    (
                                        startPos,
                                        new Vector3(
                                            objTrans.parent.position.x -
                                            (count - thePos + 1) * BtnOffset, 0f, 0f),
                                        accuFly / FlyTick
                                    );
                                accuFly++;
                            }
                            else
                            {
                                isShining = false;
                            }
                        }
                    }
                }

                if (isShining == false)
                {
                    if (!isFlying)
                    {
                        switch (objTrans.parent.name)
                        {
                        case "C1":
                            mainScreenButton.BtnList1.Insert(thePos, gameObj);

                            break;

                        case "C2":
                            mainScreenButton.BtnList2.Insert(thePos, gameObj);

                            break;

                        case "C3":
                            mainScreenButton.BtnList3.Insert(thePos, gameObj);

                            break;

                        case "C4":
                            mainScreenButton.BtnList4.Insert(thePos, gameObj);

                            break;

                        default:
                            return;
                        }
                    }

                    isFlying      = false;
                    accuFly       = 0;
                    accumulateHit = 0;
                    inAnim        = false;
                    ischange      = false;
                    if (null != theCallback)
                    {
                        theCallback();
                        theCallback = null;
                    }

                    var notice = objTrans.FindChild("NoticeStatus");
                    if (notice != null)
                    {
                        notice.gameObject.SetActive(isActive);
                    }
                }
            }

        #if !UNITY_EDITOR
        }

        catch (Exception ex)
        {
            Logger.Error(ex.ToString());
        }
        #endif
        }
Ejemplo n.º 3
0
        private void OnEvent_RunAnim(IEvent ievent)
        {
            var e = ievent as UIEvent_PlayMainUIBtnAnimEvent;

            if (null == e)
            {
                return;
            }

            var objTransform = gameObject.transform;

            for (int i = 0, imax = objTransform.childCount; i < imax; ++i)
            {
                var root          = objTransform.GetChild(i);
                var rootTransform = root.transform;
                if (rootTransform.Find(e.BtnName) != null)
                {
                    var datafind = rootTransform.Find(e.BtnName).gameObject;
                    gameObj = datafind;
                }
            }
            mainScreenButton = gameObject.GetComponent <MainScreenButtonFrame>();
            {
                // foreach(var data in myMainUiButtonLogic.BtnList)
                var __enumerator12 = (mainScreenButton.BtnList).GetEnumerator();
                while (__enumerator12.MoveNext())
                {
                    var data = __enumerator12.Current;
                    {
                        if (data.name == e.BtnName)
                        {
                            return;
                        }
                    }
                }
            }
            {
                // foreach(var data in myMainUiButtonLogic.BtnList1)
                var __enumerator13 = (mainScreenButton.BtnList1).GetEnumerator();
                while (__enumerator13.MoveNext())
                {
                    var data = __enumerator13.Current;
                    {
                        if (data.name == e.BtnName)
                        {
                            if (mainScreenButton.mNowLook != 0)
                            {
                                mainScreenButton.OnClickType1();
                            }
                            return;
                        }
                    }
                }
            }
            {
                // foreach(var data in myMainUiButtonLogic.BtnList2)
                var __enumerator14 = (mainScreenButton.BtnList2).GetEnumerator();
                while (__enumerator14.MoveNext())
                {
                    var data = __enumerator14.Current;
                    {
                        if (data.name == e.BtnName)
                        {
                            if (mainScreenButton.mNowLook != 1)
                            {
                                mainScreenButton.OnClickType2();
                            }
                            return;
                        }
                    }
                }
            }
            {
                // foreach(var data in myMainUiButtonLogic.BtnList3)
                var __enumerator15 = (mainScreenButton.BtnList3).GetEnumerator();
                while (__enumerator15.MoveNext())
                {
                    var data = __enumerator15.Current;
                    {
                        if (data.name == e.BtnName)
                        {
                            if (mainScreenButton.mNowLook != 2)
                            {
                                mainScreenButton.OnClickType3();
                            }
                            return;
                        }
                    }
                }
            }
            {
                // foreach(var data in myMainUiButtonLogic.BtnList4)
                var __enumerator16 = (mainScreenButton.BtnList4).GetEnumerator();
                while (__enumerator16.MoveNext())
                {
                    var data = __enumerator16.Current;
                    {
                        if (data.name == e.BtnName)
                        {
                            if (mainScreenButton.mNowLook != 3)
                            {
                                mainScreenButton.OnClickType4();
                            }
                            return;
                        }
                    }
                }
            }

            UIaminition(e.BtnName);
            theCallback = e.CallBack;
        }