Serves as the base for all AutoSprite-based controls. The main purpose of having this is so we can deal with all control types as a group, such as using a custom inspector.
Inheritance: AutoSpriteBase, IControl, IUIObject, IPackableControl
Esempio n. 1
0
    private void Effect_Set(WWWItem _item, object _param)
    {
        AutoSpriteControlBase autoSpriteControlBase = _param as AutoSpriteControlBase;

        if (null != _item.GetSafeBundle() && autoSpriteControlBase != null && autoSpriteControlBase.gameObject != null && null != _item.GetSafeBundle().mainAsset)
        {
            GameObject gameObject = _item.GetSafeBundle().mainAsset as GameObject;
            if (null != gameObject)
            {
                this.m_gbEffect_Set = (UnityEngine.Object.Instantiate(gameObject) as GameObject);
                if (this == null)
                {
                    UnityEngine.Object.DestroyImmediate(this.m_gbEffect_Set);
                    return;
                }
                Vector2 size = autoSpriteControlBase.GetSize();
                this.m_gbEffect_Set.transform.parent        = autoSpriteControlBase.gameObject.transform;
                this.m_gbEffect_Set.transform.localPosition = new Vector3(size.x / 2f, -size.y / 2f, autoSpriteControlBase.gameObject.transform.localPosition.z + 1.05f);
                NkUtil.SetAllChildLayer(this.m_gbEffect_Set, GUICamera.UILayer);
                this.m_gbEffect_Set.SetActive(true);
                if (TsPlatform.IsMobile && TsPlatform.IsEditor)
                {
                    NrTSingleton <NkClientLogic> .Instance.SetEditorShaderConvert(ref this.m_gbEffect_Set);
                }
            }
        }
    }
Esempio n. 2
0
 public void RequestAttachUIEffect(string path, AutoSpriteControlBase obj, Vector2 size)
 {
     if (null == obj)
     {
         return;
     }
     this.RequestUIBundleDownLoad(path, new PostProcPerItem(this._funcUIEffectDownloaded), new KeyValuePair <AutoSpriteControlBase, Vector2>(obj, size));
 }
Esempio n. 3
0
    // Mirrors the specified control's settings
    public override void Mirror(SpriteRoot s)
    {
        AutoSpriteControlBase c = (AutoSpriteControlBase)s;

        base.Mirror(s);
        text        = c.text;
        textOffsetZ = c.textOffsetZ;
    }
 public void SetSlotEffect(string effectKey, AutoSpriteControlBase obj, Vector2 size)
 {
     if (obj == null)
     {
         return;
     }
     NrTSingleton <FormsManager> .Instance.AttachEffectKey(effectKey, obj, size);
 }
Esempio n. 5
0
    public override void Mirror(SpriteRoot s)
    {
        AutoSpriteControlBase autoSpriteControlBase = (AutoSpriteControlBase)s;

        base.Mirror(s);
        this.text        = autoSpriteControlBase.Text;
        this.textOffsetZ = autoSpriteControlBase.textOffsetZ;
    }
Esempio n. 6
0
        public void AttachEffectKey(string effectKey, AutoSpriteControlBase obj, Vector2 size)
        {
            string path = MsgHandler.HandleReturn <string>("EffectFileName", new object[]
            {
                effectKey
            });

            this.RequestUIBundleDownLoad(path, new PostProcPerItem(this._funcUIEffectDownloaded), new KeyValuePair <AutoSpriteControlBase, Vector2>(obj, size));
        }
    public void ShowUIGuide(string param1, string param2, int winID)
    {
        if (string.IsNullOrEmpty(param1))
        {
            return;
        }
        if (this.guideWinIDList != null && !this.guideWinIDList.Contains(winID))
        {
            this.guideWinIDList.Add(winID);
        }
        string[] array = param1.Split(new char[]
        {
            ','
        });
        if (array == null || array.Length != 4)
        {
            return;
        }
        UIListItemContainer   listItemContainer = this.GetListItemContainer(this.m_iDummyCharKind);
        AutoSpriteControlBase charKindContainer = this.GetCharKindContainer(listItemContainer, this.m_iDummyCharKind);

        if (charKindContainer == null)
        {
            return;
        }
        if (this._Touch == null)
        {
            this._Touch = UICreateControl.Button("touch", "Main_I_Touch01", 196f, 154f);
        }
        if (this._Touch == null)
        {
            return;
        }
        int anchor = int.Parse(array[1]);

        this._Touch.SetAnchor((SpriteRoot.ANCHOR_METHOD)anchor);
        this._Touch.PlayAni(true);
        this._Touch.gameObject.SetActive(true);
        this._Touch.gameObject.transform.parent = charKindContainer.gameObject.transform;
        this._Touch.transform.position          = new Vector3(charKindContainer.transform.position.x, charKindContainer.transform.position.y, charKindContainer.transform.position.z - 3f);
        float x = float.Parse(array[2]);
        float y = float.Parse(array[3]);

        this._Touch.transform.eulerAngles = new Vector3(x, y, this._Touch.transform.eulerAngles.z);
        BoxCollider component = this._Touch.gameObject.GetComponent <BoxCollider>();

        if (null != component)
        {
            UnityEngine.Object.Destroy(component);
        }
    }
 public void SetAlpha(float _alpha)
 {
     for (int i = 0; i < base.transform.childCount; i++)
     {
         Transform child = base.transform.GetChild(i);
         if (null != child)
         {
             AutoSpriteControlBase component = child.GetComponent <AutoSpriteControlBase>();
             if (null != component)
             {
                 component.SetAlpha(_alpha);
             }
         }
     }
 }
