Esempio n. 1
0
    void OnSlotPressed_ByIndex(int index)
    {
        if (index == -1)
        {
            return;
        }

        //check lock status
        if (GetSlot(index).m_Locked)
        {
            return;
        }

        GuiEquipSelection.Instance.m_OnEquipActionDelegate = OnEquipAction;

        ShopItemId selId = GetSlot(index).m_ItemId;

        if (!GuiEquipSelection.Instance.IsShown || GuiEquipSelection.Instance.GetCurrentSelection().ItemType != m_SlotItemType)
        {
            GuiEquipSelection.Instance.Show(m_SlotItemType, selId);
        }
        else
        {
            GuiEquipSelection.Instance.SetEquipedItem(selId);
        }

        GuiEquipMenu.Instance.SetSelectedSlot(m_SlotItemType, index);
        GuiEquipSelection.Instance.UpdateItemButtons();
    }
Esempio n. 2
0
    //Updatatuj vzhled modelu playera - skin hat, etc.
    //View index rika ktery model updatujeme - 0 good team, 1 bad team
    void UpdateOutfitView(bool forceShow = false)
    {
        //Debug.Log("UpdateOutfitView: visible " + IsVisible );
        if (IsVisible || forceShow)
        {
            ShopItemId skinId = m_SkinSlots.GetSlotItem(0);
            //Debug.Log("UpdateOutfitView: " + skinId);

            //should not be empty but check anyway
            if (!skinId.IsEmpty())
            {
                //show skin
                m_SkinModel.ShowSkin(skinId);

                //pri zmene skinu musime objevit model
                m_CapModel.HideActiveModel();
                m_GunModel.HideActiveModel();

                //show hat
                UpdateHatModel(forceShow);

                //show weapon
                UpdateWeaponModel(forceShow);
            }
        }
    }
Esempio n. 3
0
    public static void EarnFreeGold(ShopItemId goldId)
    {
        //Debug.Log("Earn Free gold " + goldId);
        if (!ShopDataBridge.Instance.IsFreeGold(goldId))
        {
            return;
        }

        E_FundID fundId = (E_FundID)(goldId.Id);

        if (fundId == E_FundID.TapJoyWeb)
        {
#if UNITY_IPHONE
            MFNativeUtils.OpenURLExternal(TAPJOY_DEADZONE_URL);             //Tapjoy has to be opened in external browser on iOS due to Apple's restrictions
#elif UNITY_ANDROID
            EtceteraWrapper.ShowWeb(TAPJOY_DEADZONE_URL);
#endif
        }
        else if (fundId == E_FundID.TapJoyInApp)
        {
            TapJoy.ShowOffers();
        }
        else if (fundId == E_FundID.FreeOffer)
        {
            // Used to be SponsorPay Plugin - now unused
        }
        else if (fundId == E_FundID.FreeWeb)
        {
#if (UNITY_ANDROID || UNITY_IPHONE)
            //SponsorPay plugin has been removed in r16601
//			string sponsorPayStr = string.Format("http://iframe.sponsorpay.com/mbrowser?appid={0}&device_id={1}&uid={2}&pub0=", Game.SponsorPayCredentials.AppId, SysUtils.GetUniqueDeviceID(), CloudUser.instance.userName);
//			EtceteraWrapper.ShowWeb(sponsorPayStr);
#endif
        }
    }
Esempio n. 4
0
    void DelayedShow()
    {
        SyncSlots();

        UpdateAllViews();

        UpdateOutfitView(true);
        GuiEquipSelection.Instance.UpdateScroller();

        //TODO_DT: integrovat do GuiEquipMenu!
        //GuiEquipSelection uz by nemel byt singleton a nejspis by nemusel byt ani samostatna trida. Touch na Equip slotech by mel primarne take chodit do Equip menu a ne do EquipSlots, kod by se tak mohl vyrazne zjednodusit.
        ShopItemId lastItem = GuiEquipSelection.Instance.LastSelectedItem;

        if (IsSlotLocked(SelectedSlotType, SelectedSlotIndex))
        {
            SelectedSlotType  = GuiShop.E_ItemType.Weapon;
            SelectedSlotIndex = 0;
        }

        SelectSlot(SelectedSlotType, SelectedSlotIndex);
        if (lastItem != ShopItemId.EmptyId)
        {
            GuiEquipSelection.Instance.SelectItem(lastItem);
        }

        //Flurry.logEvent(AnalyticsTag.Equip, true);

        if (m_MessageBox != null)
        {
            m_MessageBox.ForceClose();
            m_MessageBox = null;
        }
        FixEquipList();
    }
