Exemple #1
0
        public Deck(CardSuit[] suits, CardValue[] values)
        {
            if ((suits?.Count() ?? 0) <= 0)
            {
                suits = Enum.GetValues(typeof(CardSuit)).OfType <CardSuit>().ToArray();
            }
            if ((values?.Count() ?? 0) <= 0)
            {
                values = Enum.GetValues(typeof(CardValue)).OfType <CardValue>().ToArray();
            }
            List <Card> c = new List <Card>();

            foreach (var s in suits.OrderBy(z => (int)z))
            {
                if (s == CardSuit.Unknown)
                {
                    continue;
                }
                foreach (var v in values.OrderBy(z => (int)z))
                {
                    if (v == CardValue.Default)
                    {
                        continue;
                    }
                    c.Add(new Card(s, v));
                }
            }
            AllCards = c.ToArray();
            _Cards   = AllCards.OrderBy(z => z.ID).ToList();
        }
Exemple #2
0
    public void UpdateCoolDownCards()
    {
        List <CoolingDownCard> removeList = new List <CoolingDownCard>();

        foreach (CoolingDownCard coolingDownCard in CoolingDownCards)
        {
            if (coolingDownCard.LeftRounds == 1)
            {
                CardInfo_Base cib = AllCards.GetCard(coolingDownCard.CardID);
                removeList.Add(coolingDownCard);
                AbandonCards.Add(cib);
            }
            else
            {
                coolingDownCard.LeftRounds--;
                UpdateCoolDownCardHandler(coolingDownCard);
            }
        }

        foreach (CoolingDownCard coolingDownCard in removeList)
        {
            CoolingDownCards.Remove(coolingDownCard);
            RemoveCoolDownCardHandler(coolingDownCard);
        }

        AbandonCardRecycle();
    }
    private void SetupConfig()
    {
        allCards = FindObjectOfType <AllCards>();

        halfHeight = Camera.main.orthographicSize;
        halfWidth  = Camera.main.aspect * halfHeight;

        cardPlayLine       = halfHeight + halfHeight / 9;
        cardSizeMultiplier = halfWidth * 0.19f;
        handMiddlePos      = halfHeight / 1.48f;

        cardWidth = allCards.GetSampleCard().GetComponentInChildren <SpriteRenderer>().bounds.size.x *cardSizeMultiplier;

        float margin = halfWidth / 15.72f;

        handStartPos  = Camera.main.transform.position.x - halfWidth + margin + (cardWidth / cardSizeMultiplier / 2);
        handEndPos    = Camera.main.transform.position.x + halfWidth - margin - (cardWidth / cardSizeMultiplier / 2);
        handMiddlePos = halfHeight / 1.48f;

        // Tweak for narrow screens
        if (handStartPos - (Camera.main.transform.position.x - halfWidth) > halfWidth / 4)
        {
            handStartPos = Camera.main.transform.position.x - halfWidth * .55f;
            handEndPos   = Camera.main.transform.position.x + halfWidth * .55f;
        }
    }
    public void Refresh()
    {
        Clear();

        foreach (int heroCardID in BuildCards.GetHeroCardIDs(M_SelectMode))
        {
            int pid = AllCards.GetCard(heroCardID).BaseInfo.PictureID;
            LevelEditorPanel_HeroCardPicIcon heroCardPicIcon = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.LevelEditorPanel_HeroCardPicIcon].AllocateGameObject <LevelEditorPanel_HeroCardPicIcon>(HeroCardPicIconContainer);
            heroCardPicIcon.Initialize(pid, heroCardID);
            HeroCardPicIcons.Add(heroCardPicIcon);
        }

        foreach (KeyValuePair <CardStatTypes, int> kv in BuildCards.GetTypeCardCountDict(M_SelectMode))
        {
            LevelEditorPanel_TypeCardCount typeCardCount = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.LevelEditorPanel_TypeCardCount].AllocateGameObject <LevelEditorPanel_TypeCardCount>(TypeCardCountContainer);
            typeCardCount.Initialize(
                kv.Key,
                kv.Value,
                onClick: delegate
            {
                GotoAction?.Invoke();
                RefreshTypeCardCountButtons(typeCardCount.CardStatType);
                RefreshBars(typeCardCount.CardStatType);
                ShowCardStatTypeChange?.Invoke(typeCardCount.CardStatType);
            });

            TypeCardCounts.Add(typeCardCount);
        }

        RefreshBars(CardStatTypes.Total);
    }
    public override void Use()
    {
        if (drawFrom == DrawFrom.Deck)
        {
            if (myTarget == FightManager.instance.player)
            {
                FightManager.instance.StartCoroutine(FightManager.instance.myDeck.GetNewCard(amountToDraw));
            }
            else if (myTarget == FightManager.instance.enemy)
            {
                FightManager.instance.StartCoroutine(FightManager.instance.enemyCurrentDeck.GetNewCard(amountToDraw));
            }
        }
        else if (drawFrom == DrawFrom.AllCards)
        {
            for (int i = 0; i < amountToDraw; i++)
            {
                AllCards allCardsScript = Object.FindObjectOfType <AllCards>();
                Card     randomCard     = allCardsScript.allCards[Random.Range(0, allCardsScript.allCards.Count)];

                if (myTarget == FightManager.instance.player)
                {
                    FightManager.instance.myDeck.GetSpecificCard(randomCard);
                }
                else if (myTarget == FightManager.instance.enemy)
                {
                    FightManager.instance.enemyCurrentDeck.GetSpecificCard(randomCard);
                }
            }
        }
    }
    public static void CreateDatabaseAsset()
    {
        AllCards dataAllCards = ScriptableObject.CreateInstance <AllCards>();

        AssetDatabase.CreateAsset(dataAllCards, "Assets/Resources/AllCards.asset");
        AssetDatabase.SaveAssets();
    }
