예제 #1
0
        public void Add(Card c)
        {
            if(c.Level <= maxLevel)
            {
                if (LibInstance.Cards[c.Level] == null)
                {
                    LibInstance.Cards[c.Level] = new List<Card>();
                }

                LibInstance.Cards[c.Level].Add(c);
            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: xxy1991/cozy
 private void GenButton_Click(object sender, EventArgs e)
 {
     int result = 0;
     if (NameTextBox.Text != string.Empty
         && CN_NameTextBox.Text != string.Empty
         && int.TryParse(LevelTextBox.Text, out result))
     {
         CurrElement = new Card()
         {
             Name    = NamePath,
             CN_Name = CN_NameTextBox.Text,
             Level   = result,
         };
         cozyGodEditor1.Element = CurrElement;
     }
 }
예제 #3
0
파일: CraftImpl.cs 프로젝트: xxy1991/cozy
 public Card Craft(Card a, Card b)
 {
     Card cardRet = null;
     for (int i = 0; i < m_CraftTableList.Count; i++)
     {
         if (m_CraftTableList[i].costCardList.Count == 2)
         {
             if (m_CraftTableList[i].costCardList[0] == a.Name && b.Name == m_CraftTableList[i].costCardList[1])
             {
                 cardRet = mCL.FindCardByName(m_CraftTableList[i].resultCardItem[0]);
                 break;
             }
             if (m_CraftTableList[i].costCardList[1] == a.Name && b.Name == m_CraftTableList[i].costCardList[0])
             {
                 cardRet = mCL.FindCardByName(m_CraftTableList[i].resultCardItem[0]);
                 break;
             }
         }
     }
     return cardRet;
 }
예제 #4
0
파일: RaffleImpl.cs 프로젝트: xxy1991/cozy
        public Card[] PentaDraw()
        {
            Card [] cardArrayRet = new Card[5];

            cardArrayRet[0] = Draw(minimumRank);
            for(int i = 1; i < cardArrayRet.Length; i++)
            {
                cardArrayRet[i] = Draw();
            }

            // shuffle 打乱顺序
            for(int i = 0; i < cardArrayRet.Length; i++)
            {
                int _iRdIndex = rd.Next(0, cardArrayRet.Length);

                Card tmp = cardArrayRet[i];
                cardArrayRet[i] = cardArrayRet[_iRdIndex];
                cardArrayRet[_iRdIndex] = tmp;
            }

            return cardArrayRet;
        }
예제 #5
0
파일: CraftImpl.cs 프로젝트: xxy1991/cozy
        public bool TryCraft(Card a, Card b)
        {
            bool bRet = false;

            for (int i = 0; i < m_CraftTableList.Count; i++)
            {
                if (m_CraftTableList[i].costCardList.Count == 2)
                {
                    if (m_CraftTableList[i].costCardList[0] == a.Name&& b.Name == m_CraftTableList[i].costCardList[1])
                    {
                        bRet = true;
                        break;
                    }
                    if (m_CraftTableList[i].costCardList[1] == a.Name && b.Name == m_CraftTableList[i].costCardList[0])
                    {
                        bRet = true;
                        break;
                    }
                }
            }

            return bRet;
        }
예제 #6
0
파일: MainForm.cs 프로젝트: xxy1991/cozy
        private Image DrawCard(Card card, Image img)
        {
            var b = new Bitmap(CardSize.Width, CardSize.Height);
            using (var g = Graphics.FromImage(b))
            {
                if(BorderBackground != null)
                {
                    g.DrawImage(BorderBackground, 
                        new Rectangle(Point.Empty, CardSize), 
                        new Rectangle(Point.Empty, BorderBackground.Size), 
                        GraphicsUnit.Pixel);
                }

                var offsetSize  = (CardSize - img.Size);
                int offset      = offsetSize.Width / 2;
                int fontSize    = Math.Abs(offsetSize.Width - offsetSize.Height) - 2;
                fontSize        = fontSize > 2 ? fontSize : 2;

                var CardFont    = new Font("微软雅黑", fontSize);

                g.DrawImage(img,
                    new Rectangle(new Point(offset, offset), img.Size),
                    new Rectangle(Point.Empty, img.Size),
                        GraphicsUnit.Pixel);

                SizeF sizeText = g.MeasureString(card.CN_Name, CardFont);

                g.DrawString(card.CN_Name,
                    CardFont,
                    SystemBrushes.ControlText,
                    (CardSize.Width - sizeText.Width) / 2,
                    offset + img.Height);

                if(LevelBackground != null)
                {
                    g.DrawImage(LevelBackground,
                    new Rectangle(LevelPos, LevelSize),
                    new Rectangle(Point.Empty, LevelBackground.Size),
                    GraphicsUnit.Pixel);

                    var levelFont   = new Font("微软雅黑", 10, FontStyle.Bold);
                    var levelStr    = card.Level.ToString();
                    var sizeLevel   = g.MeasureString(levelStr, levelFont);

                    g.DrawString(levelStr,
                        levelFont,
                        Brushes.WhiteSmoke,
                        LevelPos.X + (LevelSize.Width - sizeLevel.Width) / 2,
                        LevelPos.Y + (LevelSize.Height - sizeLevel.Height) / 2);
                }
            }
            return b;
        }