Esempio n. 9
0
    public void SetChatFocus()
    {
        IKeyFocusable keyFocusable = NrTSingleton <UIManager> .Instance.FocusObject as IKeyFocusable;

        if (keyFocusable != null)
        {
            TextField y = keyFocusable as TextField;
            if (this._tfInput != y)
            {
                return;
            }
        }
        if (this.HideControl)
        {
            return;
        }
        if (this.bNotTextKeypadEnter)
        {
            this._tfInput.ClearFocus();
        }
        else
        {
            this._tfInput.SetFocus();
        }
        this.bNotTextKeypadEnter = !this.bNotTextKeypadEnter;
        bool flag;

        if (!this._tfInput.Visible)
        {
            AutoSpriteControlBase arg_A3_0 = this._tfInput;
            flag = true;
            this._dtInputBG.Visible = flag;
            flag = flag;
            this.lbChatType.Visible = flag;
            arg_A3_0.Visible        = flag;
        }
        this._tfInput.ColorText = NrTSingleton <CTextParser> .Instance.GetTextColor(MainChatDlg.GetChatColorKey(this.m_SelectTab));

        UIPanelManager arg_E5_0 = this._ToolBar;

        flag = !this.bNotTextKeypadEnter;
        this._btOption.Visible = flag;
        arg_E5_0.Visible       = flag;
        if (0 < this._tfInput.Text.Length)
        {
            this.OnInputText(null);
        }
    }
Esempio n. 10
0
    private void HideTooltip()
    {
        int count = 0;

        if (ctrlTarget != null)
        {
            ctrlTarget.RemoveInputDelegate(TTInputDelegate);
        }
        ctrlTarget = null;

        if (gameObject.active)
        {
            gameObject.SetActiveRecursively(false);
        }
        gameObject.transform.parent = null;
    }