Esempio n. 5
0
    // GUIVIEW INTERFACE
    protected override void OnViewInit()
    {
        //Debug.Log("OnViewInit");

        LastId = ShopItemId.EmptyId;
        m_SharedGui.InitGui(Layout);
    }
Esempio n. 6
0
    //just set id in slot, no visual or other update is done
    public void SetSlotParams(int index, ShopItemId itmId, bool locked, bool premium)
    {
        CSlot slot = GetSlot(index);

        slot.m_Locked      = locked;
        slot.m_ItemId      = itmId;
        slot.m_PremiumOnly = premium;
    }
Esempio n. 7
0
    bool m_EquipMenu;     //true if we are in equip menu scroller

    public GuiScrollItem(ShopItemId id, GUIBase_Widget w, bool equipMenu)
    {
        m_Widget    = w;
        m_Id        = id;
        m_EquipMenu = equipMenu;
        UpdateItemInfo();
        InitGui();
    }
Esempio n. 8
0
 void UpdateWeaponModel(bool forceShow = false)
 {
     if (IsVisible || forceShow)
     {
         ShopItemId gunId = m_WeaponSlots.GetSlotItem(m_LastWeaponSlot);
         m_GunModel.Show(gunId, m_SkinModel.GetWeaponHolderTransform());
     }
 }
Esempio n. 9
0
    protected override void OnViewUpdate()
    {
        base.OnViewUpdate();

        if (m_HACK_DelayedShowRemaining > 0)
        {
            m_HACK_DelayedShowRemaining -= 1;
            if (m_HACK_DelayedShowRemaining > 0)
            {
                return;
            }

            DelayedShow();
        }

        string     popupFooter;
        ShopItemId id = GetItemUnderMouse(out popupFooter);

        /*if(id.IsEmpty())
         * {
         *      Debug.Log("Hightlited item " +  "None");
         * }
         * else
         * {
         *      Debug.Log("Hightlited item " +  id.GetName());*/

        switch (id.ItemType)
        {
        case GuiShop.E_ItemType.Weapon:
            m_ItemDescription.SetItem(new PreviewItem((E_WeaponID)id.Id));
            m_ItemDescription.Key = popupFooter;
            m_ItemDescription.Show(true);
            break;

        case GuiShop.E_ItemType.Item:
            m_ItemDescription.SetItem(new PreviewItem((E_ItemID)id.Id));
            m_ItemDescription.Key = popupFooter;
            m_ItemDescription.Show(true);
            break;

        case GuiShop.E_ItemType.Perk:
            m_ItemDescription.SetItem(new PreviewItem((E_PerkID)id.Id));
            m_ItemDescription.Key = popupFooter;
            m_ItemDescription.Show(true);
            break;

        case GuiShop.E_ItemType.Upgrade:
            m_ItemDescription.SetItem(new PreviewItem((E_UpgradeID)id.Id));
            m_ItemDescription.Key = popupFooter;
            m_ItemDescription.Show(true);
            break;

        default:
            m_ItemDescription.Show(false);
            break;
        }
        //}
    }
Esempio n. 10
0
 void UpdateHatModel(bool forceShow = false)
 {
     if (IsVisible || forceShow)
     {
         //show hat
         ShopItemId capId = m_HatSlots.GetSlotItem(0);
         m_CapModel.Show(capId, m_SkinModel.GetActiveHeadTransform());
     }
 }
Esempio n. 11
0
    public void ScrollToItem(ShopItemId id)
    {
        if (id == null)
        {
            return;
        }

        m_ScrollInventory.ScrollToItem(id);
    }
