Beispiel #1
0
 private void AutomaticallyOpenPack()
 {
     if (this.CanOpenPackAutomatically())
     {
         this.HideUnopenedPackTooltip();
         UnopenedPack pack = null;
         if (!this.m_unopenedPacks.TryGetValue(this.m_lastOpenedBoosterId, out pack) || (pack.GetBoosterStack().Count == 0))
         {
             foreach (KeyValuePair <int, UnopenedPack> pair in this.m_unopenedPacks)
             {
                 if ((pair.Value != null) && (pair.Value.GetBoosterStack().Count > 0))
                 {
                     pack = pair.Value;
                     break;
                 }
             }
         }
         if ((pack != null) && pack.CanOpenPack())
         {
             this.m_draggedPack = pack.AcquireDraggedPack();
             this.PickUpBooster();
             pack.StopAlert();
             this.OpenBooster(this.m_draggedPack);
             this.DestroyDraggedPack();
             this.UpdateUIEvents();
             this.m_DragPlane.SetActive(false);
         }
     }
 }
 private void OnDragStopSpellStateFinished(Spell spell, SpellStateType prevStateType, object userData)
 {
     if (spell.GetActiveState() == SpellStateType.NONE)
     {
         UnopenedPack pack = (UnopenedPack)userData;
         UnityEngine.Object.Destroy(pack.gameObject);
     }
 }
 private void OnUnopenedPackPrefabLoaded(string name, GameObject go, object callbackData)
 {
     go.transform.parent     = this.m_BoosterPackBone.transform.parent;
     go.transform.position   = this.m_BoosterPackBone.transform.position;
     go.transform.rotation   = this.m_BoosterPackBone.transform.rotation;
     go.transform.localScale = this.m_BoosterPackBone.transform.localScale;
     this.m_unopenedPack     = go.GetComponent <UnopenedPack>();
     this.UpdatePackStacks();
     base.SetReady(true);
 }
 public void ReleaseDraggedPack()
 {
     if (this.m_draggedPack != null)
     {
         UnopenedPack draggedPack = this.m_draggedPack;
         this.m_draggedPack = null;
         draggedPack.m_DragStopEvent.AddStateFinishedCallback(new Spell.StateFinishedCallback(this.OnDragStopSpellStateFinished), draggedPack);
         draggedPack.m_DragStopEvent.Activate();
         this.UpdateState();
     }
 }
Beispiel #5
0
    private void CreateDraggedPack(UnopenedPack creatorPack)
    {
        RaycastHit hit;

        this.m_draggedPack = creatorPack.AcquireDraggedPack();
        Vector3 position = this.m_draggedPack.transform.position;

        if (UniversalInputManager.Get().GetInputHitInfo(GameLayer.DragPlane.LayerBit(), out hit))
        {
            position = hit.point;
        }
        float  f      = Vector3.Dot(Camera.main.transform.forward, Vector3.up);
        float  num2   = -f / Mathf.Abs(f);
        Bounds bounds = this.m_draggedPack.GetComponent <Collider>().bounds;

        position.y += (num2 * bounds.extents.y) * this.m_draggedPack.transform.lossyScale.y;
        this.m_draggedPack.transform.position = position;
    }
 public UnopenedPack AcquireDraggedPack()
 {
     if ((this.m_boosterStack.Id == 10) && !Options.Get().GetBool(Option.HAS_HEARD_TGT_PACK_VO, false))
     {
         Options.Get().SetBool(Option.HAS_HEARD_TGT_PACK_VO, true);
         NotificationManager.Get().CreateTirionQuote("VO_TIRION_INTRO_02", "VO_TIRION_INTRO_02", true);
     }
     if (this.m_draggedPack == null)
     {
         this.m_draggedPack = (UnopenedPack)UnityEngine.Object.Instantiate(this, base.transform.position, base.transform.rotation);
         TransformUtil.CopyWorldScale((Component)this.m_draggedPack, (Component)this);
         this.m_draggedPack.transform.parent = base.transform.parent;
         UIBScrollableItem component = this.m_draggedPack.GetComponent <UIBScrollableItem>();
         if (component != null)
         {
             component.m_active = UIBScrollableItem.ActiveState.Inactive;
         }
         this.m_draggedPack.m_creatorPack = this;
         this.m_draggedPack.gameObject.AddComponent <DragRotator>().SetInfo(this.m_DragRotatorInfo);
         this.m_draggedPack.m_DragStartEvent.Activate();
     }
     return(this.m_draggedPack);
 }
