public void UpRand(int x, MyBoard board) { if (_curEnd == 0) board.arrSquares[curIndex].status = 0; if (x > _curEnd) { board.arrEndSquares[nType - 1].empty[_curEnd] = true; _curEnd = x - 1; board.arrEndSquares[nType - 1].empty[_curEnd] = false; _curPoint = board.arrEndSquares[nType - 1].p[_curEnd]; SoundPlayer sound = new SoundPlayer(@"Resources\Audio\UpRand.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); if (_curEnd >= 2) { int dem = 0; for (int i = 5; i > _curEnd; i--) { if (!board.arrEndSquares[nType - 1].empty[i]) dem++; } if (dem == (5 - _curEnd)) this._isFinish = true; } } }
public bool UpRandFail(int x, MyBoard board) { if (x - 1 <= _curEnd && x != 1) return true; for (int i = x - 1; i > _curEnd; i--) if (!board.arrEndSquares[nType - 1].empty[i]) return true; return false; }
public vicPiece MoveSteponStep(MyBoard board, int index) { vicPiece vic = new vicPiece(); vic.index = -1; vic.nType = 0; IsChoice = true; board.arrSquares[curIndex].status = 0; board.arrSquares[curIndex].curIndex = -1; board.arrSquares[curIndex].shadow = 0; board.arrSquares[curIndex].shield = 0; curIndex = (curIndex + 1) % 56; if (board.arrSquares[_curIndex].bomb != 0 && board.arrSquares[_curIndex].bomb != nType && Buff != 6 && Buff != 2) //Co bomb k fai cua doi minh { board.arrSquares[_startIndex].shield = 0; board.arrSquares[_startIndex].shadow = 0; board.arrSquares[_curIndex].bomb = 0; InCage(); vic.nType = -2; SoundPlayer sound1 = new SoundPlayer(@"Resources\Audio\ExClose.wav"); sound1.LoadAsync(); sound1.Play(); Started = false; Ended = false; sound1.Dispose(); return vic; } if (board.arrSquares[_curIndex].shadow != 1 && board.arrSquares[_curIndex].status != nType) { vic.nType = board.arrSquares[_curIndex].status; vic.index = board.arrSquares[_curIndex].curIndex; } if (board.arrSquares[curIndex].status == nType) // nguoi doi minh curIndex = (curIndex + 1) % 56; _curPoint = board.arrSquares[curIndex].square; board.arrSquares[_curIndex].status = nType; board.arrSquares[_curIndex].curIndex = index; if (curIndex == _endIndex) _ended = true; return vic; }
public vicPiece Start(MyBoard board, int index) { vicPiece vic = new vicPiece(); vic.index = -1; vic.nType = 0; //KT bomb if (board.arrSquares[_startIndex].bomb != 0 && board.arrSquares[_startIndex].bomb != nType && Buff != 2) //Co bomb k fai cua doi minh { board.arrSquares[_startIndex].shield = 0; board.arrSquares[_startIndex].shadow = 0; InCage(); board.arrSquares[_startIndex].bomb = 0; SoundPlayer sound1 = new SoundPlayer(@"Resources\Audio\ExClose.wav"); sound1.LoadAsync(); sound1.Play(); sound1.Dispose(); Started = false; Ended = false; return vic; } if (board.arrSquares[_startIndex].shadow != 1) { vic.nType = board.arrSquares[_startIndex].status; vic.index = board.arrSquares[_startIndex].curIndex; } _curPoint = start; _curIndex = _startIndex; board.arrSquares[_curIndex].status = nType; board.arrSquares[_curIndex].curIndex = index; SoundPlayer sound = new SoundPlayer(@"Resources\Audio\Start.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); return vic; }
public bool IsStarted(MyBoard board, int x) { if ((x != 1 && x != 6) || ((x == 1 || x == 6) && !emptyStart(board))) return false; return true; }
public bool moveFail(int x, MyBoard board) { //Kiem tra diem toi if (board.arrSquares[(curIndex + x) % 56].status == this.nType) return true; for (int i = 1; i < x; i++) { if ((curIndex + i) % 56 == _endIndex) return true; } //Diem toi k fai minh va cross if (Buff == 6) return false; //Kiem tra diem toi co shield khong if (board.arrSquares[(_curIndex + x) % 56].shield == 2) return true; //Kiem tra o giua for (int i = 1; i < x; i++) { if ((board.arrSquares[(curIndex + i) % 56].status != 0 && board.arrSquares[(curIndex + i) % 56].shadow != 1)) return true; } return false; }
public bool emptyStart(MyBoard board) { if (board.arrSquares[_startIndex].status == this.nType || board.arrSquares[_startIndex].shield == 2) return false; return true; }
public void Draw(Graphics g, MyBoard board, int index) { Bitmap bmp = new Bitmap(12, 12); Bitmap bmp1 = new Bitmap(24, 24); /*if (Started && !Ended) { board.arrSquares[_curIndex% 56].status = nType; board.arrSquares[_curIndex% 56].curIndex = index; }*/ if (Buff != 0 && Buff != 3 && Buff != 4) // Co buff { switch (Buff) { case 1: { bmp = new Bitmap(@"Resources\ImageIcon\hide.PNG"); if (Started && !Ended) board.arrSquares[_curIndex % 56].shadow = this.Buff; } break; case 2: { bmp = new Bitmap(@"Resources\ImageIcon\shield.PNG"); if (Started && !Ended) board.arrSquares[_curIndex % 56].shield = this.Buff; } break; case 5: bmp = new Bitmap(@"Resources\ImageIcon\speedup.PNG"); break; case 6: bmp = new Bitmap(@"Resources\ImageIcon\cross.PNG"); break; } g.DrawImage(bmp, _curPoint.X + 18, _curPoint.Y, 20, 20); } if (this.IsChoice) { bmp1 = new Bitmap(RacingHorses.imgarr.Images[nType - 1]); g.DrawImage(bmp1, _curPoint.X, _curPoint.Y - 20, 20, 20); } bmp.Dispose(); bmp1.Dispose(); g.DrawImage(Img, _curPoint.X, _curPoint.Y, 20, 30); }
public void clearBuff(MyBoard board) { Buff = 0; if (Started && !Ended) { board.arrSquares[curIndex].shield = 0; board.arrSquares[curIndex].shadow = 0; } }
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// private void RacingHorses_Load(object sender, EventArgs e) { for (int i = 0; i < 4; i++) { AiProps[i] = new MyProps(); } pShake.Image = imglstShake.Images[0]; pShake.Visible = false; imgarr = imglstArrow; pString.Visible = false; btnBuff[0] = btnHide; btnBuff[1] = btnShield; btnBuff[2] = btnGetTurn; btnBuff[3] = btnBomb; btnBuff[4] = btnSpeedup; btnBuff[5] = btnCross; cage = new MyCage[nCage]; board = new MyBoard(); for (int i = 0; i < 4; i++) { bool b = false; for (int t = 0; t < teamchoose.Count; t++) { if (i == teamchoose[t]) b = true; } cage[i] = new MyCage(i + 1, 4, board, b); } dice = new MyDice(); turn = 0; nextturn = 0; vic = new vicPiece(); vic.index = -1; vic.nType = 0; if (!hasProp) board.props = false; btnShake.Visible = false; if (cage[0].isPlayer) { btnShake.Visible = true; } else { pShake.Visible = true; thread_AI = new Thread(Thread_AI); thread_AI.Start(); } }
public void UseProps(int propsindex, MyCage cage, MyBoard board, int nType) { if (board.props) { switch (propsindex) { case 1: { Hide = false; cage.Hide= true; } break; case 2: { Shield = false; cage.Shield = true; } break; case 3: { GetTurn = false; cage.Useprop = true; cage.GetTurn = true; } break; case 4: { Bomb = false; for (int i = 0; i < cage.nPieces; i++) { if (cage.Pieces[i].Started && cage.Pieces[i].curEnd == 0) //Da ra khoi chuong va chua len bac { int index = cage.Pieces[i].curIndex; board.arrSquares[index].bomb = nType; //bomb do doi nType dat RacingHorses.bombarr.Add(index); } } } break; case 5: { SpeedUp = false; cage.Useprop = true; cage.SpeedUp = true; } break; case 6: { Cross = false; cage.Useprop = true; cage.Cross = true; } break; } if (propsindex == 1 || propsindex == 2 || propsindex == 5 || propsindex == 6) for (int i = 0; i < cage.nPieces; i++) { cage.Pieces[i].Buff = propsindex; } } }