Пример #1
0
        private void GenerateTree(TreeNode treeNode, YuGiNode yugiNode)
        {
            foreach (YuGiNode node in yugiNode.Children)
            {
                TreeNode n = new TreeNode(node.Name);
                n.Tag = node;

                GenerateTree(n, node);
                treeNode.Nodes.Add(n);
            }
        }
Пример #2
0
        private void DrawField(Graphics graphic, YuGiNode node, PointEx cardSize, bool top, bool rotate)
        {
            //570 field size
            //800 window size
            //230 left side menu size

            Bitmap card               = Properties.Resources.card_ura;
            Bitmap removedSymbol      = Properties.Resources.jyogai_ai1;
            Bitmap removedSymbolEnemy = Properties.Resources.jyogai_ji1;
            Bitmap deckCardZone       = Properties.Resources.hand_deck;

            Bitmap deckDepth  = GenerateDeckBitmap();
            Bitmap deckShadow = GenerateDeckShadowBitmap();

            //offset to the center from the cards edge
            int centerOffsetX = cardSize.X / 2;
            int centerOffsetY = cardSize.Y / 2;

            int centerRemovedOffsetX    = removedSymbol.Width / 2;
            int centerRemovedOffsetY    = removedSymbol.Height / 2;
            int centerHandOffsetOffsetX = deckCardZone.Width / 2;
            int centerHandOffsetOffsetY = deckCardZone.Height / 2;

            //removing the draw method extra pixel
            Point cardSizePoint = new Point(cardSize.X - 1, cardSize.Y - 1);

            YuGiPoint deckOffset = node.GetNode <YuGiPoint>("Deck");

            DrawDeck(graphic, card, deckShadow, deckDepth, new Rectangle(deckOffset.X.ValueInt32 - centerOffsetX, deckOffset.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), top);

            YuGiPoint graveyardOffset       = node.GetNode <YuGiPoint>("Graveyard");
            YuGiPoint fusionOffset          = node.GetNode <YuGiPoint>("Fusion");
            YuGiPoint fieldEffectOffset     = node.GetNode <YuGiPoint>("Field Effect Card");
            YuGiPoint removedFromGameOffset = node.GetNode <YuGiPoint>("Removed From Game");
            YuGiPoint handOffset            = node.GetNode <YuGiPoint>("Hand");

            if (top)
            {
                DrawCard(graphic, card, new Rectangle(graveyardOffset.X.ValueInt32 - centerOffsetX, graveyardOffset.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 180);
                DrawCard(graphic, card, new Rectangle(fusionOffset.X.ValueInt32 - centerOffsetX, fusionOffset.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 180);
                DrawCard(graphic, card, new Rectangle(fieldEffectOffset.X.ValueInt32 - centerOffsetX, fieldEffectOffset.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 180);
                graphic.DrawImage(removedSymbol, new Rectangle(removedFromGameOffset.X.ValueInt32 - centerRemovedOffsetX, removedFromGameOffset.Y.ValueInt32 - centerRemovedOffsetY, removedSymbol.Width, removedSymbol.Height), new Rectangle(0, 0, removedSymbol.Width, removedSymbol.Height), GraphicsUnit.Pixel);
                graphic.DrawImage(deckCardZone, new Rectangle(handOffset.X.ValueInt32 - centerHandOffsetOffsetX, (handOffset.Y.ValueInt32 - centerHandOffsetOffsetY) + 19, deckCardZone.Width, deckCardZone.Height), new Rectangle(0, 0, deckCardZone.Width, deckCardZone.Height), GraphicsUnit.Pixel);
            }
            else
            {
                DrawCard(graphic, card, new Rectangle(graveyardOffset.X.ValueInt32 - centerOffsetX, graveyardOffset.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 0);
                DrawCard(graphic, card, new Rectangle(fusionOffset.X.ValueInt32 - centerOffsetX, fusionOffset.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 0);
                DrawCard(graphic, card, new Rectangle(fieldEffectOffset.X.ValueInt32 - centerOffsetX, fieldEffectOffset.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 0);
                graphic.DrawImage(removedSymbolEnemy, new Rectangle(removedFromGameOffset.X.ValueInt32 - centerRemovedOffsetX, removedFromGameOffset.Y.ValueInt32 - centerRemovedOffsetY, removedSymbolEnemy.Width, removedSymbolEnemy.Height), new Rectangle(0, 0, removedSymbolEnemy.Width, removedSymbolEnemy.Height), GraphicsUnit.Pixel);
                graphic.DrawImage(deckCardZone, new Rectangle(handOffset.X.ValueInt32 - centerHandOffsetOffsetX, (handOffset.Y.ValueInt32 - centerHandOffsetOffsetY) - 19, deckCardZone.Width, deckCardZone.Height), new Rectangle(0, 0, deckCardZone.Width, deckCardZone.Height), GraphicsUnit.Pixel);
            }

            for (int i = 0; i < 5; i++)
            {
                YuGiPointBundle monsterCards     = node.GetNode <YuGiPointBundle>("Monster Cards");
                YuGiPointBundle magicCards       = node.GetNode <YuGiPointBundle>("Spell/Trap Cards");
                YuGiPoint       monsterCardStart = (YuGiPoint)monsterCards.Children[0];
                YuGiPoint       magicCardStart   = (YuGiPoint)magicCards.Children[0];

                if (rotate)
                {
                    Rectangle rect = new Rectangle(monsterCardStart.X.ValueInt32 + i * monsterCards.Gap - centerOffsetX, monsterCardStart.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y);
                    if (top)
                    {
                        DrawCard(graphic, card, rect, 270);
                    }
                    else
                    {
                        DrawCard(graphic, card, rect, 90);
                    }
                }
                else
                {
                    if (top)
                    {
                        DrawCard(graphic, card, new Rectangle(monsterCardStart.X.ValueInt32 + i * monsterCards.Gap - centerOffsetX, monsterCardStart.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 180);
                    }
                    else
                    {
                        DrawCard(graphic, card, new Rectangle(monsterCardStart.X.ValueInt32 + i * monsterCards.Gap - centerOffsetX, monsterCardStart.Y.ValueInt32 - centerOffsetY, cardSizePoint.X, cardSizePoint.Y), 0);
                    }
                }


                if (top)
                {
                    DrawCard(graphic, card, new Rectangle(magicCardStart.X.ValueInt32 + i * magicCards.Gap - centerOffsetX, magicCardStart.Y.ValueInt32 - centerOffsetY, cardSizePoint.X - 1, cardSizePoint.Y - 1), 180);
                }
                else
                {
                    DrawCard(graphic, card, new Rectangle(magicCardStart.X.ValueInt32 + i * magicCards.Gap - centerOffsetX, magicCardStart.Y.ValueInt32 - centerOffsetY, cardSizePoint.X - 1, cardSizePoint.Y - 1), 0);
                }
            }
        }