public void Yes() { Hide(); ShopUI shopUI = ArenaMenuUI.GetInstance().GetPanel(MenuName.SHOP) as ShopUI; shopUI.SetFromPanel(this); shopUI.Show(); }
public void HandleEvent(UIControl control, int command, float wparam, float lparam) { if (control == returnButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); Hide(); ArenaMenuUI ui = GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>(); ui.GetPanel(MenuName.ARENA).Show(); GameApp.GetInstance().Save(); } if (control == avatarScroller && command == (int)UIImageScroller.Command.ScrollSelect) { currentSelectionIndex = (int)wparam; SetBuyButtonText(); ChangeAvatarModel(BUTTON_NUM - 1 - currentSelectionIndex); avatarInfoPanel.SetText(AvatarInfo.AVATAR_INFO[BUTTON_NUM - 1 - currentSelectionIndex]); UpdateCashPanel(); } if (control == buyButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); if (GameApp.GetInstance().GetGameState().GetAvatarData((AvatarType)(BUTTON_NUM - 1 - currentSelectionIndex)) == AvatarState.ToBuy) { GameConfig gConf = GameApp.GetInstance().GetGameConfig(); if (GameApp.GetInstance().GetGameState().BuyAvatar((AvatarType)(BUTTON_NUM - 1 - currentSelectionIndex), gConf.GetAvatarConfig(BUTTON_NUM - 1 - currentSelectionIndex).price)) { SetBuyButtonText(); } else { TopDialogUI.GetInstance().ShowDialog(); } UpdateAvatarIcon(); UpdateCashPanel(); } else if (GameApp.GetInstance().GetGameState().GetAvatarData((AvatarType)(BUTTON_NUM - 1 - currentSelectionIndex)) == AvatarState.Avaliable) { GameApp.GetInstance().GetGameState().Avatar = (AvatarType)(BUTTON_NUM - 1 - currentSelectionIndex); } } else if (control == getMoreMoneyButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); Hide(); ShopUI shopUI = GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>().GetPanel(MenuName.SHOP) as ShopUI; shopUI.SetFromPanel(this); shopUI.Show(); } }
public void Yes() { Debug.Log("yes"); //Hide(); AvatarUI avatarUIPanel = ArenaMenuUI.GetInstance().GetPanel(MenuName.AVATAR) as AvatarUI; avatarUIPanel.Hide(); iapDialog.Hide(); ShopUI shopUI = ArenaMenuUI.GetInstance().GetPanel(MenuName.SHOP) as ShopUI; shopUI.SetFromPanel(avatarUIPanel); shopUI.Show(); }
public void HandleEvent(UIControl control, int command, float wparam, float lparam) { for (int i = 0; i < BUTTON_NUM; i++) { if (control == itemButton[i] && !soldoutLogo[i].Visible) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); IAP.NowPurchaseProduct(itemList[0][i + page * 3].ID, "1"); iapProcessing = (IAPName)i + page * 3; Debug.Log("IAP ID:" + itemList[0][i + page * 3].ID); iapLockPanel.Show(); } } if (control == returnButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); Hide(); if (fromPanel != null) { fromPanel.Show(); } else { ArenaMenuUI ui = GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>(); ui.GetPanel(MenuName.ARENA).Show(); } } else if (control == leftArrowButton) { if (page > 0) { page--; UpdateItemsUI(); } } else if (control == rightArrowButton) { if (page < 1) { page++; UpdateItemsUI(); } } }
public void HandleEvent(UIControl control, int command, float wparam, float lparam) { if (control == weaponScroller && command == (int)UIImageScroller.Command.ScrollSelect) { currentWeaponIndex = (int)wparam - 1; upgradeSelection = 1; if (currentWeaponIndex >= 0) { //Debug.Log("selection weapon:" + weaponList[currentWeaponIndex].Name); selectedWeapon = weaponList[currentWeaponIndex]; UpdateWeaponInfo(); InitSelection(); } else { selectedWeapon = null; UpdateWeaponInfo(); InitSelection(); } //weaponList[weaponID].IsSelectedForBattle = true; } else if (control == upgradePanels[0]) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); upgradeSelection = 1; UpdateSelectionButtonsState(); UpdateWeaponInfo(); /* * if (selectedWeapon != null) * { * cashPanel.SetCost(selectedWeapon.GetDamageUpgradePrice()); * } * else * { * GameConfig gConf = GameApp.GetInstance().GetGameConfig(); * cashPanel.SetCost(gConf.playerConf.upgradeArmorPrice); * } */ } else if (control == upgradePanels[1]) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); upgradeSelection = 2; UpdateSelectionButtonsState(); UpdateWeaponInfo(); //cashPanel.SetCost(selectedWeapon.GetFrequencyUpgradePrice()); } else if (control == upgradePanels[2]) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); upgradeSelection = 3; UpdateSelectionButtonsState(); UpdateWeaponInfo(); //cashPanel.SetCost(selectedWeapon.GetAccuracyUpgradePrice()); } else if (control == upgradePanels[3]) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); upgradeSelection = 4; UpdateSelectionButtonsState(); UpdateWeaponInfo(); //cashPanel.SetCost(selectedWeapon.WConf.bulletPrice); } else if (control == upgradeButton) { if (selectedWeapon != null) { if (selectedWeapon.Exist == WeaponExistState.Owned) { switch (upgradeSelection) { case 1: if (!selectedWeapon.IsMaxLevelDamage()) { if (gameState.UpgradeWeapon(selectedWeapon, selectedWeapon.Damage * selectedWeapon.WConf.damageConf.upFactor, 0f, 0f, selectedWeapon.GetDamageUpgradePrice())) { Debug.Log("upgrade"); ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Upgrade"); } else { iapDialog.SetText(IAPDialog.NOT_ENOUGH_CASH); iapDialog.Show(); } } break; case 2: if (!selectedWeapon.IsMaxLevelCD()) { if (gameState.UpgradeWeapon(selectedWeapon, 0f, selectedWeapon.AttackFrequency * selectedWeapon.WConf.attackRateConf.upFactor, 0f, selectedWeapon.GetFrequencyUpgradePrice())) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Upgrade"); } else { iapDialog.SetText(IAPDialog.NOT_ENOUGH_CASH); iapDialog.Show(); } } break; case 3: if (!selectedWeapon.IsMaxLevelAccuracy()) { if (gameState.UpgradeWeapon(selectedWeapon, 0f, 0f, selectedWeapon.Accuracy * selectedWeapon.WConf.accuracyConf.upFactor, selectedWeapon.GetAccuracyUpgradePrice())) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Upgrade"); } else { iapDialog.SetText(IAPDialog.NOT_ENOUGH_CASH); iapDialog.Show(); } } break; case 4: if (selectedWeapon.BulletCount < 9999) { if (gameState.BuyBullets(selectedWeapon, selectedWeapon.WConf.bullet, selectedWeapon.WConf.bulletPrice)) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Upgrade"); } else { iapDialog.SetText(IAPDialog.NOT_ENOUGH_CASH); iapDialog.Show(); } } break; } } else { WeaponBuyStatus wBuyStatus = gameState.BuyWeapon(selectedWeapon, selectedWeapon.WConf.price); if (wBuyStatus == WeaponBuyStatus.Succeed) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Upgrade"); } else if (wBuyStatus == WeaponBuyStatus.NotEnoughCash) { iapDialog.SetText(IAPDialog.NOT_ENOUGH_CASH); iapDialog.Show(); } else if (wBuyStatus == WeaponBuyStatus.Locked) { iapDialog.SetText(IAPDialog.NOT_AVAILABLE); iapDialog.Show(); } if (selectedWeapon.Exist == WeaponExistState.Owned) { upgradePanels[0].Select(true); int index = gameState.GetWeaponIndex(selectedWeapon); if (weaponScroller != null) { weaponScroller.SetOverlay(index + 1, -1); } } } } else { GameConfig gConf = GameApp.GetInstance().GetGameConfig(); if (gameState.ArmorLevel != gConf.playerConf.maxArmorLevel) { if (gameState.UpgradeArmor(gameState.GetArmorPrice())) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Upgrade"); } else { iapDialog.SetText(IAPDialog.NOT_ENOUGH_CASH); iapDialog.Show(); } } } UpdateWeaponInfo(); } else if (control == returnButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); GameApp.GetInstance().Save(); Hide(); GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>().GetPanel(MenuName.ARENA).Show(); } else if (control == getMoreMoneyButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); Hide(); ShopUI shopUI = GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>().GetPanel(MenuName.SHOP) as ShopUI; shopUI.SetFromPanel(this); shopUI.Show(); } }
public void HandleEvent(UIControl control, int command, float wparam, float lparam) { if (control == returnButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); GameApp.GetInstance().Save(); Hide(); GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>().GetPanel(MenuName.ARENA).Show(); } else if (control == weaponScroller) { int index = (int)wparam; //scroller at if (command == (int)UIImageScroller.Command.ScrollSelect) { currentSelectionWeaponIndex = gameState.GetWeaponByOwnedIndex(index); UpdateWeaponInfo(); } // long press else if (command == (int)UIImageScroller.Command.PressSelect) { if (gameState != null) { Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3"); Rect rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(currentSelectionWeaponIndex); selectionImage.SetTexture(weaponIconMaterial, rect, AutoRect.AutoSize(rect)); selectionImage.Rect = weaponScroller.GetCenterRect(); } } //long end else if (command == (int)UIImageScroller.Command.PressEnd) { selectionImage.Rect = new Rect(-1000, -1000, 200, 200); for (int i = 0; i < SELECTION_NUM; i++) { if (selectionRect[i].Contains(new Vector2(wparam, lparam))) { SelectWeapon(currentSelectionWeaponIndex, i); break; } } } //drag move else if (command == (int)UIImageScroller.Command.DragMove) { selectionImage.Rect = new Rect(wparam - 438 * 1.2f / 2, lparam - 192 * 1.2f / 2, 438 * 1.2f, 192 * 1.2f); } } else if (control == battleWeaponGrid) { if (command == (int)UIDragGrid.Command.DragOutSide) { int i = (int)wparam; if (InBattleWeaponCount() > 1) { int weaponID = rectToWeaponMap[i]; if (weaponID != -1) { weaponList[weaponID].IsSelectedForBattle = false; rectToWeaponMap[i] = -1; battleWeaponGrid.HideGridTexture(i); avatarFrame.ChangeAvatar(GameApp.GetInstance().GetGameState().Avatar); } } else { battleWeaponGrid.SetGridTexturePosition(i, i); } } else if (command == (int)UIDragGrid.Command.DragExchange) { int i = (int)wparam; int j = (int)lparam; int temp = rectToWeaponMap[i]; rectToWeaponMap[i] = rectToWeaponMap[j]; rectToWeaponMap[j] = temp; if (rectToWeaponMap[i] != -1) { Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3"); Rect rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(rectToWeaponMap[i]); battleWeaponGrid.SetGridTexture(i, weaponIconMaterial, rect); battleWeaponGrid.SetGridTexturePosition(i, i); } else { battleWeaponGrid.HideGridTexture(i); } if (rectToWeaponMap[j] != -1) { Material weaponIconMaterial = UIResourceMgr.GetInstance().GetMaterial("Weapons3"); Rect rect = WeaponsLogoTexturePosition.GetWeaponIconTextureRect(rectToWeaponMap[j]); battleWeaponGrid.SetGridTexture(j, weaponIconMaterial, rect); battleWeaponGrid.SetGridTexturePosition(j, j); } else { battleWeaponGrid.HideGridTexture(j); } avatarFrame.ChangeAvatar(GameApp.GetInstance().GetGameState().Avatar); } } else if (control == getMoreMoneyButton) { AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().GetComponent <AudioSource>()); Hide(); ShopUI shopUI = GameObject.Find("ArenaMenuUI").GetComponent <ArenaMenuUI>().GetPanel(MenuName.SHOP) as ShopUI; shopUI.SetFromPanel(this); shopUI.Show(); } }
public void HandleEvent(UIControl control, int command, float wparam, float lparam) { if (BattlePressed) { return; } if (control == upgradeButton) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button"); //AudioPlayer.PlayAudio(ArenaMenuUI.GetInstance().audio); Hide(); ui.GetPanel(MenuName.UPGRADE).Show(); } else if (control == equipmentButton) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button"); Hide(); ui.GetPanel(MenuName.EQUIPMENT).Show(); } else if (control == battleButton) { BattlePressed = true; //GameObject.Find("Music").audio.Stop(); //GameObject.Destroy(GameObject.Find("Music")); //ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Battle"); FadeAnimationScript.GetInstance().FadeInBlack(0.3f); fadeTimer.Name = "Continue"; fadeTimer.SetTimer(0.3f, false); GameApp.GetInstance().Save(); } else if (control == avatarButton) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button"); Hide(); ui.GetPanel(MenuName.AVATAR).Show(); } else if (control == optionsButton) { //this.Hide(); //ui.GetPanel(MenuName.OPTIONS).Show(); //ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button"); } else if (control == returnButton) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button"); FadeAnimationScript.GetInstance().FadeInBlack(); fadeTimer.Name = "StartMenu"; fadeTimer.SetTimer(2f, false); } else if (control == leaderButton) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button"); GameCenterInterface.OpenLeaderboard(); /* * if (GameCenterInterface.IsLogin()) * { * GameCenterInterface.OpenLeaderboard(); * } * else * { * GameCenterInterface.Login(); * } */ } else if (control == achieveButton) { ArenaMenuUI.GetInstance().GetAudioPlayer().PlayAudio("Button"); GameCenterInterface.OpenAchievement(); /* * if (GameCenterInterface.IsLogin()) * { * GameCenterInterface.OpenAchievement(); * } * else * { * GameCenterInterface.Login(); * } */ } }