Exemple #7
0
    public SortedDictionary <CardStatTypes, int> GetTypeCardCountDict(Editor_CardSelectModes mode)
    {
        SortedDictionary <CardStatTypes, int> res = new SortedDictionary <CardStatTypes, int>();

        res.Add(CardStatTypes.Total, 0);
        res.Add(CardStatTypes.HeroMech, 0);
        res.Add(CardStatTypes.SoldierMech, 0);
        res.Add(CardStatTypes.Equip, 0);
        res.Add(CardStatTypes.Energy, 0);
        res.Add(CardStatTypes.Spell, 0);
        foreach (KeyValuePair <int, CardSelectInfo> kv in CardSelectInfos)
        {
            CardStatTypes type = AllCards.GetCard(kv.Key).CardStatType;
            if (mode == Editor_CardSelectModes.SelectCount)
            {
                res[type] += kv.Value.CardSelectCount;
                res[CardStatTypes.Total] += kv.Value.CardSelectCount;
            }
            else if (mode == Editor_CardSelectModes.UpperLimit)
            {
                res[type] += kv.Value.CardSelectUpperLimit;
                res[CardStatTypes.Total] += kv.Value.CardSelectUpperLimit;
            }
        }

        return(res);
    }
Exemple #8
0
    public List <int> GetHeroCardIDs(Editor_CardSelectModes mode)
    {
        List <int> heroCardIDs = new List <int>();

        foreach (KeyValuePair <int, CardSelectInfo> kv in CardSelectInfos)
        {
            if (AllCards.GetCard(kv.Key).CardStatType == CardStatTypes.HeroMech)
            {
                if (mode == Editor_CardSelectModes.SelectCount)
                {
                    for (int i = 0; i < kv.Value.CardSelectCount; i++)
                    {
                        heroCardIDs.Add(kv.Key);
                    }
                }
                else if (mode == Editor_CardSelectModes.UpperLimit)
                {
                    for (int i = 0; i < kv.Value.CardSelectUpperLimit; i++)
                    {
                        heroCardIDs.Add(kv.Key);
                    }
                }
            }
        }

        return(heroCardIDs);
    }
Exemple #9
0
 public void Init()
 {
     if (!AllCards.Any())
     {
         UpdateUserCardsInfo();
     }
 }
Exemple #10
0
    void Start()
    {
        allCards          = GetComponent <AllCards>();
        deckContent       = GameObject.FindGameObjectWithTag("DeckContent");
        collectionContent = GameObject.FindGameObjectWithTag("ColContent");
        canvas            = GameObject.FindGameObjectWithTag("ColCanvas");
        SetStart();
        all = GameObject.FindGameObjectsWithTag("DeckBuildCard");

        //if (!savedOnce)
        //{
        //    AddMultipleCardsToCollection(GameManager.instance.player.deck);
        //    SetStartDeck(GameManager.instance.player.deck);
        //    RefreshDeckContent();
        //}
        //else
        //{
        //    collection = GameManager.instance.collection;
        //    playerDeck = GameManager.instance.playerDeckEditorDeck;

        //    AddMultipleCardsToCollection(collection);
        //    SetStartDeck(playerDeck);
        //    RefreshDeckContent();
        //}
        //AddMultipleCardsToCollection(GameManager.instance.player.deck);
    }
