Ejemplo n.º 1
0
        private void frmPlay_Load(object sender, EventArgs e)
        {
            //Thêm dữ liệu cho combobox Level & thêm menu con của mnuLevel
            LoadComboBoxLevel();
            //Load game theo điều kiện, nếu cấp độ có game đã lưu => Load lại game lưu
            LuotChoi lcdaluu = null;

            if ((int)this.chucNang == 1)
            {
                lcdaluu = getData.GetLuotChoiDaLuu(1);
                if (lcdaluu != null)
                {
                    List <Cell> lstCell = new List <Cell>();
                    lstCell = lcdaluu.Cells.ToList();

                    setData.DeleteLuotChoi(lcdaluu.maLuotChoi, lstCell);
                    LoadGameByGameSaved(1, lstCell, (int)lcdaluu.thoiGian);
                }
                else
                {
                    LoadGame(1);
                }
            }
            else if ((int)this.chucNang == 2)
            {
                LoadGame(1);
            }
            else // ((int)this.chucNang == 0)
            {
                LoadGameBySetup();
            }

            btnStart.Enabled     = true;
            this.pnlPlay.Enabled = false;
            btnIdea.Enabled      = false;
            btnResetGame.Enabled = false;
            //
            switch (chucNang)
            {
            case menuChucNang.play1:
                rdo1Player.Checked = true;
                break;

            case menuChucNang.play2:
                rdo2Player.Checked = true;
                break;

            default:
                rdo1Player.Checked = rdo2Player.Checked = false;
                break;
            }
            HienThiFormTheoChucNang(chucNang);
        }
Ejemplo n.º 2
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            btnStart.Enabled     = true;
            pnlPlay.Enabled      = false;
            btnIdea.Enabled      = false;
            btnResetGame.Enabled = false;

            if (rdo1Player.Checked)
            {
                chucNang = menuChucNang.play1;
            }
            else if (rdo2Player.Checked)
            {
                chucNang = menuChucNang.play2;
            }
            else
            {
                MessageBox.Show("Bạn hãy chọn số Players!!");
                return;
            }

            try
            {
                board.TimeRun.Stop();
                pnlPlay.Controls.Clear();
                int      ma      = (int)cboLevel.SelectedValue;
                LuotChoi lcdaluu = null;
                if ((int)this.chucNang == 1)
                {
                    lcdaluu = getData.GetLuotChoiDaLuu(ma);
                    if (lcdaluu != null)
                    {
                        List <Cell> lstCell = new List <Cell>();
                        lstCell = lcdaluu.Cells.ToList();

                        setData.DeleteLuotChoi(lcdaluu.maLuotChoi, lstCell);
                        LoadGameByGameSaved(ma, lstCell, (int)lcdaluu.thoiGian);
                    }
                    else
                    {
                        LoadGame(ma);
                    }
                }
                else //if ((int)this.chucNang == 2)
                {
                    LoadGame(ma);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Ejemplo n.º 3
0
        public void SaveGame(string tenNguoiChoi)
        {
            try
            {
                int      maCapDo = this.c.maCapDo;
                LuotChoi luot    = new LuotChoi();
                var      temp    = getData.GetMaLuotChoiCuoi();
                luot.maLuotChoi = temp + 1;
                if (tenNguoiChoi != null)
                {
                    luot.tenNguoiChoi = tenNguoiChoi;
                }
                else
                {
                    luot.tenNguoiChoi = null;
                }
                luot.thoiGian = int.Parse(lblTime.Text);
                luot.maCapDo  = maCapDo;

                List <Cell> lstCell = this.board.GetDSCell();
                foreach (Cell c in lstCell)
                {
                    int maC = getData.GetMaCellCuoi();
                    c.maCell     = maC + 1 + lstCell.IndexOf(c);
                    c.maLuotChoi = luot.maLuotChoi;
                }
                if (setData.SaveLuotChoi(luot, lstCell))
                {
                    MessageBox.Show("Thành công!!");
                }
                else
                {
                    MessageBox.Show("Thất bại!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
 partial void DeleteLuotChoi(LuotChoi instance);
 partial void UpdateLuotChoi(LuotChoi instance);
 partial void InsertLuotChoi(LuotChoi instance);
 private void detach_LuotChois(LuotChoi entity)
 {
     this.SendPropertyChanging();
     entity.CapDo = null;
 }
 private void attach_LuotChois(LuotChoi entity)
 {
     this.SendPropertyChanging();
     entity.CapDo = this;
 }