public CashPanel() { Material arenaMaterial = UIResourceMgr.GetInstance().GetMaterial("ArenaMenu"); WeaponUpgradeUIPosition uiPos = new WeaponUpgradeUIPosition(); backPanel = new UITextImage(); backPanel.SetTexture(arenaMaterial, ArenaMenuTexturePosition.CashPanel, AutoRect.AutoSize(ArenaMenuTexturePosition.CashPanel)); backPanel.Rect = AutoRect.AutoPos(uiPos.CashPanel); costPanel = new UITextImage(); costPanel.SetTexture(arenaMaterial, ArenaMenuTexturePosition.CashPanel, AutoRect.AutoSize(ArenaMenuTexturePosition.CashPanel)); costPanel.Rect = AutoRect.AutoPos(uiPos.CostPanel); cashText = new UIText(); cashText.Set(ConstData.FONT_NAME2, "", ColorName.fontColor_darkorange); cashText.AlignStyle = UIText.enAlignStyle.left; cashText.Rect = AutoRect.AutoPos(new Rect(uiPos.CashPanel.x + 40, uiPos.CashPanel.y, uiPos.CashPanel.width * 0.6f, uiPos.CashPanel.height - 10)); costText = new UIText(); costText.Set(ConstData.FONT_NAME2, "", ColorName.fontColor_red); costText.AlignStyle = UIText.enAlignStyle.center; costText.Rect = AutoRect.AutoPos(new Rect(uiPos.CostPanel.x + 40, uiPos.CostPanel.y, uiPos.CostPanel.width * 0.6f, uiPos.CostPanel.height - 10)); costPanel.Visible = false; costPanel.Enable = false; this.Add(backPanel); this.Add(costPanel); this.Add(cashText); this.Add(costText); }
public void SetCostPanelPosition(Rect pos) { WeaponUpgradeUIPosition uiPos = new WeaponUpgradeUIPosition(); uiPos.CostPanel = pos; costPanel.Rect = AutoRect.AutoPos(uiPos.CostPanel); costText.Rect = AutoRect.AutoPos(new Rect(uiPos.CostPanel.x + 40, uiPos.CostPanel.y, uiPos.CostPanel.width * 0.6f, uiPos.CostPanel.height - 10)); }
// Use this for initialization public WeaponUpgradeUI() { uiPos = new WeaponUpgradeUIPosition(); GameApp.GetInstance().Init(); gameState = GameApp.GetInstance().GetGameState(); currentWeaponIndex = -1; selectedWeapon = null; weaponList = GameApp.GetInstance().GetGameState().GetWeapons(); arenaMaterial = UIResourceMgr.GetInstance().GetMaterial("ArenaMenu"); background = new UIImage(); background.SetTexture(arenaMaterial, ArenaMenuTexturePosition.Background, AutoRect.AutoSize(ArenaMenuTexturePosition.Background)); background.Rect = AutoRect.AutoPos(uiPos.Background); for (int i = 0; i < 4; i++) { upgradePanels[i] = new UpgradePanel(new Rect(500, 465 - i * 100, 424, 108), i); upgradePanels[i].Show(); } upgradePanels[0].SetButtonText("DAMAGE"); upgradePanels[1].SetButtonText("FIRE RATE"); upgradePanels[2].SetButtonText("ACCURACY"); upgradePanels[3].SetButtonText("AMMO"); returnButton = new UIClickButton(); returnButton.SetTexture(UIButtonBase.State.Normal, arenaMaterial, ArenaMenuTexturePosition.ReturnButtonNormal, AutoRect.AutoSize(ArenaMenuTexturePosition.ReturnButtonNormal)); returnButton.SetTexture(UIButtonBase.State.Pressed, arenaMaterial, ArenaMenuTexturePosition.ReturnButtonPressed, AutoRect.AutoSize(ArenaMenuTexturePosition.ReturnButtonPressed)); returnButton.Rect = AutoRect.AutoPos(uiPos.ReturnButton); Material buttonsMaterial = UIResourceMgr.GetInstance().GetMaterial("Buttons"); upgradeButton = new UITextButton(); upgradeButton.SetTexture(UIButtonBase.State.Normal, buttonsMaterial, ButtonsTexturePosition.ButtonNormal, AutoRect.AutoSize(ButtonsTexturePosition.ButtonNormal)); upgradeButton.SetTexture(UIButtonBase.State.Pressed, buttonsMaterial, ButtonsTexturePosition.ButtonPressed, AutoRect.AutoSize(ButtonsTexturePosition.ButtonPressed)); upgradeButton.Rect = AutoRect.AutoPos(uiPos.UpgradeButton); getMoreMoneyButton = new UITextButton(); getMoreMoneyButton.SetTexture(UIButtonBase.State.Normal, arenaMaterial, ArenaMenuTexturePosition.GetMoneyButtonNormal, AutoRect.AutoSize(ArenaMenuTexturePosition.GetMoneyButtonSmallSize)); getMoreMoneyButton.SetTexture(UIButtonBase.State.Pressed, arenaMaterial, ArenaMenuTexturePosition.GetMoneyButtonPressed, AutoRect.AutoSize(ArenaMenuTexturePosition.GetMoneyButtonSmallSize)); getMoreMoneyButton.Rect = AutoRect.AutoPos(uiPos.GetMoreMoneyButton); cashPanel = new CashPanel(); upgradeButton.SetText(ConstData.FONT_NAME0, " UPGRADE", ColorName.fontColor_orange); UpdateWeaponInfo(); InitSelection(); this.Add(background); this.Add(returnButton); this.Add(getMoreMoneyButton); this.Add(upgradeButton); for (int i = 0; i < 4; i++) { this.Add(upgradePanels[i]); } weaponUI = UIResourceMgr.GetInstance().GetMaterial("Weapons"); weaponUI2 = UIResourceMgr.GetInstance().GetMaterial("Weapons2"); weaponScroller = new UIImageScroller(AutoRect.AutoPos(new Rect(0, 0, 500, 640)), AutoRect.AutoPos(new Rect(10, 120, 500, 440)), 1, AutoRect.AutoSize(WeaponsLogoTexturePosition.WeaponLogoSize), ScrollerDir.Vertical, true); weaponScroller.SetImageSpacing(AutoRect.AutoSize(WeaponsLogoTexturePosition.WeaponLogoSpacing)); Material shopMaterial = UIResourceMgr.GetInstance().GetMaterial("ShopUI"); Material avatarMaterial = UIResourceMgr.GetInstance().GetMaterial("Avatar"); weaponScroller.SetCenterFrameTexture(avatarMaterial, AvatarTexturePosition.Frame); weaponScroller.AddOverlay(shopMaterial, ShopTexturePosition.LockedLogo); weaponScroller.AddOverlay(shopMaterial, ShopTexturePosition.BuyLogo); UIImage uiImage = new UIImage(); TexturePosInfo info = WeaponsLogoTexturePosition.GetWeaponTextureRect(weaponList.Count); uiImage.SetTexture(info.m_Material, info.m_TexRect, AutoRect.AutoSize(info.m_TexRect)); uiImage.Rect = info.m_TexRect; weaponScroller.Add(uiImage); for (int i = 0; i < weaponList.Count; i++) { uiImage = new UIImage(); info = WeaponsLogoTexturePosition.GetWeaponTextureRect(i); uiImage.SetTexture(info.m_Material, info.m_TexRect, AutoRect.AutoSize(info.m_TexRect)); uiImage.Rect = info.m_TexRect; weaponScroller.Add(uiImage); } this.Add(weaponScroller); weaponScroller.EnableScroll(); this.Add(cashPanel); for (int i = 0; i < weaponList.Count; i++) { if (weaponList[i].Exist == WeaponExistState.Locked) { weaponScroller.SetOverlay(i + 1, 0); } else if (weaponList[i].Exist == WeaponExistState.Unlocked) { weaponScroller.SetOverlay(i + 1, 1); } } Material avatarLogoMaterial = UIResourceMgr.GetInstance().GetMaterial("Avatar"); weaponScroller.SetMaskImage(avatarLogoMaterial, AvatarTexturePosition.Mask); weaponScroller.Show(); iapDialog = new IAPDialog(UIDialog.DialogMode.YES_OR_NO); iapDialog.SetDialogEventHandler(this); this.Add(iapDialog); cashPanel.Show(); SetUIHandler(this); uiInited = true; Hide(); }