Exemple #11
0
 public void Init(CardDeck.CoolingDownCard cdc, ClientPlayer clientPlayer)
 {
     ClientPlayer           = clientPlayer;
     M_CoolingDownCard      = cdc;
     CoolDownRoundText.text = cdc.LeftRounds.ToString();
     ClientUtils.ChangeImagePicture(Image, AllCards.GetCard(cdc.CardID).BaseInfo.PictureID);
     CooldDownIconAnim.SetTrigger("Add");
 }
 private void ConfigHand()
 {
     allCards   = FindObjectOfType <AllCards>();
     configData = FindObjectOfType <ConfigData>();
     maxCardGap = configData.GetCardWidth() + cardWidthBuffer;
     cardGap    = 1f;
     maxWidth   = configData.GetHandEndPos() - configData.GetHandStartPos();
 }
Exemple #13
0
 public async void PickUpUnChecked(int cardId)
 {
     if (AuthorizedEmployee.Id == 1)
     {
         this.UpdateCard        = AllCards.Find(al => cardId == al.Id);
         this.UpdateCard.PickUp = false;
         Card card = await UpdateCard.PutCardAsync(this.UpdateCard);
     }
 }
Exemple #14
0
        public void UpdateUserCardsInfo()
        {
            var json  = Http.GetStringAsync(cardsapi).Result;
            var cards = JsonConvert.DeserializeObject <carddata>(json);

            AllCards.Clear();
            AllCards.AddRange(cards.data);
            Save();
        }
Exemple #15
0
        /// <summary>
        /// Creates and starts a new draft
        /// </summary>
        /// <param name="name">the name which will identify the draft</param>
        /// <param name="decklist">the number of each card and its data that will be used to populate the packs</param>
        /// <param name="participantNames">the names fo the participants</param>
        /// <param name="packSize">how many cards will initially fill each pack</param>
        /// <param name="numRounds">the number of rounds in the draft</param>
        private Draft(string name, Dictionary <CardData, int> decklist, List <string> participantNames, int packSize, int numRounds)
        {
            _name       = name;
            _decklist   = decklist;
            _created    = DateTime.Now;
            _cardList   = new List <Card>();
            _cardLookup = new Dictionary <string, Card>();
            //create all cards and populate _cardLookup
            foreach (var kvp in decklist)
            {
                for (int i = 0; i < kvp.Value; i++)
                {
                    //the unique ID is just {database ID}{draft name}{copy number}
                    string uniqueID = kvp.Key.DBID + _name + i.ToString();
                    Card   c        = new Card(kvp.Key, uniqueID);
                    _cardList.Add(c);
                    _cardLookup[uniqueID] = c;
                }
            }


            //shuffle cards using draftname as the seed - it is not properly random so that if something goes wrong, a draft can be restarted and the players can re-pick the same cards
            Random rng = new Random(name.GetHashCode());
            int    n   = _cardList.Count;

            while (n > 1)
            {
                n--;
                int  k = rng.Next(n + 1);
                Card v = _cardList[k];
                _cardList[k] = _cardList[n];
                _cardList[n] = v;
            }

            //create participants
            _participants = new LinkedList <Participant>(participantNames.Select(pname => new Participant(pname, this)));

            foreach (Participant p in _participants)
            {
                _waitingPacks[p] = new Queue <Pack>(_participants.Count);
            }
            NumRoundsRemaining = numRounds;
            //since we want the draft to start with passing to the right, we set this to false, so that when the first round starts, it will be set to true
            PassRight = false;
            //num packs will be num rounds * num participants
            int numPacks = numRounds * _participants.Count;

            _remainingPacks = new Queue <Pack>(numPacks);
            //enqueue packs to _remainingPacks and associate the card list to each pack in _cardLists
            for (int packIndex = 0; packIndex < numPacks; packIndex++)
            {
                List <Card> currPackList = AllCards.GetRange(packIndex * packSize, packSize);
                RemainingPacks.Enqueue(new Pack(currPackList));
            }
            //start the round
            StartNewRound();
        }
 public void Refresh()
 {
     TypeText.text = Cur_Bonus.BonusType.ToString();
     NameText.text = Utils.TextMeshProColorStringConvertToText(Cur_Bonus.GetDesc());
     if (Cur_Bonus is Bonus_UnlockCardByID b_UnlockCardByID)
     {
         ClientUtils.ChangeImagePicture(Pic, AllCards.GetPicIDByCardID(b_UnlockCardByID.CardID));
     }
 }
