/// <summary> /// Position in screen /// </summary> public Rect GetRect() { return(UIToolkits.GetUIObjectScreenRect(mUIObject.transform)); }
public T GetChildComponent <T>(string name) where T : Component { return(UIToolkits.FindComponent <T>(mUIObject.transform, name)); }
public bool AddChildComponentMouseClick(string name, EventDelegate.Callback callBack) { return(UIToolkits.AddChildComponentMouseClick(mUIObject.transform, name, callBack)); }
public override void CreateEffect() { if (bTweenPos) { float fromToValX = to.x - from.x; float fromToValY = to.y - from.y; Vector3 fromPos = new Vector3(transform.localPosition.x - fromToValX, transform.localPosition.y - fromToValY, transform.localPosition.z); Vector3 toPos = transform.localPosition; //创建需要的特效 if (mTweenPos == null) { mTweenPos = TweenPosition.Begin(transform.gameObject, duration, toPos); } mTweenPos.from = fromPos; mTweenPos.to = toPos; mTweenPos.duration = duration; m_fromY = mTweenPos.from.y; mTweenList.Add(mTweenPos); } if (bTweenScale) { Vector3 localScale = transform.localScale; //创建需要的特效 if (mTweenScale == null) { mTweenScale = TweenScale.Begin(transform.gameObject, duration, endScale); } mTweenScale.value = new Vector3(localScale.x * startScale.x, localScale.y * startScale.y, localScale.z * startScale.z); mTweenScale.from = mTweenScale.value; mTweenScale.to = new Vector3(localScale.x * endScale.x, localScale.y * endScale.y, localScale.z * endScale.z); mTweenScale.duration = duration; mTweenList.Add(mTweenScale); } if (bTweenAlpha) { if (GetComponent <UIPanel>() != null) //若为 UIPanel, 添加AlphaTween到自己 { AddEffectTo(gameObject); } else // 否则,添加AlphaTween到所有自控件 { List <UIWidget> list = new List <UIWidget>(); UIToolkits.FindComponents <UIWidget>(transform, list); foreach (UIWidget widget in list) { AddEffectTo(widget.gameObject); } } } if (IdleAnim != null) { m_animation = GetComponent <Animation>(); if (m_animation == null) { m_animation = this.gameObject.AddComponent <Animation>(); if (IdleAnim != null) { m_animation.AddClip(IdleAnim, "IdelAnim"); } } } }
public override void OnShow() { base.OnShow(); m_items[0] = PurchasedItem.ItemInGame_Resort; m_items[1] = PurchasedItem.ItemInGame_Hammer; if (GlobalVars.CurStageData.TimeLimit > 0) { m_items[2] = PurchasedItem.ItemInGame_TimeStoper; } else if (GlobalVars.CurStageData.ChocolateCount > 0) { m_items[2] = PurchasedItem.ItemInGame_ChocoStoper; } if (GlobalVars.CurStageData.Target == GameTarget.BringFruitDown) { m_fruitBoard.SetActive(true); m_jellyBoard.SetActive(false); m_scoreBoard.SetActive(false); m_collectBoard.SetActive(false); Transform fruit1Trans = UIToolkits.FindChild(m_fruitBoard.transform, "Fruit1Board"); Transform fruit2Trans = UIToolkits.FindChild(m_fruitBoard.transform, "Fruit2Board"); if (GlobalVars.CurStageData.Nut1Count > 0) { fruit1Trans.gameObject.SetActive(true); UIToolkits.FindComponent <UISprite>(m_fruitBoard.transform, "FruitNumTotal1").spriteName = "BaseNum" + GlobalVars.CurStageData.Nut1Count.ToString(); } else { fruit1Trans.gameObject.SetActive(false); } if (GlobalVars.CurStageData.Nut2Count > 0) { fruit2Trans.gameObject.SetActive(true); UIToolkits.FindComponent <UISprite>(m_fruitBoard.transform, "FruitNumTotal2").spriteName = "BaseNum" + GlobalVars.CurStageData.Nut2Count.ToString(); } else { fruit2Trans.gameObject.SetActive(false); } //居中对齐 if (GlobalVars.CurStageData.Nut1Count > 0 && GlobalVars.CurStageData.Nut2Count > 0) //若两个水果都有 { fruit1Trans.LocalPositionX(10); fruit2Trans.LocalPositionX(201); } else if (GlobalVars.CurStageData.Nut1Count > 0) { fruit1Trans.LocalPositionX(111); } else if (GlobalVars.CurStageData.Nut2Count > 0) { fruit2Trans.LocalPositionX(111); } if (GlobalVars.CurStageData.Nut1Count > 0) { GameLogic.Singleton.CollectTargetUIPos[0] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + fruit1Trans.localPosition.x, 1.562183f - 38.568f, 0); } if (GlobalVars.CurStageData.Nut2Count > 0) { GameLogic.Singleton.CollectTargetUIPos[1] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + fruit2Trans.localPosition.x, 1.562183f - 38.5681f, 0); } } else if (GlobalVars.CurStageData.Target == GameTarget.ClearJelly) { m_fruitBoard.SetActive(false); m_jellyBoard.SetActive(true); m_scoreBoard.SetActive(false); m_collectBoard.SetActive(false); if (GlobalVars.CurStageData.GetDoubleJellyCount() > 0) { UIToolkits.FindChild(m_jellyBoard.transform, "DoubleJellyBoard").gameObject.SetActive(true); } else { UIToolkits.FindChild(m_jellyBoard.transform, "DoubleJellyBoard").gameObject.SetActive(false); } if (GlobalVars.CurStageData.GetDoubleJellyCount() > 0) { UIToolkits.FindChild(m_jellyBoard.transform, "JellyBoard").LocalPositionX(27); UIToolkits.FindChild(m_jellyBoard.transform, "DoubleJellyBoard").LocalPositionX(187); } else { UIToolkits.FindChild(m_jellyBoard.transform, "JellyBoard").LocalPositionX(123); } } else if (GlobalVars.CurStageData.Target == GameTarget.Collect) //处理搜集关的显示 { m_fruitBoard.SetActive(false); m_jellyBoard.SetActive(false); m_scoreBoard.SetActive(false); m_collectBoard.SetActive(true); int collectTypeCount = 0; for (int i = 0; i < 3; ++i) { if (GlobalVars.CurStageData.CollectCount[i] > 0) { m_collectLabel[i].gameObject.SetActive(true); ++collectTypeCount; switch (GlobalVars.CurStageData.CollectSpecial[i]) { case TSpecialBlock.ESpecial_Normal: { m_collectSprite[i].spriteName = "Item" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None); } break; case TSpecialBlock.ESpecial_NormalPlus6: { m_collectSprite[i].spriteName = "TimeAdded" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None); } break; case TSpecialBlock.ESpecial_EatLineDir0: m_collectSprite[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_3"; break; case TSpecialBlock.ESpecial_EatLineDir1: m_collectSprite[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_1"; break; case TSpecialBlock.ESpecial_EatLineDir2: m_collectSprite[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_2"; break; case TSpecialBlock.ESpecial_Bomb: m_collectSprite[i].spriteName = "Bomb" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None); break; case TSpecialBlock.ESpecial_EatAColor: m_collectSprite[i].spriteName = "Rainbow"; break; default: break; } } else { m_collectLabel[i].gameObject.SetActive(false); } } if (collectTypeCount == 3) { int interval = 130; for (int i = 0; i < 3; ++i) { m_collectLabel[i].transform.LocalPositionX(i * interval); } } else if (collectTypeCount == 2) { int interval = 150; int curPosX = 30; for (int i = 0; i < 3; ++i) { if (GlobalVars.CurStageData.CollectCount[i] > 0) { m_collectLabel[i].transform.LocalPositionX(curPosX); curPosX += interval; } } } else if (collectTypeCount == 1) { for (int i = 0; i < 3; ++i) { if (GlobalVars.CurStageData.CollectCount[i] > 0) { m_collectLabel[i].transform.LocalPositionX(144); break; } } } GameLogic.Singleton.CollectTargetUIPos[0] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + m_collectLabel[0].transform.localPosition.x, 1.562183f - 38.568f, 0); GameLogic.Singleton.CollectTargetUIPos[1] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + m_collectLabel[1].transform.localPosition.x, 1.562183f - 38.5681f, 0); GameLogic.Singleton.CollectTargetUIPos[2] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + m_collectLabel[2].transform.localPosition.x, 1.562183f - 38.5681f, 0); } if (GlobalVars.CurStageData.Target == GameTarget.GetScore) { m_fruitBoard.SetActive(false); m_jellyBoard.SetActive(false); m_scoreBoard.SetActive(true); m_collectBoard.SetActive(false); UIToolkits.FindComponent <NumberDrawer>(m_scoreBoard.transform, "ScoreNum").SetNumber(GlobalVars.CurStageData.StarScore[0]); } UISprite item3Icon = GetChildComponent <UISprite>("Item3Icon"); for (int i = 0; i < 3; ++i) { if (CapsConfig.ItemUnLockLevelArray[(int)m_items[i]] <= GlobalVars.AvailabeStageCount || GlobalVars.DeveloperMode) { if (i == 2) { if (GlobalVars.CurStageData.TimeLimit > 0) { item3Icon.spriteName = PurchasedItem.ItemInGame_TimeStoper.ToString(); m_itemBtn[2].gameObject.SetActive(true); } else if (GlobalVars.CurStageData.ChocolateCount > 0) { item3Icon.spriteName = PurchasedItem.ItemInGame_ChocoStoper.ToString(); m_itemBtn[2].gameObject.SetActive(true); } else { m_itemBtn[2].gameObject.SetActive(false); } } else { m_itemBtn[i].gameObject.SetActive(true); } } else { m_itemBtn[i].gameObject.SetActive(false); } } UpdateItemButtons(); RefreshTarget(); if (GlobalVars.DeveloperMode) { m_debugBtn.gameObject.SetActive(true); } else { m_debugBtn.gameObject.SetActive(false); } }
public override void OnShow() { base.OnShow(); m_collectBoard.gameObject.SetActive(false); m_jellyBoard.gameObject.SetActive(false); m_scoreBoard.gameObject.SetActive(false); m_nutBoard.gameObject.SetActive(false); m_gameFailedBoard.gameObject.SetActive(false); m_resortBoard.gameObject.SetActive(false); m_autoResortBoard.gameObject.SetActive(false); m_stepLimitBoard.gameObject.SetActive(false); m_timeLimitBoard.gameObject.SetActive(false); m_sugarCrushBoard.gameObject.SetActive(false); Transform curBoard; if (Mode == TargetMode.StageTarget) { m_background.spriteName = "TargetBar"; StageData stage = GlobalVars.CurStageData; if (stage.Target == GameTarget.GetScore) { m_scoreBoard.gameObject.SetActive(true); curBoard = m_scoreBoard; NumberDrawer scoreLabel = UIToolkits.FindComponent <NumberDrawer>(curBoard, "Score"); scoreLabel.SetNumberRapid(stage.StarScore[0]); } else if (stage.Target == GameTarget.ClearJelly) { m_jellyBoard.gameObject.SetActive(true); curBoard = m_jellyBoard; if (stage.GetDoubleJellyCount() > 0 && stage.GetSingleJellyCount() > 0) { m_jellyBoard.LocalPositionX(-30.0f); NumberDrawer jelly2Label = GetChildComponent <NumberDrawer>("Jelly2Count"); jelly2Label.SetNumberRapid(stage.GetDoubleJellyCount()); NumberDrawer jellyLabel = GetChildComponent <NumberDrawer>("JellyCount"); jellyLabel.SetNumberRapid(stage.GetSingleJellyCount()); jellySplash.gameObject.SetActive(true); jellyIcon.gameObject.SetActive(true); jellyDoubleIcon.gameObject.SetActive(true); jellyIcon.LocalPositionX(48.0f); jellyDoubleIcon.LocalPositionX(253.2f); } else if (stage.GetDoubleJellyCount() > 0 && stage.GetSingleJellyCount() == 0) { NumberDrawer jelly2Label = GetChildComponent <NumberDrawer>("Jelly2Count"); jelly2Label.SetNumberRapid(stage.GetDoubleJellyCount()); jellySplash.gameObject.SetActive(false); jellyIcon.gameObject.SetActive(false); jellyDoubleIcon.gameObject.SetActive(true); jellyDoubleIcon.LocalPositionX(48.0f); m_jellyBoard.LocalPositionX(86.0f); } else { NumberDrawer jellyLabel = GetChildComponent <NumberDrawer>("JellyCount"); jellyLabel.SetNumberRapid(stage.GetSingleJellyCount()); jellySplash.gameObject.SetActive(false); jellyIcon.gameObject.SetActive(true); jellyIcon.LocalPositionX(48.0f); jellyDoubleIcon.gameObject.SetActive(false); m_jellyBoard.LocalPositionX(86.0f); } } else if (stage.Target == GameTarget.BringFruitDown) { m_nutBoard.gameObject.SetActive(true); curBoard = m_nutBoard; if (stage.Nut1Count > 0) { nut1Label.SetNumberRapid(stage.Nut1Count); nut1Label.gameObject.SetActive(true); nut1Icon.gameObject.SetActive(true); nut1Label.LocalPositionX(-14); } else { nut1Label.gameObject.SetActive(false); nut1Icon.gameObject.SetActive(false); } if (stage.Nut2Count > 0) { nut2Label.SetNumberRapid(stage.Nut2Count); nut2Label.gameObject.SetActive(true); nut2Icon.gameObject.SetActive(true); nut2Label.LocalPositionX(-14); } else { nut2Label.gameObject.SetActive(false); nut2Icon.gameObject.SetActive(false); } if (stage.Nut1Count > 0 && stage.Nut2Count > 0) { nutSplash.gameObject.SetActive(true); nut1Label.LocalPositionX(-101); nut2Label.LocalPositionX(71); } else { nutSplash.gameObject.SetActive(false); } } else //Collect { m_collectBoard.gameObject.SetActive(true); curBoard = m_collectBoard; int collectCount = 0; for (int i = 0; i < 3; ++i) { if (stage.CollectCount[i] > 0) { ++collectCount; collectLabel[i].gameObject.SetActive(true); collectIcon[i].gameObject.SetActive(true); collectLabel[i].text = stage.CollectCount[i].ToString(); switch (GlobalVars.CurStageData.CollectSpecial[i]) { case TSpecialBlock.ESpecial_Normal: { collectIcon[i].spriteName = "Item" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None); } break; case TSpecialBlock.ESpecial_NormalPlus6: { collectIcon[i].spriteName = "TimeAdded" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None); } break; case TSpecialBlock.ESpecial_EatLineDir0: collectIcon[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_3"; break; case TSpecialBlock.ESpecial_EatLineDir1: collectIcon[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_1"; break; case TSpecialBlock.ESpecial_EatLineDir2: collectIcon[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_2"; break; case TSpecialBlock.ESpecial_Bomb: collectIcon[i].spriteName = "Bomb" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None); break; case TSpecialBlock.ESpecial_EatAColor: collectIcon[i].spriteName = "Rainbow"; break; default: break; } } else { collectLabel[i].gameObject.SetActive(false); collectIcon[i].gameObject.SetActive(false); } } if (collectCount == 3) { m_collectBoard.LocalPositionX(0); } else if (collectCount == 2) { m_collectBoard.LocalPositionX(67); } else { m_collectBoard.LocalPositionX(120); } } if (stage.StepLimit > 0) { m_stepLimitBoard.gameObject.SetActive(true); NumberDrawer stepLabel = UIToolkits.FindComponent <NumberDrawer>(m_stepLimitBoard, "StepNum"); stepLabel.SetNumberRapid(stage.StepLimit); } else { m_timeLimitBoard.gameObject.SetActive(true); NumberDrawer timeLabel = UIToolkits.FindComponent <NumberDrawer>(m_timeLimitBoard, "TimeNum"); timeLabel.SetNumberRapid(stage.TimeLimit); } } else { if (Mode == TargetMode.GameFailed) { m_background.spriteName = "FailedBar"; m_gameFailedBoard.gameObject.SetActive(true); } else if (Mode == TargetMode.AutoResort) { m_background.spriteName = "ResortBar"; m_autoResortBoard.gameObject.SetActive(true); } else if (Mode == TargetMode.SugarCrush) { m_background.spriteName = "TargetBar"; m_sugarCrushBoard.gameObject.SetActive(true); } } }