Beispiel #7
0
 private void DestroyDraggedPack()
 {
     this.m_draggedPack.RemoveEventListener(UIEventType.RELEASE, new UIEvent.Handler(this.OnDraggedPackRelease));
     this.m_draggedPack.GetCreatorPack().ReleaseDraggedPack();
     this.m_draggedPack = null;
 }
 private void ShowReward(UIEvent e)
 {
     if (TavernBrawlManager.Get().CurrentMission() != null)
     {
         RewardType rewardType = TavernBrawlManager.Get().CurrentMission().rewardType;
         if (rewardType != RewardType.REWARD_BOOSTER_PACKS)
         {
             if (rewardType != RewardType.REWARD_CARD_BACK)
             {
                 object[] objArray4 = new object[] { TavernBrawlManager.Get().CurrentMission().rewardType };
                 UnityEngine.Debug.LogErrorFormat("Tavern Brawl reward type currently not supported! Add type {0} to TaverBrawlDisplay.ShowReward().", objArray4);
                 return;
             }
             if (this.m_rewardObject == null)
             {
                 int cardBackIdx = (int)TavernBrawlManager.Get().CurrentMission().RewardData1;
                 CardBackManager.LoadCardBackData data = CardBackManager.Get().LoadCardBackByIndex(cardBackIdx, false, "Card_Hidden");
                 if (data == null)
                 {
                     object[] objArray3 = new object[] { cardBackIdx };
                     UnityEngine.Debug.LogErrorFormat("TavernBrawlDisplay.ShowReward() - Could not load cardback ID {0}!", objArray3);
                     return;
                 }
                 this.m_rewardObject = data.m_GameObject;
                 GameUtils.SetParent(this.m_rewardObject, this.m_rewardContainer, false);
                 this.m_rewardObject.transform.localScale = (Vector3)(Vector3.one * 5.92f);
             }
         }
         else if (this.m_rewardObject == null)
         {
             int       id     = (int)TavernBrawlManager.Get().CurrentMission().RewardData1;
             DbfRecord record = GameDbf.Booster.GetRecord(id);
             if (record == null)
             {
                 object[] objArray1 = new object[] { id };
                 UnityEngine.Debug.LogErrorFormat("TavernBrawlDisplay.ShowReward() - no record found for booster {0}!", objArray1);
                 return;
             }
             string assetName = record.GetAssetName("PACK_OPENING_PREFAB");
             if (string.IsNullOrEmpty(assetName))
             {
                 object[] objArray2 = new object[] { id };
                 UnityEngine.Debug.LogErrorFormat("TavernBrawlDisplay.ShowReward() - no prefab found for booster {0}!", objArray2);
                 return;
             }
             GameObject obj2 = AssetLoader.Get().LoadActor(assetName, false, false);
             if (obj2 == null)
             {
                 UnityEngine.Debug.LogError(string.Format("TavernBrawlDisplay.ShowReward() - failed to load prefab {0} for booster {1}!", assetName, id));
                 return;
             }
             this.m_rewardObject = obj2;
             UnopenedPack component = obj2.GetComponent <UnopenedPack>();
             if (component == null)
             {
                 UnityEngine.Debug.LogError(string.Format("TavernBrawlDisplay.ShowReward() - No UnopenedPack script found on prefab {0} for booster {1}!", assetName, id));
                 return;
             }
             GameUtils.SetParent(this.m_rewardObject, this.m_rewardContainer, false);
             component.AddBooster();
         }
         this.m_rewardsPreview.SetActive(true);
         iTween.Stop(this.m_rewardsPreview);
         object[] args = new object[] { "scale", this.m_rewardsScale, "time", 0.15f };
         iTween.ScaleTo(this.m_rewardsPreview, iTween.Hash(args));
     }
 }