Esempio n. 12
0
    //-----------------------------------------------------------------------------------------------------------------------------------------------------

    void UpdateCurrentPage(ShopItemId selItem, bool forceUpdateView)
    {
        GuiShopPageBase pageBase = CurrentPage as GuiShopPageBase;

        if (pageBase != null)
        {
            pageBase.OnItemChange(selItem, forceUpdateView);
        }
    }
Esempio n. 13
0
 void SyncItemsSlots()
 {
     for (int i = 0; i < maxItemsSlot; i++)
     {
         bool       locked  = ShopDataBridge.Instance.IsItemSlotLocked(i);
         bool       premium = ShopDataBridge.Instance.IsPremiumItemSlot(i);
         ShopItemId itmId   = ShopDataBridge.Instance.GetItemInSlot(i);
         m_ItemSlots.SetSlotParams(i, itmId, locked, premium);
     }
 }
Esempio n. 14
0
 void BuyResultHandler(GuiPopup inPopup, E_PopupResultCode inResult)
 {
     if (inResult == E_PopupResultCode.Success || inResult == E_PopupResultCode.Cancel)
     {
         //success
         ShopItemId selItem = m_ShopScroller.GetSelectedItem();
         UpdateBuyButton(selItem);
         UpdateCurrentPage(selItem, true);
     }
 }
Esempio n. 15
0
 public void HideSkin()
 {
     //hide previous skin
     if (m_ActiveModel != null)
     {
         RenderUtils.EnableRenderer(m_ActiveModel, false);
         m_ActiveModel = null;
     }
     m_ActiveId = ShopItemId.EmptyId;
 }
Esempio n. 16
0
    public void SetSelectedItem(ShopItemId id)
    {
        if (id == null)
        {
            return;
        }

        //Debug.Log("Set selected item: " + id);
        m_ScrollInventory.SetSelectedItem(id);
    }
Esempio n. 17
0
    public void ShowSkin(ShopItemId skinId)
    {
        //Debug.Log("ShowActiveModel begin:"  + skinId + " curr id " + m_ActiveId + " model: " + ((m_ActiveModel != null) ? m_ActiveModel.name : "none"));

        if (m_ActiveId == skinId)
        {
            return;
        }

        //hide previous skin
        HideSkin();

        if (skinId.IsEmpty())
        {
            return;
        }

        //store id
        m_ActiveId = skinId;

        m_ActiveModel = ShopDataBridge.Instance.GetOutfitModel(skinId);

        if (m_ActiveModel != null)
        {
            int HUDLayer = LayerMask.NameToLayer("HUD");

            RenderUtils.EnableRenderer(m_ActiveModel, true);

            Renderer[] renderers = m_ActiveModel.GetComponentsInChildren <Renderer>();

            foreach (Renderer r in renderers)
            {
                r.gameObject.layer = HUDLayer;
                r.useLightProbes   = false;
                r.material         = Object.Instantiate(r.material) as Material;
                r.material.SetFloat("_LightProbesLightingAmount", 0);
                r.material.SetVector("_FakeProbeTopColor", OutfitColors.m_PreviewColorGradTop);
                r.material.SetVector("_FakeProbeBotColor", OutfitColors.m_PreviewColorGradBot);
            }

            // prevent glitches caused by late update of animation - @see BUG #330  Character in A pose when player enters the equip section
            if (null != m_ActiveModel.GetComponent <Animation>())
            {
                m_ActiveModel.GetComponent <Animation>().Sample();
            }

            UpdatePos();
        }
        else
        {
            Debug.LogError("Failed to get model for skin: " + skinId.Id + " " + skinId.ItemType);
        }

        //Debug.Log("ShowActiveModel end "  + skinId + " curr id " + m_ActiveId + " model: " + ((m_ActiveModel != null) ? m_ActiveModel.name : "none"));
    }
Esempio n. 18
0
    void SyncWeaponsSlots()
    {
        for (int i = 0; i < maxWeaponSlot; i++)
        {
            bool       locked  = ShopDataBridge.Instance.IsWeaponSlotLocked(i);
            bool       premium = ShopDataBridge.Instance.IsPremiumWeaponSlot(i);
            ShopItemId itmId   = ShopDataBridge.Instance.GetWeaponInSlot(i);

            m_WeaponSlots.SetSlotParams(i, itmId, locked, premium);
        }
    }
