public override void OnCreate() { base.OnCreate(); //m_resultLabel = UIToolkits.FindComponent<UILabel>(mUIObject.transform, "ResultLabel"); m_infoLabel = UIToolkits.FindComponent <UILabel>(mUIObject.transform, "EndInfomation"); m_levelLabel = GetChildComponent <NumberDrawer>("LevelLabel"); m_winBoard = UIToolkits.FindChild(mUIObject.transform, "WinBoard"); m_failedBoard = UIToolkits.FindChild(mUIObject.transform, "FailedBoard"); m_retryBtn = GetChildComponent <UIButton>("RetryBtn"); AddChildComponentMouseClick("CloseBtn", OnCloseClicked); AddChildComponentMouseClick("RetryBtn", OnRetryClicked); AddChildComponentMouseClick("NextLevelBtn", OnNextLevelClicked); for (int i = 0; i < 3; ++i) { m_starsSprites[i] = GetChildComponent <UISprite>("Star" + (i + 1)); //查找sprite m_starParticles[i] = GetChildComponent <ParticleSystem>("StarEffect" + (i + 1)); m_starParticles[i].Stop(true); //m_starParticles[i].gameObject.SetActive(false); //for (int index = 0; index < m_starParticles[i].transform.childCount; ++index) //{ // m_starParticles[i].transform.GetChild(index).gameObject.SetActive(false); //} } }
public CapBlock() { //创建新Sprite GameObject capObj = GameObject.Find("CapInstance"); GameObject newObj = GameObject.Instantiate(capObj) as GameObject; newObj.SetActive(false); newObj.transform.parent = capObj.transform.parent; newObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); m_blockTransform = newObj.transform; m_blockSprite = UIToolkits.FindComponent <UISprite>(m_blockTransform); m_animation = UIToolkits.FindComponent <Animation>(m_blockTransform); m_addColorSprite = m_blockSprite.transform.Find("AddColor").GetComponent <UISprite>(); m_blockSprite.transform.localScale = Vector3.one; m_blockSprite.transform.localPosition = Vector3.zero; m_tweenPosition = m_blockTransform.GetComponent <TweenPosition>(); m_tweenScale = m_blockTransform.GetComponent <TweenScale>(); m_tweenAlpha = m_blockSprite.transform.GetComponent <TweenAlpha>(); m_addColorTweenAlpha = m_addColorSprite.transform.GetComponent <TweenAlpha>(); }
int GetGridFlagsFromCheckBoxes() { int gridFlags = 0; for (int i = 0; i < 14; ++i) { UIToggle checkBox = UIToolkits.FindComponent <UIToggle>(mUIObject.transform, "GridFlag" + (i + 1)); //找到CheckBox if (checkBox != null && checkBox.value) { gridFlags |= 1 << i; } } return(gridFlags); }
public void RefreshTarget() { if (GlobalVars.CurStageData.Target == GameTarget.BringFruitDown) { if (GlobalVars.CurStageData.Nut1Count > 0) { UIToolkits.FindComponent <UISprite>(m_fruitBoard.transform, "FruitNumCur1").spriteName = "BaseNum" + GameLogic.Singleton.PlayingStageData.Nut1Count.ToString(); } if (GlobalVars.CurStageData.Nut2Count > 0) { UIToolkits.FindComponent <UISprite>(m_fruitBoard.transform, "FruitNumCur2").spriteName = "BaseNum" + GameLogic.Singleton.PlayingStageData.Nut2Count.ToString(); } } else if (GlobalVars.CurStageData.Target == GameTarget.ClearJelly) { if (GlobalVars.CurStageData.GetJellyCount() > 0) { UIToolkits.FindComponent <NumberDrawer>(m_jellyBoard.transform, "JellyNum").SetNumberRapid(GameLogic.Singleton.PlayingStageData.GetSingleJellyCount()); } if (GlobalVars.CurStageData.GetDoubleJellyCount() > 0) { UIToolkits.FindComponent <NumberDrawer>(m_jellyBoard.transform, "DoubleJellyNum").SetNumberRapid(GameLogic.Singleton.PlayingStageData.GetDoubleJellyCount()); } } else if (GlobalVars.CurStageData.Target == GameTarget.Collect) //处理搜集关的显示 { for (int i = 0; i < 3; ++i) { if (GlobalVars.CurStageData.CollectCount[i] > 0) { m_collectLabel[i].text = GameLogic.Singleton.PlayingStageData.CollectCount[i].ToString() + "/" + GlobalVars.CurStageData.CollectCount[i].ToString(); if (GameLogic.Singleton.PlayingStageData.CollectCount[i] >= GlobalVars.CurStageData.CollectCount[i]) { m_collectLabel[i].color = new Color(0, 1, 0); } else { m_collectLabel[i].color = new Color(0, 0, 0); } } } } }
void RefreshStageGridFlagCheckBoxes(int gridFlags) //刷新当前编辑的GridFlag对应的CheckBox界面 { for (int i = 0; i < 14; ++i) { UIToggle checkBox = UIToolkits.FindComponent <UIToggle>(mUIObject.transform, "GridFlag" + (i + 1)); //找到CheckBox if (checkBox == null) { continue; } if ((gridFlags & 1 << i) > 0) { checkBox.value = true; } else { checkBox.value = false; } } }
int m_clickDebugCount = 0; //用来记录点击隐藏的debug按钮几次,点击3次才起作用 public override void OnCreate() { base.OnCreate(); AddChildComponentMouseClick("PlayBtn", OnPlayBtnClick); AddChildComponentMouseClick("ClearBtn", delegate() { PlayerPrefs.DeleteAll(); //删除进度 Unibiller.DebitBalance("gold", Unibiller.GetCurrencyBalance("gold")); }); AddChildComponentMouseClick("RecoverHeartBtn", delegate() { GlobalVars.AddHeart(5); }); AddChildComponentMouseClick("AddCoinBtn", delegate() { Unibiller.CreditBalance("gold", 100); }); AddChildComponentMouseClick("DebugBtn", delegate() { ++m_clickDebugCount; if (m_clickDebugCount >= 3 && (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)) { m_debugBoard.SetActive(true); } }); m_developerMode = UIToolkits.FindComponent <UIToggle>(mUIObject.transform, "DeveloperCheck"); m_developerMode.value = false; m_testLabel = GetChildComponent <UILabel>("TestNotice"); m_debugBoard = mUIObject.transform.FindChild("DebugBoard").gameObject; }
public T GetChildComponent <T>(string name) where T : Component { return(UIToolkits.FindComponent <T>(mUIObject.transform, name)); }
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); } } }