예제 #1
0
        private void On_Open(object sender, System.EventArgs e)
        {
            CloseConnection();

            trac.LIFE = 1;             // !!!
            OpenFileDialog Open = new OpenFileDialog();

            Open.InitialDirectory = ".";
            Open.Filter           = "tractor files(*.tra)|*.tra|All files(*.*)|*.*";
            Open.FilterIndex      = 1;
            Open.RestoreDirectory = true;

            if (Open.ShowDialog() == DialogResult.OK)
            {
                brickList.ClearAll();
                blueBrickList.ClearAll();
                soilList.ClearAll();
                stoneList.ClearAll();
                skiList.ClearAll();
                bombList.ClearAll();

                Stream myStream = Open.OpenFile();
                if (myStream != null)
                {
                    BinaryFormatter myBin = new BinaryFormatter();
                    List = (PlaceList)myBin.Deserialize(myStream);

                    List.SetList(ref brickList, ref blueBrickList, ref soilList,
                                 ref stoneList, ref skiList, ref bombList, ref trac, ref trac2);

                    myStream.Close();
                    this.IsCreateNewMap    = false;
                    this.timer1.Enabled    = true;
                    menuItemCreate.Visible = true;

                    menuItemPlayer.Enabled    = false;
                    menuItemSkier.Enabled     = false;
                    menuItemBomb.Enabled      = false;
                    menuItemStone.Enabled     = false;
                    menuItemSoil.Enabled      = false;
                    menuItemBrick.Enabled     = false;
                    menuItemBlueBrick.Enabled = false;

                    Map.ClearMap();

                    foreach (Skier sk in skiList)
                    {
                        Map.SetItem(sk);
                    }
                    foreach (Stone st in stoneList)
                    {
                        Map.SetItem(st);
                    }
                    foreach (Bomb bo in bombList)
                    {
                        Map.SetItem(bo);
                    }
                    foreach (Brick br in brickList)
                    {
                        Map.SetItem(br);
                    }
                    foreach (BlueBrick bbr in blueBrickList)
                    {
                        Map.SetItem(bbr);
                    }
                    foreach (Soil so in soilList)
                    {
                        Map.SetItem(so);
                    }
                    Map.SetItem(trac);
                    Map.SetItem(trac2);

                    IfCreatureMoving = true;

                    this.timer1.Enabled = true;
                }
            }
            Invalidate();
        }
예제 #2
0
        private void On_Save_as(object sender, System.EventArgs e)
        {
            this.timer1.Enabled = false;

            SaveFileDialog mySave = new SaveFileDialog();

            mySave.InitialDirectory = ".";
            mySave.Filter           = "tractor files(*.tra)|*.tra|All files(*.*)|*.*";
            mySave.FilterIndex      = 1;
            mySave.RestoreDirectory = true;
            mySave.FileName         = "trac";

            if (mySave.ShowDialog() == DialogResult.OK)
            {
                List = new PlaceList(brickList, blueBrickList, soilList,
                                     stoneList, skiList, bombList, trac, trac2);

                Stream myStream = mySave.OpenFile();
                if (myStream != null)
                {
                    BinaryFormatter myBin = new BinaryFormatter();
                    myBin.Serialize(myStream, List);
                    myStream.Close();
                    this.IsCreateNewMap    = false;
                    this.timer1.Enabled    = true;
                    menuItemCreate.Visible = true;

                    menuItemPlayer.Enabled    = false;
                    menuItemSkier.Enabled     = false;
                    menuItemBomb.Enabled      = false;
                    menuItemStone.Enabled     = false;
                    menuItemSoil.Enabled      = false;
                    menuItemBrick.Enabled     = false;
                    menuItemBlueBrick.Enabled = false;

                    Map.ClearMap();
                    foreach (Skier sk in skiList)
                    {
                        Map.SetItem(sk);
                    }
                    foreach (Stone st in stoneList)
                    {
                        Map.SetItem(st);
                    }
                    foreach (Bomb bo in bombList)
                    {
                        Map.SetItem(bo);
                    }
                    foreach (Brick br in brickList)
                    {
                        Map.SetItem(br);
                    }
                    foreach (BlueBrick bbr in blueBrickList)
                    {
                        Map.SetItem(bbr);
                    }
                    foreach (Soil so in soilList)
                    {
                        Map.SetItem(so);
                    }
                    Map.SetItem(trac);
                    Map.SetItem(trac2);
                }
            }
            this.timer1.Enabled = true;
        }