Esempio n. 19
0
 public bool IsItemWaiting(ShopItemId itemId)
 {
     for (int i = 0; i < m_Items.Count; i++)
     {
         if (m_Items[i].m_ItemId.Id == itemId.Id)
         {
             return(IsSlotWaiting(i));
         }
     }
     return(false);
 }
Esempio n. 20
0
    // ------
    protected override void OnViewUpdate()
    {
        m_ResearchScroller.Update();

        base.OnViewUpdate();

        if (m_PopupItems == null || !IsEnabled)
        {
            m_ItemDescription.Show(false);
            return;
        }

        ShopItemId id = new ShopItemId();

        Vector3 input = Input.mousePosition;

        input.y = Screen.height - input.y;

        foreach (popupItem item in m_PopupItems)
        {
            if (item.area.Contains(input))
            {
                id = item.item;
                break;
            }
        }

        switch (id.ItemType)
        {
        case GuiShop.E_ItemType.Weapon:
            m_ItemDescription.SetItem(new PreviewItem((E_WeaponID)id.Id));
            m_ItemDescription.Show(true);
            break;

        case GuiShop.E_ItemType.Item:
            m_ItemDescription.SetItem(new PreviewItem((E_ItemID)id.Id));
            m_ItemDescription.Show(true);
            break;

        case GuiShop.E_ItemType.Perk:
            m_ItemDescription.SetItem(new PreviewItem((E_PerkID)id.Id));
            m_ItemDescription.Show(true);
            break;

        case GuiShop.E_ItemType.Upgrade:
            m_ItemDescription.SetItem(new PreviewItem((E_UpgradeID)id.Id));
            m_ItemDescription.Show(true);
            break;

        default:
            m_ItemDescription.Show(false);
            break;
        }
    }
Esempio n. 21
0
 public void SetEquipedItem(ShopItemId equipedId)
 {
     if (m_EquipedItem == equipedId && equipedId != ShopItemId.EmptyId)
     {
         ScrollToItem(m_EquipedItem);
     }
     else
     {
         m_EquipedItem = equipedId;
     }
     UpdateItemButtons();
 }
Esempio n. 22
0
    //-----------------------------------------------------------------------------------------------------------------------------------------------------
    void UpdateBuyButton(ShopItemId selItem)
    {
        //texty v db
        const int textBuy     = 02030020;
        const int textConvert = 02030040;
        const int textOwned   = 02030054;
        const int textEarn    = 02030058;
        const int textLocked  = 02030053;

        // this will displays status bar hints if needed
        ShopDataBridge.Instance.HaveEnoughMoney(selItem, -1);

        //pro veci ktere uz mame zakaz buy
        ShopItemInfo inf = ShopDataBridge.Instance.GetItemInfo(selItem);

        if (inf.PremiumOnly && inf.Locked)
        {
            m_BuyButton.Widget.Show(false, true);
            m_Buy_Premium_Button.Widget.Show(true, true);
        }
        else
        {
            m_BuyButton.Widget.Show(true, true);
            m_Buy_Premium_Button.Widget.Show(false, true);
            m_BuyButton.SetDisabled(inf.Owned && !inf.Consumable || inf.Locked);
        }

        //zobraz vhodny label:
        int textId = textBuy;

        if (inf.Owned && !inf.Consumable)
        {
            textId = textOwned;
        }
        else if (ShopDataBridge.Instance.IsFreeGold(selItem))
        {
            textId = textEarn;
        }
        else if (ShopDataBridge.Instance.IsFundConvertor(selItem))
        {
            textId = textConvert;
        }
        else if (inf.Locked)
        {
            textId = textLocked;
        }
        else
        {
            textId = textBuy;
        }

        m_Buy_Button_Label.SetNewText(textId);
    }