Exemple #17
0
    public void AddCardIntoCardSelectWindow(CardInfo_Base cardInfo)
    {
        CardSelectWindowCardContainer newCardContainer = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.CardSelectWindowCardContainer].AllocateGameObject <CardSelectWindowCardContainer>(AllCardsContainer);

        newCardContainer.Initialize(cardInfo);
        RefreshCardInSelectWindow(newCardContainer, false);
        AllCards.Add(cardInfo.CardID, newCardContainer.M_ChildCard);
        AllCardContainers.Add(cardInfo.CardID, newCardContainer);
    }
Exemple #18
0
    internal void GetTempCardByCardTypes(CardFilterTypes cardFilterTypes, int count)
    {
        List <int> cardIds = AllCards.GetRandomCardInfoByCardFilterType(cardFilterTypes, count);

        foreach (int cardId in cardIds)
        {
            GetTempCardsByID(cardId, 1);
        }
    }
Exemple #19
0
 public CardDeck(BuildInfo cdi, OnCardDeckCountChange onCardDeckCountChangeHandler, Action <CoolingDownCard> onUpdateCoolDownCardHandler, Action <CoolingDownCard> onRemoveCoolDownCardHandler)
 {
     M_BuildInfo = cdi;
     CardDeckCountChangeHandler = onCardDeckCountChangeHandler;
     UpdateCoolDownCardHandler  = onUpdateCoolDownCardHandler;
     RemoveCoolDownCardHandler  = onRemoveCoolDownCardHandler;
     AppendCards(AllCards.GetCards(M_BuildInfo.M_BuildCards.GetCardIDs().ToArray()));
     SuffleSelf();
 }
Exemple #20
0
    public void EditAllCardLimitDict(int cardID, int changeValue) // 更改某卡牌上限数量
    {
        if (changeValue > 0)
        {
            if (!CardUnlockInfos[cardID])
            {
                CardUnlockInfos[cardID] = true;
            }
        }

        foreach (KeyValuePair <int, BuildInfo> kv in PlayerBuildInfos)
        {
            SortedDictionary <int, BuildCards.CardSelectInfo> csis = kv.Value.M_BuildCards.CardSelectInfos;
            int remainChange = changeValue;
            if (csis[cardID].CardSelectUpperLimit + changeValue >= 0)
            {
                csis[cardID].CardSelectUpperLimit += changeValue;

                if (csis[cardID].CardSelectUpperLimit < csis[cardID].CardSelectCount)
                {
                    csis[cardID].CardSelectCount = csis[cardID].CardSelectUpperLimit;
                }
            }
            else // 如果本身的上限不够扣,则扣掉该系列卡牌的其他牌的上限
            {
                remainChange += csis[cardID].CardSelectUpperLimit;
                csis[cardID].CardSelectUpperLimit = 0;
                List <int> series = AllCards.GetCardSeries(cardID);
                foreach (int i in series)
                {
                    if (csis[i].CardSelectUpperLimit + remainChange >= 0)
                    {
                        csis[i].CardSelectUpperLimit += remainChange;
                        if (csis[i].CardSelectUpperLimit < csis[i].CardSelectCount)
                        {
                            csis[i].CardSelectCount = csis[i].CardSelectUpperLimit;
                        }

                        break;
                    }
                    else
                    {
                        remainChange += csis[i].CardSelectUpperLimit;
                        csis[i].CardSelectUpperLimit = 0;
                        csis[i].CardSelectCount      = 0;
                    }
                }
            }
        }

        int baseCardID = AllCards.GetCardBaseCardID(cardID);

        Base_CardLimitDict[baseCardID] += changeValue;

        InfoRefresh?.Invoke();
    }
Exemple #21
0
    public static Card GetCardById(string id)
    {
        Card card = AllCards.ToList().FirstOrDefault(c => c.name == id);

        if (card == null)
        {
            throw new Exception("Card " + id + " does not contains in all cards!");
        }
        return(card);
    }
Exemple #22
0
        public void ShuffleCards()
        {
            Random random = new Random();

            for (int i = 0; i < AllCards.Count; i++)
            {
                var temp = AllCards[i];
                AllCards.RemoveAt(i);
                AllCards.Insert(random.Next(AllCards.Count), temp);
            }
        }
Exemple #23
0
        public async void PickUpCheck(int cardId)
        {
            if (AuthorizedEmployee.Id == 1)
            {
                this.UpdateCard        = AllCards.Find(al => cardId == al.Id);
                this.UpdateCard.PickUp = true;
                Card card = await UpdateCard.PutCardAsync(this.UpdateCard);

                //this.AllCards = await UpdateCard.GetCardsAsync();
            }
        }
