예제 #1
0
 public void AddCard(string cardId)
 {
     var entityDef = DefLoader.Get().GetEntityDef(cardId);
     if (entityDef == null)
     {
         Logger.AppendLine($"DeckTileHolder.Update - entityDef is null for cardId:{cardId}");
         return;
     }
     TileWrapper tile;
     if (_tileDict.TryGetValue(cardId, out tile))
     {
         Logger.AppendLine($"DeckTileHolder.Update - Already have '{cardId}', increasing count");
         tile.Count++;
         CollectionDeckSlot deckSlot = new CollectionDeckSlot
         {
             CardID = cardId,
             Count = tile.Count,
             Index = 0,
             OnSlotEmptied = slot => { },
             //Premium = CardFlair.DEFAULT_PREMIUM_TYPE
         };
         tile.Tile.SetSlot(deckSlot, false);
     }
     else // Brand new card
     {
         Logger.AppendLine($"DeckTileHolder.Update - Dont have '{cardId}' so creating");
         var tileWrapper = CreateTileWrapper(cardId, 1, _tileDict.Count);
         _tiles.Add(tileWrapper);
         _tileDict.Add(cardId, tileWrapper);
     }
     var pos = _holderGameObject.transform.position;
     Logger.AppendLine($"_holderGameObject x:{pos.x} y:{pos.y} z:{pos.z}");
 }
예제 #2
0
        public static TileWrapper CreateTileWrapper(string cardId, int count, GameObject holderGameObject, int position)
        {
            var newTileObj    = new GameObject("MyDeckTileVisual");
            var newTileVisual = newTileObj.AddComponent <DeckTrayDeckTileVisual>();

            Logger.AppendLine("Creating card based on new instance");
            newTileVisual.MarkAsUsed();
            newTileVisual.Show();
            CollectionDeckSlot deckSlot = new CollectionDeckSlot
            {
                CardID        = cardId,
                Count         = count,
                Index         = 0,
                OnSlotEmptied = slot => { },
                Premium       = TAG_PREMIUM.GOLDEN
            };

            newTileVisual.SetSlot(deckSlot, false);
            newTileObj.transform.SetParent(holderGameObject.transform);
            newTileObj.transform.localScale    = new Vector3(Scale, Scale, Scale);
            newTileObj.transform.localPosition = new Vector3(0f, 0f, position * HeightDistance);
            var tileWrapper = new TileWrapper {
                Tile = newTileVisual, Count = count
            };

            return(tileWrapper);
        }
예제 #3
0
 public void CopyFrom(CollectionDeckSlot otherSlot)
 {
     this.Index   = otherSlot.Index;
     this.Count   = otherSlot.Count;
     this.CardID  = otherSlot.CardID;
     this.Premium = otherSlot.Premium;
     this.Owned   = otherSlot.Owned;
 }
예제 #4
0
 public void CopyFrom(CollectionDeck otherDeck)
 {
     this.ID                 = otherDeck.ID;
     this.Type               = otherDeck.Type;
     this.m_name             = otherDeck.m_name;
     this.HeroCardID         = otherDeck.HeroCardID;
     this.HeroCardFlair      = otherDeck.HeroCardFlair;
     this.HeroOverridden     = otherDeck.HeroOverridden;
     this.CardBackID         = otherDeck.CardBackID;
     this.CardBackOverridden = otherDeck.CardBackOverridden;
     this.IsTourneyValid     = otherDeck.IsTourneyValid;
     this.SeasonId           = otherDeck.SeasonId;
     this.m_slots.Clear();
     for (int i = 0; i < otherDeck.GetSlotCount(); i++)
     {
         CollectionDeckSlot slotByIndex = otherDeck.GetSlotByIndex(i);
         CollectionDeckSlot item        = new CollectionDeckSlot();
         item.CopyFrom(slotByIndex);
         this.m_slots.Add(item);
     }
 }
예제 #5
0
        public static TileWrapper CreateTileWrapper(string cardId, int count, GameObject holderGameObject, int position)
        {
            var newTileObj = new GameObject("MyDeckTileVisual");
            var newTileVisual = newTileObj.AddComponent<DeckTrayDeckTileVisual>();
            Logger.AppendLine("Creating card based on new instance");
            newTileVisual.MarkAsUsed();
            newTileVisual.Show();
            CollectionDeckSlot deckSlot = new CollectionDeckSlot
            {
                CardID = cardId,
                Count = count,
                Index = 0,
                OnSlotEmptied = slot => { },
                Premium = TAG_PREMIUM.GOLDEN
            };
            newTileVisual.SetSlot(deckSlot, false);
            newTileObj.transform.SetParent(holderGameObject.transform);
            newTileObj.transform.localScale = new Vector3(Scale, Scale, Scale);
            newTileObj.transform.localPosition = new Vector3(0f, 0f, position * HeightDistance);
            var tileWrapper = new TileWrapper { Tile = newTileVisual, Count = count };

            return tileWrapper;
        }
예제 #6
0
    public bool AddCard(string cardID, TAG_PREMIUM premium)
    {
        if (!this.CanInsertCard(cardID, premium))
        {
            return(false);
        }
        bool owned = this.CanAddOwnedCard(cardID, premium);
        CollectionDeckSlot slot = this.FindSlotByCardIdPremiumAndOwned(cardID, premium, owned);

        if (slot != null)
        {
            slot.Count++;
            return(true);
        }
        slot = new CollectionDeckSlot {
            CardID  = cardID,
            Count   = 1,
            Premium = premium,
            Owned   = owned
        };
        this.InsertSlotByDefaultSort(slot);
        return(true);
    }
예제 #7
0
        public void AddCard(string cardId)
        {
            var entityDef = DefLoader.Get().GetEntityDef(cardId);

            if (entityDef == null)
            {
                Logger.AppendLine($"DeckTileHolder.Update - entityDef is null for cardId:{cardId}");
                return;
            }
            TileWrapper tile;

            if (_tileDict.TryGetValue(cardId, out tile))
            {
                Logger.AppendLine($"DeckTileHolder.Update - Already have '{cardId}', increasing count");
                tile.Count++;
                CollectionDeckSlot deckSlot = new CollectionDeckSlot
                {
                    CardID        = cardId,
                    Count         = tile.Count,
                    Index         = 0,
                    OnSlotEmptied = slot => { },
                    //Premium = CardFlair.DEFAULT_PREMIUM_TYPE
                };
                tile.Tile.SetSlot(deckSlot, false);
            }
            else // Brand new card
            {
                Logger.AppendLine($"DeckTileHolder.Update - Dont have '{cardId}' so creating");
                var tileWrapper = CreateTileWrapper(cardId, 1, _tileDict.Count);
                _tiles.Add(tileWrapper);
                _tileDict.Add(cardId, tileWrapper);
            }
            var pos = _holderGameObject.transform.position;

            Logger.AppendLine($"_holderGameObject x:{pos.x} y:{pos.y} z:{pos.z}");
        }
예제 #8
0
 public void SetSlot(CollectionDeckSlot slot)
 {
     this.m_slot = slot;
 }
예제 #9
0
 private Network.CardUserData CardUserDataFromSlot(CollectionDeckSlot deckSlot, bool deleted)
 {
     return(new Network.CardUserData {
         DbId = GameUtils.TranslateCardIdToDbId(deckSlot.CardID), Count = !deleted ? deckSlot.Count : 0, Premium = deckSlot.Premium
     });
 }
 public void SetSlot(CollectionDeckSlot s, bool useSliderAnimations)
 {
     this.m_slot = s;
     this.m_useSliderAnimations = useSliderAnimations;
     this.SetUpActor();
 }