Esempio n. 23
0
    IEnumerator DoUpgradeCoroutine(int upgradeIndex)
    {
        WeaponSettings.Upgrade upgrade = m_ResearchItem.GetUpgrade(upgradeIndex);
        if (upgrade.GoldCost > 0 && ResearchSupport.Instance.HasPlayerEnoughFunds(upgrade.GoldCost, true) == false)
        {
            ShopItemId desired = new ShopItemId((int)upgrade.ParentID, GuiShop.E_ItemType.Weapon);
            ShopItemId reqIAP  = ShopDataBridge.Instance.GetIAPNeededForItem(desired, upgradeIndex);

            if (reqIAP.IsEmpty())
            {
                yield break;
            }

            bool buySucceed = true;
            GuiShopNotFundsPopup.Instance.AddFundsID = reqIAP;
            GuiPopup popup = Owner.ShowPopup("NotFundsPopup",
                                             "",
                                             "",
                                             (inPopup, inResult) =>
            {
                switch (inResult)
                {
                case E_PopupResultCode.Cancel:
                    buySucceed = false;
                    break;

                case E_PopupResultCode.Failed:
                    buySucceed = false;
                    break;
                }
            });

            //Debug.Log("Popup Visible:" + popup.IsVisible);
            while (popup.IsVisible == true)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (buySucceed == false)
            {
                yield break;
            }

            //Debug.Log("IAP success:" + buySucceed);
        }

        if (ResearchSupport.Instance.HasPlayerEnoughFunds(upgrade.GoldCost, true))
        {
            GuiPopupDoUpgrade popik = Owner.ShowPopup("DoUpgrade", "", "", DoUpgradeResultHandler) as GuiPopupDoUpgrade;
            popik.SetItem(m_ResearchItem, upgradeIndex);
        }
    }
Esempio n. 24
0
    // SPOLECNY ITERFACE PRO VSECHNY PAGE
    public override void OnItemChange(ShopItemId bundleId, bool forceUpdateView)
    {
        base.OnItemChange(bundleId, forceUpdateView);

        if (bundleId.IsEmpty())
        {
            //hide icons
            foreach (BundleGui bg in m_BundleGui)
            {
                bg.Root.Show(false, true);
            }
        }

        //show all items in the bundle and hide the rest of the icons
        ShopItemInfo bundleInf = ShopDataBridge.Instance.GetItemInfo(bundleId);

        for (int i = 0; i < MAX_BUNDLE_ITEMS; i++)
        {
            BundleGui bg = m_BundleGui[i];
            if (bg.Root == null)
            {
                continue;
            }

            //do we have an item on this index?
            if (i < bundleInf.BundleItems.Count)
            {
                //get info about bundle item
                ShopItemId   id       = bundleInf.BundleItems[i];
                ShopItemInfo itemInfo = ShopDataBridge.Instance.GetItemInfo(id);
                bg.Root.Show(true, false);
                bg.Label.SetNewText(itemInfo.NameText);
                bg.Label.Widget.Show(true, true);
                bg.Owned.Widget.Show(itemInfo.Owned, true);

                //sprite
                GUIBase_Sprite newSprite = GuiBaseUtils.GetChildSprite(bg.Root, ThumbName(id.ItemType));
                if (bg.Sprite != newSprite)
                {
                    bg.Sprite.Widget.Show(false, true);
                    bg.Sprite = newSprite;
                }

                bg.Sprite.Widget.CopyMaterialSettings(itemInfo.ScrollerWidget ? itemInfo.ScrollerWidget : itemInfo.SpriteWidget);
                bg.Sprite.Widget.Show(true, true);
            }
            else
            {
                bg.Root.Show(false, true);
            }
        }
    }
