//创建获得金币 public void ShowGetGold(int gold) { Debug.Log("------------ShowGetGold------------"); GComponent words = UIPackage.CreateObject("GameUI", "HurtInfo").asCom; WordsInfo wd = AddWordsInfo(words); wd.RandomX(-30, 30); //words.z = 0; //1,直接加到GRoot显示出来 GRoot.inst.AddChild(words); GRoot.inst.SetChildIndex(words, 1); words.GetChild("num").asTextField.text = "" + gold; words.GetChild("num").asTextField.color = new Color(245 / 255.0f, 218 / 255.0f, 0); words.GetChild("num").asTextField.shadowOffset = new Vector2(1, 1); words.GetChild("num").asTextField.textFormat.bold = true; FairyGUI.Transition trans = words.GetTransition("getgold"); trans.Play(); trans.SetHook("over", () => { RemoveWordsInfo(wd); }); //音效 AudioManager.Am.Play3DSound(AudioManager.Sound_Gold, this.Mode.transform.position); }
public override void ConstructFromXML(FairyGUI.Utils.XML cxml) { base.ConstructFromXML(cxml); _timeText = this.GetChild("timeText").asTextField; _readController = this.GetController("IsRead"); _fetchController = this.GetController("c1"); _trans = this.GetTransition("t0"); }
public void Copy(Transition source) { Stop(); _items.Clear(); int cnt = source._items.Count; for (int i = 0; i < cnt; i++) { _items.Add(source._items[i].Clone()); } }
void __play(GComponent target) { _btnGroup.visible = false; GRoot.inst.AddChild(target); FairyGUI.Transition t = target.GetTransition("t0"); t.Play(() => { _btnGroup.visible = true; GRoot.inst.RemoveChild(target); }); }
void __play4() { _btnGroup.visible = false; _g4.x = GRoot.inst.width - _g4.width - 20; _g4.y = 100; GRoot.inst.AddChild(_g4); FairyGUI.Transition t = _g4.GetTransition("t0"); t.Play(3, 0, () => { _btnGroup.visible = true; GRoot.inst.RemoveChild(_g4); }); }
public static void NoticeWordsAnim(string word, Google.Protobuf.Collections.RepeatedField <string> p, string anim, int pos = 1) { // pos 1上 2中 3下 var showpos = Tool.GetPosition(0.5f, 0.2f); if (pos == 1) { showpos = Tool.GetPosition(0.5f, 0.2f); } else if (pos == 2) { showpos = Tool.GetPosition(0.5f, 0.5f); } else if (pos == 3) { showpos = Tool.GetPosition(0.5f, 0.8f); } GComponent words = UIPackage.CreateObject("GameUI", "NoticeWords").asCom; //1,直接加到GRoot显示出来 GRoot.inst.AddChild(words); //GRoot.inst.SetChildIndex(words, 1); words.xy = showpos;// Tool.GetPosition(0.5f, 0.2f); //var root = words.GetComponent<FairyGUI.UIPanel>().ui; words.GetChild("word").asTextField.text = word;// noticewords.Words; if (p != null && p.Count > 0) { int index = 1; foreach (var item in p) { Debug.Log("---------------NoticeWords:" + item); words.GetChild("word").asTextField.SetVar("p" + index, item); index++; } words.GetChild("word").asTextField.FlushVars(); } FairyGUI.Transition trans = words.GetTransition(anim); trans.Play(); trans.SetHook("over", () => { words.Dispose(); }); }
void __play5() { _btnGroup.visible = false; _g5.x = 20; _g5.y = GRoot.inst.height - _g5.height - 100; GRoot.inst.AddChild(_g5); FairyGUI.Transition t = _g5.GetTransition("t0"); _startValue = 10000; int add = UnityEngine.Random.Range(1000, 3000); _endValue = _startValue + add; _g5.GetChild("value").text = "" + _startValue; _g5.GetChild("add_value").text = "" + add; t.Play(() => { _btnGroup.visible = true; GRoot.inst.RemoveChild(_g5); }); }
static int _CreateFairyGUI_Transition(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { FairyGUI.GComponent arg0 = (FairyGUI.GComponent)ToLua.CheckObject(L, 1, typeof(FairyGUI.GComponent)); FairyGUI.Transition obj = new FairyGUI.Transition(arg0); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: FairyGUI.Transition.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
//创建miss public void ShowMiss() { Debug.Log("------------ShowMiss------------"); //var words = (GameObject)(GameObject.Instantiate(Resources.Load("UIPref/HurtWords"))); //words.transform.parent = m_Mode.transform.parent; //words.transform.position = m_Mode.transform.position + new Vector3(0, m_MeshHeight, -0.1f); GComponent words = UIPackage.CreateObject("GameUI", "HurtInfo").asCom; WordsInfo wd = AddWordsInfo(words); wd.RandomX(-30, 30); //words.z = 0; //1,直接加到GRoot显示出来 GRoot.inst.AddChild(words); GRoot.inst.SetChildIndex(words, 1); //var root = words.GetComponent<FairyGUI.UIPanel>().ui; words.GetChild("num").asTextField.text = "miss"; words.GetChild("num").asTextField.color = new Color(1.0f, 1.0f, 1.0f); FairyGUI.Transition trans = words.GetTransition("up"); trans.Play(); trans.SetHook("over", () => { RemoveWordsInfo(wd); }); }
static int Play(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(FairyGUI.Transition))) { FairyGUI.Transition obj = (FairyGUI.Transition)ToLua.ToObject(L, 1); obj.Play(); return(0); } else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(FairyGUI.Transition), typeof(FairyGUI.PlayCompleteCallback))) { FairyGUI.Transition obj = (FairyGUI.Transition)ToLua.ToObject(L, 1); FairyGUI.PlayCompleteCallback arg0 = null; LuaTypes funcType2 = LuaDLL.lua_type(L, 2); if (funcType2 != LuaTypes.LUA_TFUNCTION) { arg0 = (FairyGUI.PlayCompleteCallback)ToLua.ToObject(L, 2); } else { LuaFunction func = ToLua.ToLuaFunction(L, 2); arg0 = DelegateFactory.CreateDelegate(typeof(FairyGUI.PlayCompleteCallback), func) as FairyGUI.PlayCompleteCallback; } obj.Play(arg0); return(0); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(FairyGUI.Transition), typeof(int), typeof(float), typeof(FairyGUI.PlayCompleteCallback))) { FairyGUI.Transition obj = (FairyGUI.Transition)ToLua.ToObject(L, 1); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); float arg1 = (float)LuaDLL.lua_tonumber(L, 3); FairyGUI.PlayCompleteCallback arg2 = null; LuaTypes funcType4 = LuaDLL.lua_type(L, 4); if (funcType4 != LuaTypes.LUA_TFUNCTION) { arg2 = (FairyGUI.PlayCompleteCallback)ToLua.ToObject(L, 4); } else { LuaFunction func = ToLua.ToLuaFunction(L, 4); arg2 = DelegateFactory.CreateDelegate(typeof(FairyGUI.PlayCompleteCallback), func) as FairyGUI.PlayCompleteCallback; } obj.Play(arg0, arg1, arg2); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: FairyGUI.Transition.Play")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
//创建伤害数字 public void CreateHurtWords(Protomsg.MsgPlayerHurt hurt) { //Vector2 pt = World2FairyUIPoint(); //pt.x += UnityEngine.Random.Range(-30, 30); //如果是加钻石 //Debug.Log("------CreateHurtWords:" + hurt); if (hurt.GetDiamond > 0) { ShowGetDiamond(hurt.GetDiamond); return; } //如果是加金币 if (hurt.GetGold > 0) { ShowGetGold(hurt.GetGold); return; } GComponent words = UIPackage.CreateObject("GameUI", "HurtInfo").asCom; WordsInfo wd = AddWordsInfo(words); wd.RandomX(-30, 30); //1,直接加到GRoot显示出来 GRoot.inst.AddChild(words); GRoot.inst.SetChildIndex(words, 1); //words.xy = pt; words.GetChild("num").asTextField.text = hurt.HurtAllValue + ""; if (this == GameScene.Singleton.GetMyMainUnit()) { //自己受伤 if (hurt.HurtAllValue < 0) { FairyGUI.Transition trans = words.GetTransition("down"); trans.Play(); trans.SetHook("over", () => { RemoveWordsInfo(wd); }); } else//加血 { words.GetChild("num").asTextField.color = new Color(0.1f, 1.0f, 0.1f); FairyGUI.Transition trans = words.GetTransition("up"); trans.Play(); trans.SetHook("over", () => { RemoveWordsInfo(wd); //GameObject.Destroy(words); }); } } else { //伤害别人 if (hurt.IsCrit != 1) { words.GetChild("num").asTextField.color = new Color(1.0f, 1.0f, 1.0f); } FairyGUI.Transition trans = words.GetTransition("up"); trans.Play(); trans.SetHook("over", () => { RemoveWordsInfo(wd); //words.Dispose(); //GameObject.Destroy(words); }); } }
/// <summary> /// Set current page index, no onChanged event. /// 通过索引设置当前活动页面,和selectedIndex的区别在于,这个方法不会触发onChanged事件。 /// </summary> /// <param name="value">Page index</param> public void SetSelectedIndex(int value) { if (_selectedIndex != value) { if (value > _pageIds.Count - 1) throw new IndexOutOfRangeException("" + value); _previousIndex = _selectedIndex; _selectedIndex = value; parent.ApplyController(this); if (_playingTransition != null) { _playingTransition.Stop(); _playingTransition = null; } } }
public virtual void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; SetSize(sourceWidth, sourceHeight); arr = xml.GetAttributeArray("pivot"); if (arr != null) { float f1 = float.Parse(arr[0]); float f2 = float.Parse(arr[1]); this.SetPivot(f1, f2, xml.GetAttributeBool("anchor")); } this.opaque = xml.GetAttributeBool("opaque", true); arr = xml.GetAttributeArray("hitTest"); if (arr != null) { PixelHitTestData hitTestData = _packageItem.owner.GetPixelHitTestData(arr[0]); if (hitTestData != null) this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2])); } OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); if (overflow == OverflowType.Scroll) { ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); string vtScrollBarRes = null; string hzScrollBarRes = null; arr = xml.GetAttributeArray("scrollBarRes"); if (arr != null) { vtScrollBarRes = arr[0]; hzScrollBarRes = arr[1]; } SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes); } else SetupOverflow(overflow); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) continue; u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } str = xml.GetAttribute("mask"); if (str != null) this.mask = GetChildById(str).displayObject; XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); }
virtual public void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; SetSize(sourceWidth, sourceHeight); this.opaque = xml.GetAttributeBool("opaque", true); arr = xml.GetAttributeArray("hitTest"); if (arr != null) { PixelHitTestData hitTestData = _packageItem.owner.GetPixelHitTestData(arr[0]); if (hitTestData != null) { this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2])); } } OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) { overflow = FieldTypes.ParseOverflowType(str); } else { overflow = OverflowType.Visible; } str = xml.GetAttribute("margin"); if (str != null) { _margin.Parse(str); } if (overflow == OverflowType.Scroll) { ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) { scroll = FieldTypes.ParseScrollType(str); } else { scroll = ScrollType.Vertical; } ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) { scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); } else { scrollBarDisplay = ScrollBarDisplayType.Default; } int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) { scrollBarMargin.Parse(str); } string vtScrollBarRes = null; string hzScrollBarRes = null; arr = xml.GetAttributeArray("scrollBarRes"); if (arr != null) { vtScrollBarRes = arr[0]; hzScrollBarRes = arr[1]; } SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes); } else { SetupOverflow(overflow); } arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) { this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); } _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) { continue; } u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } str = xml.GetAttribute("mask"); if (str != null) { this.mask = GetChildById(str).displayObject; } XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); }
public static void PaoMaDeng(string word, Google.Protobuf.Collections.RepeatedField <string> p) { //处理文字 Dictionary <string, string> pa = new Dictionary <string, string>(); if (p != null && p.Count > 0) { int index = 1; foreach (var item in p) { pa["p" + index] = item; index++; } } word = Tool.ParseTemplate(word, pa); if (PaoMaDengCom == null) { PaoMaDengCom = UIPackage.CreateObject("GameUI", "PaoMaDeng").asCom; GRoot.inst.AddChild(PaoMaDengCom); PaoMaDengCom.xy = Tool.GetPosition(0.5f, 0.2f); PaoMaDengCom.GetChild("word").asTextField.text = word; FairyGUI.Transition trans = PaoMaDengCom.GetTransition("move2left"); var speed = 200.0f; var distanse = 800 + PaoMaDengCom.GetChild("word").width; var time = distanse / speed; trans.SetValue("over", -PaoMaDengCom.GetChild("word").width, 5); trans.SetDuration("start", time); trans.Play(); LastPlayTime = GetTime(); trans.SetHook("over", () => { PaoMaDengCom.Dispose(); PaoMaDengCom = null; }); } else { var lasttext = PaoMaDengCom.GetChild("word").asTextField.text; PaoMaDengCom.GetChild("word").asTextField.text = " "; for (;;) { if (PaoMaDengCom.GetChild("word").width >= 800) { break; } PaoMaDengCom.GetChild("word").asTextField.text += " "; } var space = PaoMaDengCom.GetChild("word").asTextField.text; PaoMaDengCom.GetChild("word").asTextField.text = lasttext + space + word; FairyGUI.Transition trans = PaoMaDengCom.GetTransition("move2left"); //trans.SetPaused(true); var speed = 200.0f; var distanse = 800 + PaoMaDengCom.GetChild("word").width; Debug.Log("distanse:" + distanse); var time = distanse / speed; trans.SetValue("over", -PaoMaDengCom.GetChild("word").width, 5); trans.SetDuration("start", time); trans.SetHook("over", null); trans.Play(1, 0, (float)(GetTime() - LastPlayTime), time, null); trans.SetHook("over", () => { PaoMaDengCom.Dispose(); PaoMaDengCom = null; }); //trans.SetPaused(false); } }
internal void ConstructFromResource(List<GObject> objectPool, int poolIndex) { this.gameObjectName = packageItem.name; XML xml = packageItem.componentData; string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; SetSize(sourceWidth, sourceHeight); arr = xml.GetAttributeArray("pivot"); if (arr != null) { float f1 = float.Parse(arr[0]); float f2 = float.Parse(arr[1]); this.SetPivot(f1, f2, xml.GetAttributeBool("anchor")); } this.opaque = xml.GetAttributeBool("opaque", true); arr = xml.GetAttributeArray("hitTest"); if (arr != null) { PixelHitTestData hitTestData = packageItem.owner.GetPixelHitTestData(arr[0]); if (hitTestData != null) this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2])); } OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); if (overflow == OverflowType.Scroll) { ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); string vtScrollBarRes = null; string hzScrollBarRes = null; arr = xml.GetAttributeArray("scrollBarRes"); if (arr != null) { vtScrollBarRes = arr[0]; hzScrollBarRes = arr[1]; } SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes); } else SetupOverflow(overflow); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList.Enumerator et = xml.GetEnumerator("controller"); Controller controller; while (et.MoveNext()) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(et.Current); } GObject child; DisplayListItem[] displayList = packageItem.displayList; int childCount = displayList.Length; for (int i = 0; i < childCount; i++) { DisplayListItem di = displayList[i]; if (objectPool != null) child = objectPool[poolIndex + i]; else if (di.packageItem != null) { di.packageItem.Load(); child = UIObjectFactory.NewObject(di.packageItem); child.packageItem = di.packageItem; child.ConstructFromResource(); } else child = UIObjectFactory.NewObject(di.type); child.underConstruct = true; child.Setup_BeforeAdd(di.desc); child.InternalSetParent(this); _children.Add(child); } this.relations.Setup(xml); for (int i = 0; i < childCount; i++) _children[i].relations.Setup(displayList[i].desc); for (int i = 0; i < childCount; i++) { child = _children[i]; child.Setup_AfterAdd(displayList[i].desc); child.underConstruct = false; if (child.displayObject != null) ToolSet.SetParent(child.displayObject.cachedTransform, this.displayObject.cachedTransform); } str = xml.GetAttribute("mask"); if (str != null) this.mask = GetChildById(str).displayObject; et = xml.GetEnumerator("transition"); while (et.MoveNext()) { Transition trans = new Transition(this); trans.Setup(et.Current); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); SetBoundsChangedFlag(); ConstructFromXML(xml); }
public Transition AddTransition(string name) { int cnt = _transitions.Count; for (int i = 0; i < cnt; ++i) { Transition trans = _transitions[i]; if (trans.name == name) return trans; } Transition trans2 = new Transition(this); _transitions.Add(trans2); return trans2; }
virtual public void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) { overflow = FieldTypes.ParseOverflowType(str); } else { overflow = OverflowType.Visible; } ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) { scroll = FieldTypes.ParseScrollType(str); } else { scroll = ScrollType.Vertical; } ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) { scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); } else { scrollBarDisplay = ScrollBarDisplayType.Default; } int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) { scrollBarMargin.Parse(str); } str = xml.GetAttribute("margin"); if (str != null) { _margin.Parse(str); } SetSize(sourceWidth, sourceHeight); SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) { this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); } _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) { continue; } u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; //build real display list foreach (GObject child in _children) { if (child.displayObject != null && child.finalVisible) { container.AddChild(child.displayObject); } } }
public virtual void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); SetSize(sourceWidth, sourceHeight); SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) continue; u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; //build real display list foreach (GObject child in _children) { if (child.displayObject != null && child.finalVisible) container.AddChild(child.displayObject); } }
internal void ConstructFromResource(List <GObject> objectPool, int poolIndex) { this.gameObjectName = packageItem.name; XML xml = packageItem.componentData; string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; SetSize(sourceWidth, sourceHeight); arr = xml.GetAttributeArray("restrictSize"); if (arr != null) { minWidth = int.Parse(arr[0]); maxWidth = int.Parse(arr[1]); minHeight = int.Parse(arr[2]); maxHeight = int.Parse(arr[3]); } arr = xml.GetAttributeArray("pivot"); if (arr != null) { float f1 = float.Parse(arr[0]); float f2 = float.Parse(arr[1]); this.SetPivot(f1, f2, xml.GetAttributeBool("anchor")); } this.opaque = xml.GetAttributeBool("opaque", true); arr = xml.GetAttributeArray("hitTest"); if (arr != null) { PixelHitTestData hitTestData = packageItem.owner.GetPixelHitTestData(arr[0]); if (hitTestData != null) { this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2])); } } OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) { overflow = FieldTypes.ParseOverflowType(str); } else { overflow = OverflowType.Visible; } str = xml.GetAttribute("margin"); if (str != null) { _margin.Parse(str); } if (overflow == OverflowType.Scroll) { ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) { scroll = FieldTypes.ParseScrollType(str); } else { scroll = ScrollType.Vertical; } ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) { scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); } else { scrollBarDisplay = ScrollBarDisplayType.Default; } int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) { scrollBarMargin.Parse(str); } string vtScrollBarRes = null; string hzScrollBarRes = null; arr = xml.GetAttributeArray("scrollBarRes"); if (arr != null) { vtScrollBarRes = arr[0]; hzScrollBarRes = arr[1]; } string headerRes = null; string footerRes = null; arr = xml.GetAttributeArray("ptrRes"); if (arr != null) { headerRes = arr[0]; footerRes = arr[1]; } SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes, headerRes, footerRes); } else { SetupOverflow(overflow); } arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) { this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); } _buildingDisplayList = true; XMLList.Enumerator et = xml.GetEnumerator("controller"); Controller controller; while (et.MoveNext()) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(et.Current); } GObject child; DisplayListItem[] displayList = packageItem.displayList; int childCount = displayList.Length; for (int i = 0; i < childCount; i++) { DisplayListItem di = displayList[i]; if (objectPool != null) { child = objectPool[poolIndex + i]; } else if (di.packageItem != null) { di.packageItem.Load(); child = UIObjectFactory.NewObject(di.packageItem); child.packageItem = di.packageItem; child.ConstructFromResource(); } else { child = UIObjectFactory.NewObject(di.type); } child.underConstruct = true; child.Setup_BeforeAdd(di.desc); child.InternalSetParent(this); _children.Add(child); } this.relations.Setup(xml); for (int i = 0; i < childCount; i++) { _children[i].relations.Setup(displayList[i].desc); } for (int i = 0; i < childCount; i++) { child = _children[i]; child.Setup_AfterAdd(displayList[i].desc); child.underConstruct = false; if (child.displayObject != null) { ToolSet.SetParent(child.displayObject.cachedTransform, this.displayObject.cachedTransform); } } str = xml.GetAttribute("mask"); if (str != null) { this.mask = GetChildById(str).displayObject; } et = xml.GetEnumerator("transition"); while (et.MoveNext()) { Transition trans = new Transition(this); trans.Setup(et.Current); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); SetBoundsChangedFlag(); ConstructFromXML(xml); }