Esempio n. 11
0
 public void ShowTextEffect(GameObject gbEffect, AutoSpriteControlBase Control)
 {
     if (null != gbEffect)
     {
         Vector2 size = Control.GetSize();
         gbEffect.transform.parent        = Control.gameObject.transform;
         gbEffect.transform.localPosition = new Vector3(size.x / 2f, -size.y / 2f, Control.gameObject.transform.localPosition.z - 0.1f);
         gbEffect.SetActive(true);
         Animation componentInChildren = gbEffect.GetComponentInChildren <Animation>();
         if (componentInChildren != null)
         {
             componentInChildren.Stop();
             componentInChildren.Play();
         }
     }
 }
        public void ResizeEffect(IUIObject control, GameObject obj)
        {
            if (obj == null)
            {
                return;
            }
            AutoSpriteControlBase autoSpriteControlBase = (AutoSpriteControlBase)control;

            if (null == autoSpriteControlBase)
            {
                return;
            }
            if (autoSpriteControlBase.GetSize().x == 115f || autoSpriteControlBase.GetSize().x == 116f)
            {
                obj.transform.localScale    = new Vector3(1.6f, 1.6f, 1f);
                obj.transform.localPosition = new Vector3(58f, -58f, obj.transform.localPosition.z);
                Transform child = NkUtil.GetChild(obj.transform, "fx_aura_01");
                if (null != child)
                {
                    child.transform.localPosition = new Vector3(-31.5f, -30f, child.transform.localPosition.z);
                }
            }
            else if (autoSpriteControlBase.GetSize().x == 504f && autoSpriteControlBase.GetSize().y == 448f)
            {
                obj.transform.localScale    = new Vector3(0.98f, 0.98f, 1f);
                obj.transform.localPosition = new Vector3(251f, -210f, obj.transform.localPosition.z);
            }
            else if (autoSpriteControlBase.GetSize().x == 512f && autoSpriteControlBase.GetSize().y == 512f)
            {
                obj.transform.localScale    = new Vector3(1f, 1.12f, 1f);
                obj.transform.localPosition = new Vector3(256f, -242f, obj.transform.localPosition.z);
            }
            else if (autoSpriteControlBase.GetSize().x == 424f && autoSpriteControlBase.GetSize().y == 432f)
            {
                obj.transform.localScale    = new Vector3(0.82f, 0.95f, 1f);
                obj.transform.localPosition = new Vector3(211f, -204f, obj.transform.localPosition.z);
            }
            else if (autoSpriteControlBase.GetSize().x == 315f && autoSpriteControlBase.GetSize().y == 315f)
            {
                obj.transform.localScale    = new Vector3(0.6f, 0.68f, 1f);
                obj.transform.localPosition = new Vector3(157.5f, -151f, obj.transform.localPosition.z);
            }
            else
            {
                obj.transform.localScale = new Vector3(autoSpriteControlBase.GetSize().x / 64f - 0.1f, autoSpriteControlBase.GetSize().x / 64f - 0.1f, 1f);
            }
        }
Esempio n. 13
0
    public void Load_SetEffect()
    {
        UIListItemContainer item = this.m_nlbEquipInfo.GetItem(0);

        if (item != null)
        {
            AutoSpriteControlBase element = item.GetElement(12);
            if (element != null)
            {
                string  str     = string.Format("{0}{1}", "Effect/Instant/fx_setbuuton_ui", NrTSingleton <UIDataManager> .Instance.AddFilePath);
                WWWItem wWWItem = Holder.TryGetOrCreateBundle(str + Option.extAsset, NkBundleCallBack.UIBundleStackName);
                wWWItem.SetItemType(ItemType.USER_ASSETB);
                wWWItem.SetCallback(new PostProcPerItem(this.Effect_Set), element);
                TsImmortal.bundleService.RequestDownloadCoroutine(wWWItem, DownGroup.RUNTIME, true);
            }
        }
    }
Esempio n. 14
0
        public void AttachGameObject(GameObject wItem, KeyValuePair <AutoSpriteControlBase, Vector2> Data)
        {
            if (null == wItem)
            {
                TsLog.LogWarning("AttachGameObject is null ", new object[]
                {
                    wItem
                });
                return;
            }
            GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(wItem, Vector3.zero, Quaternion.identity);

            gameObject.name = NrTSingleton <UIDataManager> .Instance.AttachEffectKeyName;
            if (null == gameObject)
            {
                return;
            }
            MsgHandler.Handle("SetAllChildLayer", new object[]
            {
                gameObject,
                GUICamera.UILayer
            });
            if (null == Data.Key)
            {
                UnityEngine.Object.Destroy(gameObject.gameObject);
                return;
            }
            AutoSpriteControlBase key = Data.Key;

            if (null == key)
            {
                UnityEngine.Object.Destroy(gameObject.gameObject);
                return;
            }
            if (null == key.gameObject)
            {
                UnityEngine.Object.Destroy(gameObject.gameObject);
                return;
            }
            Vector2 value = Data.Value;

            gameObject.transform.parent        = key.gameObject.transform;
            gameObject.transform.localPosition = new Vector3(value.x / 2f, -value.y / 2f, key.gameObject.transform.localPosition.z - 0.1f);
            key.ExcuteGameObjectDelegate(key, gameObject);
        }
    public AutoSpriteControlBase GetElement(int value)
    {
        int num = value + 1;

        if (0 <= num && num < base.transform.childCount)
        {
            Transform child = base.transform.GetChild(num);
            if (null != child)
            {
                AutoSpriteControlBase component = child.GetComponent <AutoSpriteControlBase>();
                if (null != component)
                {
                    return(component);
                }
            }
        }
        return(null);
    }
