Пример #1
0
        private void BombMove(Bombs bombList, Skiers skiList, Bricks brickList)
        {
            Int32 countSkier = 0;

            Int32 [] IndSkier  = new Int32[bombList.CountPlayer];
            Int32    countBomb = 0;

            Int32 [] IndBomb = new Int32[bombList.CountPlayer];
            foreach (Bomb st in bombList)
            {
                if (Map.GetItem(st.TOP / 25 + 1, st.LEFT / 25) == ItemName.Skier)
                {
                    foreach (Skier sk in skiList)
                    {
                        if ((st.LEFT == sk.LEFT) && (st.TOP == (sk.TOP - 25)))
                        {
                            IndSkier[countSkier] = skiList.IndexOf(sk);
                            IndBomb[countBomb]   = bombList.IndexOf(st);
                            Invalidate(new Rectangle(sk.LEFT, sk.TOP, 25, 25));
                            Invalidate(new Rectangle(st.LEFT, st.TOP, 25, 25));
                            Map.SetItem(st.TOP / 25, st.LEFT / 25, ItemName.Null);
                            Map.SetItem(sk.TOP / 25, sk.LEFT / 25, ItemName.Null);
                            countSkier++;
                            countBomb++;
                        }
                    }
                }
            }
            Array.Sort(IndSkier);
            Array.Reverse(IndSkier);

            Array.Sort(IndBomb);
            Array.Reverse(IndBomb);

            for (int i = 0; i < countBomb; i++)
            {
                bombList.RemovePlayer(IndBomb[i]);
            }
            for (int i = 0; i < countSkier; i++)
            {
                skiList.RemovePlayer(IndSkier[i]);
            }

            foreach (Bomb st in bombList)
            {
                if (st.Moving(trac) == true)
                {
                    if (st.BombDirec == Direction.Down)
                    {
                        InvalidateDown(st);
                    }
                    if (st.BombDirec == Direction.Left)
                    {
                        InvalidateLeft(st);
                    }
                    if (st.BombDirec == Direction.Right)
                    {
                        InvalidateRight(st);
                    }
                }
            }
        }
Пример #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);
                        Map.SetInd(sk.TOP / 25, sk.LEFT / 25, skiList.IndexOf(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;
        }