Esempio n. 1
0
        public Form2(CardDB[] cardDB_temp, Card[] card_temp, int[] cardOrder_temp,int cardNum_temp)
        {
            cardDB = cardDB_temp;
            card = card_temp;
            cardOrder = cardOrder_temp;
            cardNum = cardNum_temp;

            InitializeComponent();
        }
Esempio n. 2
0
 public void setAll(Card setCard)
 {
     this.id = setCard.id;
     this.no = setCard.no;
     this.open = setCard.open;
     this.active = setCard.active;
     this.reverse = setCard.reverse;
     this.owner = setCard.owner;
     this.Location.X = setCard.Location.X;
     this.Location.Y = setCard.Location.Y;
     this.section = setCard.section;
 }
Esempio n. 3
0
        private void デッキを読み込みToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Card[] sendDeck = new Card[50];
            string fname;
            openFileDialog1.Filter = "テキストファイル (*.txt)|*.txt|deckファイル (*.deck)|*.deck";
            if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
            fname = openFileDialog1.FileName;

            // デッキを読み込み
            if (!ReadDeck(fname))
            {
                MessageBox.Show("デッキの読み込みに失敗しました。");
                return;
            }

            for (int i = 0; i < 50; i++)
            {
                core.home.libraryOrder[i] = i;
            }
            core.home.libraryNum=50;
            RedrawAll();
        }
Esempio n. 4
0
        //----------メニュー----------
        private void ゲーム開始ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Card[] sendDeck = new Card[50];
            string fname;
            openFileDialog1.Filter = "テキストファイル (*.txt)|*.txt|deckファイル (*.deck)|*.deck";
            if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
            fname = openFileDialog1.FileName;

            // デッキを読み込み
            if (!ReadDeck(fname))
            {
                MessageBox.Show("デッキの読み込みに失敗しました。");
                return;
            }
            for (int i = 0; i < 50; i++)
            {
                sendDeck[i] = new Card(i, 1);
                sendDeck[i].setAll(core.cards[i]);
            }

            fm3 = new Form3();
            if (fm3.ShowDialog() == DialogResult.OK)
            {
                bool host = fm3.host;
                int port = fm3.port;
                string ip = fm3.ip;

                if (host)
                {
                    //サーバーを作成
                    if (Program.OpenServer(port) == false)
                    {
                        MessageBox.Show("サーバーの作成に失敗しました。");
                        return;
                    }
                    textBox1.Text += "サーバーを作成しました。" + Environment.NewLine;

                    ip = "localhost";
                }

                //クライアントを作成
                if (Program.OpenClient(ip, port) == false)
                {
                    MessageBox.Show("サーバーへの接続に失敗しました。");
                    return;
                }

                Program.cl.Send(sendDeck, TOPBYTE.DECK);
                selectedCard = -1;
                RedrawAll();
            }
            fm3.Dispose();
        }
Esempio n. 5
0
        //----------デッキ読み込み----------
        private bool ReadDeck(string fname)
        {
            Card[] deck = new Card[50];

            int cnt = 0;
            System.IO.StreamReader reader = new System.IO.StreamReader(fname, Encoding.Default);
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                string[] field = line.Split(',');

                // fieldにデータが2つ以上ない場合
                if (field.Length < 2) continue;

                int n, no; //n:枚数 no:番号
                if (int.TryParse(field[0], out n) && int.TryParse(field[1], out no))
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (cnt >= 50) break;
                        deck[cnt] = new Card(cnt,no);
                        cnt++;
                    }
                }
                if (cnt > 50) break;
            }
            reader.Close();

            // false
            if (cnt != 50)
            {
                MessageBox.Show("デッキの枚数が50枚ではありません。");
                return false;
            }

            // true
            for (int i = 0; i < 50; i++) core.cards[i].no = deck[i].no;
            core.Initialize();
            selectedCard = -1;
            return true;
        }