Esempio n. 16
0
    public void SetParent(GameObject parent)
    {
        if (!parent)
        {
            HideTooltip();
            return;
        }

        if (parent.name == "ComplexWindow")
        {
            ComplexWindow cw = parent.GetComponent <ComplexWindow>();
            if (cw != null)
            {
                cw.OpInputDelegate += ComplexWindowInputDelegate;
            }
        }
        else if (parent.name == "TreePrefab")
        {
            TreeControl tc = parent.GetComponent <TreeControl>();
            if (tc != null)
            {
                tc.OpItemInputDelegate += TreeControlInputDelegate;
            }
        }
        else
        {
            ctrlTarget = parent.GetComponent <AutoSpriteControlBase>();
            if (ctrlTarget != null)
            {
                ctrlTarget.AddInputDelegate(TTInputDelegate);
            }
        }
        curParent = parent;

        ShowTooltip(parent);

        if (CurrentTutorial.nMark == 0)
        {
            if (!CurrentTutorial.isDone)
            {
                TutorialDone();
            }
        }
    }
Esempio n. 17
0
    public override bool DidChange(SpriteRoot s)
    {
        AutoSpriteControlBase autoSpriteControlBase = (AutoSpriteControlBase)s;

        if (this.text != autoSpriteControlBase.Text)
        {
            autoSpriteControlBase.Text = autoSpriteControlBase.Text;
            return(true);
        }
        if (this.textOffsetZ != autoSpriteControlBase.textOffsetZ)
        {
            if (autoSpriteControlBase.spriteText != null)
            {
                autoSpriteControlBase.spriteText.offsetZ = this.textOffsetZ;
            }
            return(true);
        }
        return(base.DidChange(s));
    }
Esempio n. 18
0
    internal void AddHollowWindow(GameObject window)
    {
        if (window == null)
        {
            return;
        }
        UIScrollList list = window.GetComponentInChildren <UIScrollList>();

        if (list != null)
        {
            list.AddInputDelegate(HollowWindowInput);
        }

        AutoSpriteControlBase baseControl = window.GetComponentInChildren <AutoSpriteControlBase>();

        if (baseControl != null)
        {
            baseControl.AddInputDelegate(HollowWindowInput);
        }
    }
Esempio n. 19
0
    // Returns true if any of the settings do not match:
    public override bool DidChange(SpriteRoot s)
    {
        AutoSpriteControlBase c = (AutoSpriteControlBase)s;

        if (text != c.text)
        {
            c.Text = c.text;
            return(true);
        }

        if (textOffsetZ != c.textOffsetZ)
        {
            if (c.spriteText != null)
            {
                c.spriteText.offsetZ = textOffsetZ;
            }
            return(true);
        }

        return(base.DidChange(s));
    }
    public void AddChild(GameObject go)
    {
        AutoSpriteControlBase autoSpriteControlBase = (AutoSpriteControlBase)go.GetComponent(typeof(AutoSpriteControlBase));

        if (autoSpriteControlBase != null)
        {
            if (autoSpriteControlBase is AutoSpriteControlBase && autoSpriteControlBase.Container != this)
            {
                autoSpriteControlBase.Container = this;
            }
            this.uiObjs.Add(autoSpriteControlBase);
        }
        else
        {
            UIListItemContainer uIListItemContainer = (UIListItemContainer)go.GetComponent(typeof(UIListItemContainer));
            if (null != uIListItemContainer)
            {
                this.containerObjs.Add(uIListItemContainer);
            }
        }
    }
    public void RemoveChild(GameObject go)
    {
        if (null == go)
        {
            return;
        }
        AutoSpriteControlBase autoSpriteControlBase = (AutoSpriteControlBase)go.GetComponent(typeof(AutoSpriteControlBase));

        if (autoSpriteControlBase != null)
        {
            for (int i = 0; i < this.uiObjs.Count; i++)
            {
                if (this.uiObjs[i] == autoSpriteControlBase)
                {
                    this.uiObjs.RemoveAt(i);
                    break;
                }
            }
            if (autoSpriteControlBase is AutoSpriteControlBase && autoSpriteControlBase.Container == this)
            {
                autoSpriteControlBase.Container = null;
            }
        }
        else
        {
            UIListItemContainer uIListItemContainer = (UIListItemContainer)go.GetComponent(typeof(UIListItemContainer));
            if (uIListItemContainer != null)
            {
                for (int j = 0; j < this.containerObjs.Count; j++)
                {
                    if (this.containerObjs[j] == uIListItemContainer)
                    {
                        this.containerObjs.RemoveAt(j);
                        break;
                    }
                }
            }
        }
    }
    void ShowSpriteSettings()
    {
        AutoSpriteControlBase cont = (AutoSpriteControlBase)control;

        // Get the info for this state/element:
        stateInfo = cont.GetStateElementInfo(curState);

        // Put up a texture drop box:
        // Load the texture:
        if (stateInfo.stateObj.frameGUIDs.Length < 1)
        {
            stateInfo.tex = null;
        }
        else
        {
            stateInfo.tex = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(stateInfo.stateObj.frameGUIDs[0]), typeof(Texture2D));
        }


        BeginMonitorChanges();
        // Select the texture for the state:
        stateInfo.tex = (Texture2D)EditorGUILayout.ObjectField(stateNames[curState], stateInfo.tex, typeof(Texture2D));
        EndMonitorChanges();


        // Re-assign the state info to the control:
        // If we have an available frame, assign the new GUID
        if (stateInfo.stateObj.frameGUIDs.Length > 0)
        {
            stateInfo.stateObj.frameGUIDs[0] = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(stateInfo.tex));
        }         // Else only create a new GUID element if the selection is non-null:
        else if (stateInfo.tex != null)
        {
            stateInfo.stateObj.frameGUIDs    = new string[1];
            stateInfo.stateObj.frameGUIDs[0] = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(stateInfo.tex));
        }         // Else, don't do anything. Period.

        transitions = stateInfo.transitions;
    }
    private bool IsExistCharKind(UIListItemContainer item, int pTargetCharKind)
    {
        AutoSpriteControlBase charKindContainer = this.GetCharKindContainer(item, pTargetCharKind);

        return(!(charKindContainer == null));
    }