Exemple #24
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
 }
Exemple #25
0
 /// <summary>
 /// Default constructor to populate the deck
 /// </summary>
 public Deck()
 {
     foreach (string suit in Card.suitNames)
     {
         for (int i = 1; i <= 13; i++)
         {
             Card card = new Card(i, suit);
             AllCards.Add(card);
         }
     }
     _numberOfCards = AllCards.Count;
 }
Exemple #26
0
 public virtual void Initialize(Bonus bonus)
 {
     Bonus = bonus;
     if (ItemDesc)
     {
         ItemDesc.text = Utils.TextMeshProColorStringConvertToText(Bonus.GetDesc());
     }
     if (bonus is Bonus_UnlockCardByID b_UnlockCardByID)
     {
         BonusCardInfo = AllCards.GetCard(b_UnlockCardByID.CardID);
     }
 }
Exemple #27
0
        // Helper function
        private Card DealOneCard(bool shouldBeFaceUp)
        {
            Card drawnCard = null;

            if (AllCards.Count > 0)
            {
                drawnCard = AllCards[0];
                drawnCard.Flip(shouldBeFaceUp);
                AllCards.Remove(drawnCard);
            }
            return(drawnCard);
        }
Exemple #28
0
        public async void Initialize()
        {
            this.AuthorizedEmployee = SessionService.Instance.AuthorizedEmployee;

            Favorite favorite = new Favorite();

            this.Favorites = await favorite.GetFavoritesAsync();

            this.Date      = new Card();
            this.Date.Date = this.Date.Date.Date;
            this.Favorite  = new Favorite();

            Card card = new Card();

            this.AllCards = await card.GetCardsAsync();

            this.AllCards = AllCards.OrderBy(ac => ac.Date).ToList();

            var FavoriteCheckCards = new List <Card>();


            for (var i = 0; i < AllCards.Count; i++)
            {
                card = AllCards.ElementAt(i);
                //card.Id == Favorites.CardId && this.AuthorizedEmployee.Id == Favorites.EmployeeId
                if (Favorites.Any(f => f.CardId == card.Id && f.EmployeeId == this.AuthorizedEmployee.Id))
                {
                    //List<int> intList = new List<int>;

                    card          = AllCards.ElementAt(i);
                    card.Favorite = true;

                    FavoriteCheckCards.Add(card);

                    //this.AllCards.RemoveAt(i);
                    //this.Cards.Insert(i, card);
                    //this.Cards.Insert(i, new Card() { Id = card.Id, CD = card.CD, Text = card.Text, Date = card.Date, FromId = card.FromId, ToId = card.ToId, Title = card.Title, Reply = card.Reply, Favorite = card.Favorite, PickUp = card.PickUp });
                    //this.Cards.Add(card);
                    //this.AllCards.Insert(i, new Card() { Id = card.Id, CD = card.CD, Text = card.Text, Date = card.Date, FromId = card.FromId, ToId = card.ToId, Title = card.Title, Reply = card.Reply, Favorite = card.Favorite, PickUp = card.PickUp });
                    //this.Cards.Add(new Card() { Id = card.Id, CD = card.CD, Text = card.Text, Date = card.Date, FromId = card.FromId, ToId = card.ToId, Title=card.Title, Reply=card.Reply, Favorite=card.Favorite, PickUp=card.PickUp});
                }
                else
                {
                    FavoriteCheckCards.Add(card);
                }
            }


            this.Cards = FavoriteCheckCards;
            this.Cards = Cards.OrderBy(ac => ac.Date).ToList();
            //this.AuthorizedEmployee = SessionService.Instance.AuthorizedEmployee;
        }
        public int GetSideEffectFunctionBias()
        {
            CardInfo_Base card = AllCards.GetCard(M_SideEffectParam.GetParam_ConstInt("SummonCardID"));

            if (card != null)
            {
                return(card.GetCardUseBias() * 3);
            }
            else
            {
                return(0);
            }
        }
Exemple #30
0
 internal void GetTempCardsByID(int cardID, int count)
 {
     for (int i = 0; i < count; i++)
     {
         CardInfo_Base cardInfo  = AllCards.GetCard(cardID);
         CardBase      newCard   = CardBase.InstantiateCardByCardInfo(cardInfo, BattlePlayer, BattlePlayer.GameManager.GenerateNewTempCardInstanceId());
         bool          checkHand = HandAddCard(newCard);
         if (checkHand)
         {
             OnPlayerGetCard(cardID, newCard.M_CardInstanceId);
         }
     }
 }