Esempio n. 6
0
        // カード画像がない場合のカードの描画
        public static Bitmap DrawCard(CardDB[] cardDB, Card card, int w, int h)
        {
            Bitmap img = new Bitmap(w, h);
            Graphics g = Graphics.FromImage(img);
            Rectangle area;

            // 枠の描画
            g.FillRectangle(Brushes.White, 0, 0, w, h);
            Pen pen = new Pen(Brushes.Black, 3);
            if (cardDB[card.no].type == "Character") pen.Brush = Brushes.Aquamarine;
            if (cardDB[card.no].type == "Spell") pen.Brush = Brushes.OrangeRed;
            if (cardDB[card.no].type == "Command") pen.Brush = Brushes.Gray;
            g.DrawRectangle(pen, 1, 1, w - 3, h - 3);
            g.DrawRectangle(new Pen(Brushes.Black, 1), 0, 0, w - 1, h - 1);

            // カード名の描画
            area = new Rectangle(3, h / 2, w - 6, h / 2 - 15);
            g.DrawString(cardDB[card.no].name, new Font("MS UI Gothic", 8), Brushes.Black, area);

            // 攻撃力・耐久力の描画
            area = new Rectangle(4, h - 13, w - 8, 10);
            StringFormat stringFormat = new StringFormat();
            stringFormat.Alignment = StringAlignment.Far;
            stringFormat.LineAlignment = StringAlignment.Center;
            g.DrawString(cardDB[card.no].attack + " / " + cardDB[card.no].toughness, new Font("MS UI Gothic", 8), Brushes.Black, area, stringFormat);

            // ノード・コストの描画
            area = new Rectangle(4, 5, w - 8, 15);
            g.DrawString("N " + cardDB[card.no].node + "  C " + cardDB[card.no].cost, new Font("MS UI Gothic", 8), Brushes.Black, area, stringFormat);

            g.Dispose();
            return img;
        }
Esempio n. 7
0
 public NetvisionCore()
 {
     int i;
     for (i = 0; i < 100; i++)
     {
         cards[i] = new Card(i, 1);
     }
     Initialize();
 }
Esempio n. 8
0
        static void ServerOnRecv(int remoteID, byte[] accptBytes)
        {
            TOPBYTE topbyte = (TOPBYTE)accptBytes[0];
            accptBytes = VisionFunctions.DeleteTopByte(accptBytes);
            if (topbyte == TOPBYTE.STRING)
            {
                string sendStr;
                sendStr = VisionFunctions.DeserializeToString(accptBytes);
                //fm1.Chat_Add(string.Format("server:client{0}からの通信>{1}", remoteID, accptStr));
                sv.Broadcast(sendStr, TOPBYTE.STRING);
            }
            else if (topbyte == TOPBYTE.NETVISIONCORE)
            {
                NetvisionCore accptCore = new NetvisionCore();
                accptCore.setAll(VisionFunctions.DeserializeToNetvisionCore(accptBytes));
                if (remoteID == sv.player1) { sv.core.setAll(accptCore); }
                else if (remoteID == sv.player2) { sv.core.setAll(accptCore.ReverseSide()); }

                // 返信
                sv.BroadcastCore();
            }
            else if (topbyte == TOPBYTE.DECK)
            {
                Card[] accptDeck = new Card[50];
                accptDeck = VisionFunctions.DeserializeToDeck(accptBytes);
                if (remoteID == sv.player1)
                {
                    for (int i = 0; i < 50; i++) sv.core.cards[i].setAll(accptDeck[i]);
                }
                else if (remoteID == sv.player2)
                {
                    for (int i = 0; i < 50; i++) sv.core.cards[50 + i].setAll(accptDeck[i]);
                }

                if (svStat == SERVERSTAT.PLAYING)
                {
                    sv.StartGame();
                    sv.BroadcastCore();
                }
            }
            else
            {
                string sendStr;
                sendStr = accptBytes.Length.ToString();
                sv.Broadcast(sendStr, TOPBYTE.STRING);
            }
        }