Esempio n. 24
0
    void ShowSpriteSettings()
    {
        AutoSpriteControlBase cont = (AutoSpriteControlBase)control;

        // Get the info for this state/element:
        stateInfo = cont.GetStateElementInfo(curState);


        // See if the sprite timeline is available:
        if (ste == null)
        {
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(UICtlEditor));
            System.Type steType            = asm.GetType("SpriteTimeline");
            if (steType != null)
            {
                ste = (ISTE)System.Activator.CreateInstance(steType);
                ste.Setup(position, 0);
            }
        }

        // NOW see if the timeline is available:
        if (ste != null)
        {
            ste.SetCurAnim(curState);
            needRepaint = ste.STEOnGUI(-(20f + height), out textureAreaBottom);
        }
        else
        {
            // Put up a texture drop box:
            // Load the texture:
            if (stateInfo.stateObj.frameGUIDs.Length < 1)
            {
                stateInfo.stateObj.frameGUIDs = new string[1] {
                    ""
                };
            }
            stateInfo.tex = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(stateInfo.stateObj.frameGUIDs[0]), typeof(Texture2D));


            BeginMonitorChanges();
#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9)
            // Draw a "clear" button:
            if (GUI.Button(new Rect(clearRect.x, clearRect.y + height, clearRect.width, clearRect.height), "X"))
            {
                stateInfo.tex = null;
            }

            // Select the texture for the state:
            stateInfo.tex     = (Texture2D)EditorGUI.ObjectField(tempRect, stateInfo.tex, typeof(Texture2D));
            textureAreaBottom = tempRect.yMax + ctlVirtSpace;
#else
            // Select the texture for the state:
            stateInfo.tex     = (Texture2D)EditorGUILayout.ObjectField(stateNames[curState], stateInfo.tex, typeof(Texture2D));
            textureAreaBottom = 0;             // This tells us to use Layout.
#endif

            // Handle drag and drop from an outside source:
            EventType eventType = Event.current.type;
            if (eventType == EventType.DragUpdated || eventType == EventType.DragPerform)
            {
                // Validate what is being dropped:
                if (DragAndDrop.objectReferences[0] is Texture2D)
                {
                    // Show a copy icon on the drag
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                    if (eventType == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();
                        stateInfo.tex = (Texture2D)DragAndDrop.objectReferences[0];
                        needRepaint   = true;
                    }

                    Event.current.Use();
                }
            }

            EndMonitorChanges();

            // Re-assign the state info to the control:
            stateInfo.stateObj.frameGUIDs[0] = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(stateInfo.tex));
        }

        transitions = stateInfo.transitions;
    }
