public void Configure(string message, Popup parent, float parentBottom, float duration = 5) { Parent = parent; Text text = transform.Find("Text").GetComponent <Text>(); text.text = message; MaxLife = duration; ParentBottom = parentBottom; Height = text.preferredHeight + Border * 2f; RectTransformExtensions.SetHeight(((RectTransform)transform), Height); float lastPopupBottom = ParentBottom; if (parent.Popups.Count > 0) { GameObject lastPopup = parent.Popups[parent.Popups.Count - 1]; RectTransform rectTrans = (RectTransform)lastPopup.transform; lastPopupBottom = rectTrans.localPosition.y - rectTrans.rect.height / 2f; } BoxCollider2D collider = this.GetComponent <BoxCollider2D>(); collider.size = new Vector3(collider.size.x, Height + Border); transform.localPosition = new Vector3(0, lastPopupBottom - (Height + Border * 5f) / 2f, 0); //return transform.localPosition.y - Height / 2f; }
public void OnShoot(Player p, float speedMod, float targetSize, float startOffset, float endOffset) { speed = BASE_SPEED * speedMod; m_startOffset = startOffset; m_endOffset = endOffset; RectTransformExtensions.SetHeight(m_rectTrans, 0.0f); target.rectTransform.localPosition = GetBarPosition(endOffset); RectTransformExtensions.SetHeight(target.rectTransform, BASE_TARGET + targetSize); meter.SetActive(true); m_isShooting = true; //StartCoroutine(ShootingTimeout()); }
private void Update() { if (m_isShooting) { m_timer += speed * Time.deltaTime; RectTransformExtensions.SetHeight(m_rectTrans, m_timer); // Overflowed bar => Failed shot + disable if (RectTransformExtensions.GetHeight(m_rectTrans) >= m_height) { StopShooting(); StartCoroutine(Hide(1.0f)); print("failed"); } } }
void CreateHud(bool Player1, PlayerType car) { Transform Hud = (Transform)Instantiate(HudPreFab); Hud.SetParent(this.gameObject.transform, false); RectTransform pos = Hud.gameObject.GetComponent <RectTransform>(); RectTransformExtensions.SetPositionOfPivot(pos, new Vector2(0, Player1 ? Screen.height / 2 : 0)); RectTransformExtensions.SetHeight(pos, Screen.height / 2); AmmoStorage storage = car.gameObject.GetComponentInChildren <AmmoStorage>(); Hud.GetComponentInChildren <AmmoDisplay>().SetAmmoStorage(storage); Hud.GetComponentInChildren <ScoreDisplay>().SetAmmoStorage(storage); }
public void RecalculateLayout() { int i = 0; int count = ChildViews.Count; float menuHeight = Mathf.Max(ChildViewHeight * count, IsInScrollRect ? ParentHeight : 0); float startHeight = menuHeight / 2 - ChildViewHeight / 2; //Debug.Log("ParentHeight: " + ParentHeight); //Debug.Log("menuHeight: " + menuHeight); //Debug.Log("startHeight: " + startHeight); RectTransformExtensions.SetHeight((RectTransform)transform, menuHeight); foreach (var view in ChildViews) { ((RectTransform)view.transform).localPosition = new Vector3(0, startHeight - ChildViewHeight * i, 0); i++; } }
protected override void onPreShow([Optional, DefaultParameterValue(null)] object param) { this.m_inputParameters = (InputParameters)param; if (!string.IsNullOrEmpty(this.m_inputParameters.Headline)) { this.HeaderTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Headline); this.HeaderTitle.enabled = true; } else { this.HeaderTitle.enabled = false; } if (!string.IsNullOrEmpty(this.m_inputParameters.Title)) { this.DividerRoot.SetActive(true); this.DividerTitle.enabled = true; this.DividerTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Title); } else { this.DividerRoot.SetActive(false); this.DividerTitle.enabled = false; } if (!string.IsNullOrEmpty(this.m_inputParameters.Message)) { this.MessageText.enabled = true; this.MessageText.text = this.m_inputParameters.Message; } else { this.MessageText.enabled = false; } if (this.m_inputParameters.CostAmount > 0.0) { this.Button.SetActive(true); this.ButtonIcon.gameObject.SetActive(true); this.ButtonText.text = MenuHelpers.BigValueToString(Math.Round(this.m_inputParameters.CostAmount)); this.SetIconForResource(ref this.ButtonIcon, this.m_inputParameters.CostResourceType); } else if (!string.IsNullOrEmpty(this.m_inputParameters.ButtonText)) { this.Button.SetActive(true); this.ButtonIcon.gameObject.SetActive(false); this.ButtonText.text = this.m_inputParameters.ButtonText; if (this.m_inputParameters.ButtonIcon != null) { Sprite iconForSprite = this.GetIconForSprite(this.m_inputParameters.ButtonIcon); if (iconForSprite != null) { this.ButtonIcon.gameObject.SetActive(true); this.ButtonIcon.sprite = iconForSprite; } } } else { this.Button.SetActive(false); } if (this.m_inputParameters.DisposableBackgroundTexture != null) { this.RawBg.enabled = true; this.RawBg.texture = this.m_inputParameters.DisposableBackgroundTexture; float num = ((float)this.m_inputParameters.DisposableBackgroundTexture.width) / ((float)this.m_inputParameters.DisposableBackgroundTexture.height); float newSize = Mathf.Clamp((float)(this.m_defaultWidth / num), (float)200f, (float)1880f); RectTransformExtensions.SetHeight(base.RectTm, newSize); base.RewardsGrid.gameObject.SetActive(false); } else { this.RawBg.enabled = false; RectTransformExtensions.SetHeight(base.RectTm, this.m_defaultHeight); List <Reward> rewards = Service.Binder.PromotionManager.GetRewards(this.m_inputParameters.Promotion); if ((rewards != null) && (rewards.Count > 0)) { base.RewardsGrid.gameObject.SetActive(true); base.InitRewardGrid(rewards); } else { base.RewardsGrid.gameObject.SetActive(false); } } }
protected override void onPreShow([Optional, DefaultParameterValue(null)] object param) { this.m_inputParameters = (InputParameters)param; if (!string.IsNullOrEmpty(this.m_inputParameters.Headline)) { this.PopupTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Headline); } else { this.PopupTitle.enabled = false; } if (!string.IsNullOrEmpty(this.m_inputParameters.Title)) { this.DividerTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Title); } else { this.DividerTitle.enabled = false; } if (!string.IsNullOrEmpty(this.m_inputParameters.Message)) { this.DescriptionText.enabled = true; this.DescriptionText.text = this.m_inputParameters.Message; } else { this.DescriptionText.enabled = false; } if (this.m_inputParameters.DisposableBackgroundTexture != null) { this.RawBg.enabled = true; this.RawBg.texture = this.m_inputParameters.DisposableBackgroundTexture; float num = ((float)this.m_inputParameters.DisposableBackgroundTexture.width) / ((float)this.m_inputParameters.DisposableBackgroundTexture.height); float newSize = Mathf.Clamp((float)(this.m_defaultWidth / num), (float)200f, (float)1880f); RectTransformExtensions.SetHeight(base.RectTm, newSize); } else { this.RawBg.enabled = false; RectTransformExtensions.SetHeight(base.RectTm, this.m_defaultHeight); } string flareProductIdForPromoSlot = Service.Binder.PromotionManager.GetFlareProductIdForPromoSlot(this.m_inputParameters.Slot); if (!string.IsNullOrEmpty(flareProductIdForPromoSlot)) { ShopEntry shopEntryByFlareProductId = Service.Binder.ShopManager.GetShopEntryByFlareProductId(flareProductIdForPromoSlot); if (shopEntryByFlareProductId != null) { this.m_purchaseController = new ShopPurchaseController(shopEntryByFlareProductId, null, PathToShopType.Vendor, null, new Action <ShopEntry, PurchaseResult>(this.onPurchaseComplete)); this.PurchaseButtonText.text = this.m_purchaseController.getPriceText(1); if (this.m_inputParameters.DisposableBackgroundTexture == null) { base.RewardsGrid.gameObject.SetActive(true); List <Reward> rewards = new List <Reward>(); PremiumProduct prod = Service.Binder.ShopService.GetProduct(flareProductIdForPromoSlot); foreach (ProductReward reward in ConfigShops.GetRewardsFromProduct(prod)) { rewards.Add(ConfigShops.GetRewardFromProductReward(reward, prod)); } base.InitRewardGrid(rewards); } else { base.RewardsGrid.gameObject.SetActive(false); } } } }
protected override void onPreShow([Optional, DefaultParameterValue(null)] object param) { this.m_inputParameters = (InputParameters)param; if (!string.IsNullOrEmpty(this.m_inputParameters.Headline)) { this.HeaderTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Headline); } else { this.HeaderTitle.text = StringExtensions.ToUpperLoca(_.L(ConfigLoca.APPBOY_POPUP_HEADER, null, false)); } if (!string.IsNullOrEmpty(this.m_inputParameters.Title)) { this.DividerRoot.SetActive(true); this.DividerTitle.text = StringExtensions.ToUpperLoca(this.m_inputParameters.Title); } else { this.DividerRoot.SetActive(false); } if (!string.IsNullOrEmpty(this.m_inputParameters.Message)) { this.MessageText.enabled = true; this.MessageText.text = this.m_inputParameters.Message; } else { this.MessageText.enabled = false; } if (!string.IsNullOrEmpty(this.m_inputParameters.SingleButtonText)) { this.SingleButton.SetActive(true); this.DualButtonRoot.SetActive(false); this.SingleButtonText.text = this.m_inputParameters.SingleButtonText; } else { this.SingleButton.gameObject.SetActive(false); if (!string.IsNullOrEmpty(this.m_inputParameters.DualButtonLeftText)) { this.DualButtonRoot.SetActive(true); this.DualButtonLeftText.text = this.m_inputParameters.DualButtonLeftText; this.DualButtonRightText.text = this.m_inputParameters.DualButtonRightText; } else { this.DualButtonRoot.SetActive(false); } } if (this.m_inputParameters.DisposableIconTexture != null) { this.DefaultIcon.enabled = false; this.RawIcon.enabled = true; this.RawIcon.texture = this.m_inputParameters.DisposableIconTexture; } else { this.DefaultIcon.enabled = true; this.RawIcon.enabled = false; } if (this.m_inputParameters.DisposableBackgroundTexture != null) { this.RawBg.enabled = true; this.RawBg.texture = this.m_inputParameters.DisposableBackgroundTexture; float num = ((float)this.m_inputParameters.DisposableBackgroundTexture.width) / ((float)this.m_inputParameters.DisposableBackgroundTexture.height); float newSize = Mathf.Clamp((float)(this.m_defaultWidth / num), (float)200f, (float)1880f); RectTransformExtensions.SetHeight(base.RectTm, newSize); } else { this.RawBg.enabled = false; RectTransformExtensions.SetHeight(base.RectTm, this.m_defaultHeight); } PlayerView.Binder.EventBus.AppboyAction("message-displayed", this.m_inputParameters.CampaignId); }