Beispiel #1
0
        // ユニットマップ

        public Form1()
        {
            InitializeComponent();
            sD = new sData((int)X_num.Value, (int)Y_num.Value);
            makeCellPanel((int)X_num.Value, (int)Y_num.Value);
            //makeList(0);
            comboBox1.SelectedIndex = 0;
        }
Beispiel #2
0
        static public bool ShowMiniForm(ref sData s)
        {
            gForm f = new gForm(s);

            f.ShowDialog();
            f.Dispose();

            return(f.ReturnValue);
        }
Beispiel #3
0
        public bool ReturnValue = false; //Form1に返す戻り値

        public gForm(params sData[] argumentValues)
        {
            sD = argumentValues[0];
            InitializeComponent();
            numericUpDown1.Value    = sD.star3;
            numericUpDown2.Value    = sD.star2;
            comboBox1.SelectedIndex = sD.goalType;
            numericUpDown3.Value    = sD.goalDetail;
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            sData loadedData = sData.load();

            if (loadedData != null)
            {
                sD = loadedData;
                makeCellPanel(sD.x, sD.y);
            }
        }
Beispiel #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            //メッセージボックスを表示する
            DialogResult result = MessageBox.Show("マップサイズを変更しますか?",
                                                  "マップサイズ",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Exclamation,
                                                  MessageBoxDefaultButton.Button2);

            //何が選択されたか調べる
            if (result == DialogResult.Yes)
            {
                //「はい」が選択された時
                //Console.WriteLine("「はい」が選択されました");
                //while (flowLayoutPanel1.Controls.Count > 0) flowLayoutPanel1.Controls.RemoveAt(0);
                sD = new sData((int)X_num.Value, (int)Y_num.Value);
                makeCellPanel((int)X_num.Value, (int)Y_num.Value);
            }
        }
Beispiel #6
0
        //ファイルから読み取り
        public static sData load()
        {
            //開くファイルを選択するダイアログを開く
            sData          loadedData = null;
            OpenFileDialog ofd        = new OpenFileDialog();

            ofd.Filter = "ステージデータ(*.sdt)|*.sdt" + "|All Files|*.*";
            //ofd.InitialDirectory = Directory.GetCurrentDirectory() + @"\Userdata";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                //ファイルをバイナリ読込
                Stream fileStream = ofd.OpenFile();
                byte[] data       = new byte[fileStream.Length];
                fileStream.Read(data, 0, data.Length);

                // マジックチェック
                if (magic.SequenceEqual(data.Take(2).ToArray()))
                {
                    // バージョンチェック
                    if (version == data[2])
                    {
                        loadedData       = new sData(data[8], data[9]);
                        loadedData.star3 = data[4] * 255 + data[5];
                        loadedData.star2 = data[6] * 255 + data[7];

                        int cnt = 10;
                        // タイル情報登録
                        for (int i = 0; i < loadedData.x; i++)
                        {
                            for (int j = 0; j < loadedData.y; j++)
                            {
                                loadedData.tMap[i, j] = data[cnt];
                                cnt++;
                            }
                        }

                        // ユニット情報
                        int unitNum = data[cnt];
                        cnt++;
                        for (int i = 0; i < unitNum; i++)
                        {
                            loadedData.uMap[data[cnt], data[cnt + 1]] = data[cnt + 2];
                            //unitObj.addUnit("test_" + i, (uType)Enum.ToObject(typeof(uType), loadData[cnt + 2]), new Vector2Int(loadData[cnt], loadData[cnt + 1]));
                            cnt += 4;
                        }

                        // ゴール条件
                        loadedData.goalType = data[cnt];
                        cnt++;
                        loadedData.goalDetail = data[cnt];
                    }
                    else
                    {
                        MessageBox.Show("ファイルバージョンが違います。", "エラー",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("ファイルフォーマットが違います。", "エラー",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            return(loadedData);
        }