Esempio n. 25
0
        private void _funcUIEffectDownloaded(IDownloadedItem wItem, object obj)
        {
            if (null == wItem.mainAsset)
            {
                TsLog.LogWarning("wItem.mainAsset is null -> Path = {0}", new object[]
                {
                    wItem.assetPath
                });
                return;
            }
            GameObject gameObject = wItem.mainAsset as GameObject;

            if (null == gameObject)
            {
                return;
            }
            if (TsPlatform.IsMobile && TsPlatform.IsEditor)
            {
                MsgHandler.Handle("SetEditorShaderConvert", new object[]
                {
                    gameObject
                });
            }
            GameObject gameObject2 = (GameObject)UnityEngine.Object.Instantiate(gameObject, Vector3.zero, Quaternion.identity);

            gameObject2.name = NrTSingleton <UIDataManager> .Instance.AttachEffectKeyName;
            if (null == gameObject2)
            {
                UnityEngine.Object.Destroy(gameObject.gameObject);
                return;
            }
            MsgHandler.Handle("SetAllChildLayer", new object[]
            {
                gameObject2,
                GUICamera.UILayer
            });
            KeyValuePair <AutoSpriteControlBase, Vector2> keyValuePair = (KeyValuePair <AutoSpriteControlBase, Vector2>)obj;

            if (null == keyValuePair.Key)
            {
                UnityEngine.Object.Destroy(gameObject2.gameObject);
                return;
            }
            AutoSpriteControlBase key = keyValuePair.Key;

            if (null == key)
            {
                UnityEngine.Object.Destroy(gameObject2.gameObject);
                return;
            }
            if (null == key.gameObject)
            {
                UnityEngine.Object.Destroy(gameObject2.gameObject);
                return;
            }
            Vector2 value = keyValuePair.Value;

            gameObject2.transform.parent        = key.gameObject.transform;
            gameObject2.transform.localPosition = new Vector3(value.x / 2f, -value.y / 2f, key.gameObject.transform.localPosition.z - 0.1f);
            key.ExcuteGameObjectDelegate(key, gameObject2);
        }