Esempio n. 25
0
    ShopItemId GetItemUnderMouse(out string popupFooter)
    {
        popupFooter = null;
        int slotIndex;

        //check if mouse is over scroller
        ShopItemId id = GuiEquipSelection.Instance.GetItemOverMouse();

        if (id.ItemType != GuiShop.E_ItemType.None)
        {
            return(id);
        }
        //not over scroller, check perks
        id = m_PerkSlots.GetItemOverMouse(out slotIndex);
        if (id.ItemType != GuiShop.E_ItemType.None)
        {
            string keyString = GetUseKeyString(PlayerControlsGamepad.E_Input.Sprint);
            if (!string.IsNullOrEmpty(keyString))
            {
                popupFooter = TextDatabase.instance[02020002] + ": " + keyString;
            }
            return(id);
        }
        //not over perks, check usable items
        id = m_ItemSlots.GetItemOverMouse(out slotIndex);
        if (id.ItemType != GuiShop.E_ItemType.None)
        {
            PlayerControlsGamepad.E_Input command;
            if (slotIndex == 0)
            {
                command = PlayerControlsGamepad.E_Input.Item1;
            }
            else if (slotIndex == 1)
            {
                command = PlayerControlsGamepad.E_Input.Item2;
            }
            else
            {
                command = PlayerControlsGamepad.E_Input.Item3;
            }
            string keyString = GetUseKeyString(command);
            if (!string.IsNullOrEmpty(keyString))
            {
                popupFooter = TextDatabase.instance[02020002] + ": " + keyString;
            }
            return(id);
        }
        //not over usable items, check weapon slots
        id = m_WeaponSlots.GetItemOverMouse(out slotIndex);

        return(id);
    }
Esempio n. 26
0
 public void HideActiveModel()
 {
     //Debug.Log("HideActiveModel " +  ((m_ActiveModel != null) ? m_ActiveModel.name : "none"));
     if (m_ActiveModel != null)
     {
         m_ActiveModel.transform.parent = null;
         RenderUtils.EnableRenderer(m_ActiveModel, false);
         //destroy model
         Object.Destroy(m_ActiveModel);
         m_ActiveModel = null;
     }
     m_ActiveId = ShopItemId.EmptyId;
 }
Esempio n. 27
0
    void OnSelectionChange(ShopItemId selItem)
    {
        if (!IsVisible || !IsEnabled)
        {
            return;
        }

        //Update buy button
        UpdateBuyButton(selItem);

        //update info about item
        UpdateCurrentPage(selItem, false);
    }
Esempio n. 28
0
    //--------------------------------------

    void OnBuyPremiumButton(bool inside)
    {
        if (!inside)
        {
            return;
        }

        ShopItemId selId = m_ShopScroller.GetSelectedItem();

        if (ShopDataBridge.Instance.GetItemInfo(selId).PremiumOnly)
        {
            Owner.ShowPopup("PremiumAccount", null, null, null);
        }
    }
Esempio n. 29
0
    IEnumerator BuyCoroutine(ShopItemId selId)
    {
        if (!ShopDataBridge.Instance.HaveEnoughMoney(selId, -1))
        {
            ShopItemId reqIAP = ShopDataBridge.Instance.GetIAPNeededForItem(selId, -1);

            if (reqIAP.IsEmpty())
            {
                yield break;
            }

            bool buySucceed = true;
            GuiShopNotFundsPopup.Instance.AddFundsID = reqIAP;
            GuiPopup popup = Owner.ShowPopup("NotFundsPopup",
                                             "",
                                             "",
                                             (inPopup, inResult) =>
            {
                switch (inResult)
                {
                case E_PopupResultCode.Cancel:
                    buySucceed = false;
                    break;

                case E_PopupResultCode.Failed:
                    buySucceed = false;
                    break;
                }
            });

            //Debug.Log("Popup Visible:" + popup.IsVisible);
            while (popup.IsVisible == true)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (buySucceed == false)
            {
                yield break;
            }
            //Debug.Log("IAP success:" + buySucceed);
        }

        if (ShopDataBridge.Instance.HaveEnoughMoney(selId, -1))
        {
            //show buy confirm dialog
            GuiShopBuyPopup.Instance.SetBuyItem(selId);
            Owner.ShowPopup("ShopBuyPopup", "", "", BuyResultHandler);
        }
    }
Esempio n. 30
0
    void Awake()
    {
        if (Instance != null)
        {
            Object.Destroy(Instance);
            Instance = null;
        }
        Instance        = this;
        m_IsInitialized = false;
        IsShown         = false;

        m_ItemScroller = new GuiShopItemScroller(ScrollBarPrefab);
        //m_ItemScroller.m_DebugName = "Equip scroller";
        LastSelectedItem = ShopItemId.EmptyId;
    }