Esempio n. 26
0
    /// <summary>
    /// Copies all of the specified control's settings
    /// to this control, provided they are of the same
    /// type.  One exception is that layers are not
    /// copied as this would require a new allocation
    /// and could negatively impact performance at
    /// runtime.
    /// </summary>
    /// <param name="s">Reference to the control whose settings are to be copied to this control.</param>
    public virtual void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            if (Application.isPlaying && s.Started)
            {
                base.Copy(s);
            }
            else             // If we're in-editor, copy the TextureAnims too
            {
                base.CopyAll(s);
            }

            if (!(s is AutoSpriteControlBase))
            {
                if (autoResize || pixelPerfect)
                {
                    CalcSize();
                }
                else
                {
                    SetSize(s.width, s.height);
                }

                SetBleedCompensation();

                return;
            }
        }



        AutoSpriteControlBase c = (AutoSpriteControlBase)s;

        // Copy transitions:
        if ((flags & ControlCopyFlags.Transitions) == ControlCopyFlags.Transitions)
        {
            if (c is UIStateToggleBtn || !Application.isPlaying)
            {
                if (c.Transitions != null)
                {
                    Transitions = new EZTransitionList[c.Transitions.Length];
                    for (int i = 0; i < Transitions.Length; ++i)
                    {
                        Transitions[i] = new EZTransitionList();
                        c.Transitions[i].CopyToNew(Transitions[i], true);
                    }
                }
            }
            else
            {
                if (Transitions != null && c.Transitions != null)
                {
                    for (int i = 0; i < Transitions.Length && i < c.Transitions.Length; ++i)
                    {
                        c.Transitions[i].CopyTo(Transitions[i], true);
                    }
                }
            }
        }


        if ((flags & ControlCopyFlags.Text) == ControlCopyFlags.Text)
        {
            // See if we want to clone the other
            // control's text mesh:
            if (spriteText == null && c.spriteText != null)
            {
                GameObject newText = (GameObject)Instantiate(c.spriteText.gameObject);
                newText.transform.parent        = transform;
                newText.transform.localPosition = c.spriteText.transform.localPosition;
                newText.transform.localScale    = c.spriteText.transform.localScale;
                newText.transform.localRotation = c.spriteText.transform.localRotation;
            }

            if (spriteText != null)
            {
                spriteText.Copy(c.spriteText);
            }
        }

        if ((flags & ControlCopyFlags.Data) == ControlCopyFlags.Data)
        {
            data = c.data;
        }

        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            // See if we can copy the other control's collider's settings:
            if (c.collider != null)
            {
                if (collider.GetType() == c.collider.GetType())
                {
                    if (c.collider is BoxCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(BoxCollider));
                        }

                        BoxCollider bc1 = (BoxCollider)collider;
                        BoxCollider bc2 = (BoxCollider)c.collider;
                        bc1.center = bc2.center;
                        bc1.size   = bc2.size;
                    }
                    else if (c.collider is SphereCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(SphereCollider));
                        }

                        SphereCollider sc1 = (SphereCollider)collider;
                        SphereCollider sc2 = (SphereCollider)c.collider;
                        sc1.center = sc2.center;
                        sc1.radius = sc2.radius;
                    }
                    else if (c.collider is MeshCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(MeshCollider));
                        }

                        MeshCollider mc1 = (MeshCollider)collider;
                        MeshCollider mc2 = (MeshCollider)c.collider;
                        mc1.smoothSphereCollisions = mc2.smoothSphereCollisions;
                        mc1.convex     = mc2.convex;
                        mc1.sharedMesh = mc2.sharedMesh;
                    }
                    else if (c.collider is CapsuleCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(CapsuleCollider));
                        }

                        CapsuleCollider cc1 = (CapsuleCollider)collider;
                        CapsuleCollider cc2 = (CapsuleCollider)c.collider;
                        cc1.center    = cc2.center;
                        cc1.radius    = cc2.radius;
                        cc1.height    = cc2.height;
                        cc1.direction = cc2.direction;
                    }

                    if (collider != null)
                    {
                        collider.isTrigger = c.collider.isTrigger;
                    }
                }
            }
            else if (Application.isPlaying)            // Don't create a collider if we're in edit mode
            {
                // Create a default box collider to fit so
                // long as the control isn't of 0 size:
                if (collider == null &&
                    width != 0 && height != 0 &&
                    !float.IsNaN(width) && !float.IsNaN(height))
                {
                    BoxCollider bc = (BoxCollider)gameObject.AddComponent(typeof(BoxCollider));
                    bc.size      = new Vector3(c.width, c.height, 0.001f);
                    bc.center    = c.GetCenterPoint();
                    bc.isTrigger = true;
                }
                else
                {
                    if (collider is BoxCollider)
                    {
                        BoxCollider bc = (BoxCollider)collider;
                        bc.size   = new Vector3(c.width, c.height, 0.001f);
                        bc.center = c.GetCenterPoint();
                    }
                    else if (collider is SphereCollider)
                    {
                        SphereCollider sc = (SphereCollider)collider;
                        sc.radius = Mathf.Max(c.width, c.height);
                        sc.center = c.GetCenterPoint();
                    }
                    // Else Fuhgettaboutit
                }
            }
        }

        if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
        {
            changeDelegate = c.changeDelegate;
            inputDelegate  = c.inputDelegate;
        }

        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State ||
            (flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            Container = c.Container;

            if (Application.isPlaying)
            {
                controlIsEnabled = c.controlIsEnabled;
                Hide(c.IsHidden());
            }

            if (curAnim != null)
            {
                if (curAnim.index == -1)
                {
                    PlayAnim(curAnim);
                }
                else
                {
                    SetState(curAnim.index);
                }
            }
            else
            {
                SetState(0);
            }
        }

/*
 *              if (autoResize || pixelPerfect)
 *                      CalcSize();
 *              else
 *                      SetSize(s.width, s.height);
 */
    }
Esempio n. 27
0
 public void ActiveRewardEffect(AutoSpriteControlBase _obj)
 {
     TsAudioManager.Instance.AudioContainer.RequestAudioClip("UI_SFX", "EXPLOERE", "BOX_OPEN", new PostProcPerItem(NrAudioClipDownloaded.OnEventAudioClipDownloadedImmedatePlay));
     NrTSingleton <FormsManager> .Instance.RequestAttachUIEffect("ui/mythicraid/fx_myth_raid_treasure_chest_mobile", _obj, _obj.GetSize());
 }