public void LoadContent(ContentManager content, GameScreen _mainGame) { m_mainGame = (MainGameScreen)_mainGame; m_content = content; gameFont = content.Load <SpriteFont>("Font/GameFont"); m_gridState = Grid_State.Falling; Cell tempCell; for (int i = 0; i < COL; i++) { for (int j = 0; j < ROW; j++) { if (m_board[i, j] == 1) { int randomNumber = 0; if (Global.GAMEMODE == GameMode.EasyClassic) { randomNumber = random.Next(1, 5); } if (Global.GAMEMODE == GameMode.NormalClassic || Global.GAMEMODE == GameMode.Level) { randomNumber = random.Next(1, 6); } Cell_Type type = (Cell_Type)randomNumber; tempCell = new Cell(this); tempCell.LoadContent(content, i - COL, j, type); m_listNewCell.Add(tempCell); } } } Falling(); }
public void DragCompleteHandle() { switch (m_listTouch.Count) { case 0: break; case 1: m_listTouch[0].setEndTouch(false); m_gridState = Grid_State.Wait; m_currentCellType = Cell_Type.None; break; case 2: m_listTouch[0].setEndTouch(true); m_listTouch[0].m_direction = m_listTouch[1].m_position; m_listTouch[1].setEndTouch(true); m_listTouch[1].m_direction = m_listTouch[0].m_position; if (m_gridState == Grid_State.Touching) { m_gridState = Grid_State.ToTwo; } m_countBeExplosion = m_listTouch.Count; m_mainGame.SetPoint(m_currentCellType, 2, m_lastCellPos); SoundManager.GetInstance().PlaySound(ESound.FailCell); break; default: for (int i = 0; i < m_listTouch.Count; i++) { if (m_listTouch[i].m_indexI == m_lastIndexI && m_listTouch[i].m_indexJ == m_lastIndexJ) { m_listTouch[i].SetWaitAction(); } else { m_listTouch[i].setEndTouch(true); m_listTouch[i].m_direction = m_lastCellPos; } } Global.isFly = true; SwitchTouchingTo(); //CalculatorPoint(); m_countBeExplosion = m_listTouch.Count; break; } if (m_listTouch.Count >= 1) { randomCell(m_listTouch.Count); } if (m_listTouch.Count > 0) { m_countCell = m_listTouch.Count; } m_listTouch.Clear(); }
bool SwitchTouchingToGold() { if (m_gridState == Grid_State.Touching && (m_listTouch.Count >= 3) && (m_currentCellType == Cell_Type.Type06 || m_currentCellType == Cell_Type.Type07)) { m_gridState = Grid_State.ToGold; } return(false); }
bool SwitchTouchingToFinal() { if (m_gridState == Grid_State.Touching && m_listTouch.Count >= 3 && m_currentCellType == Cell_Type.Type08) { m_gridState = Grid_State.ToFinal; return(true); } return(false); }
bool SwitchTouchingToFive() { if (m_gridState == Grid_State.Touching && (m_listTouch.Count >= 5) && (m_currentCellType == Cell_Type.Type01 || m_currentCellType == Cell_Type.Type02 || m_currentCellType == Cell_Type.Type03 || m_currentCellType == Cell_Type.Type04 || m_currentCellType == Cell_Type.Type05)) { m_gridState = Grid_State.ToFive; } return(false); }
public void Reset(ContentManager content) { m_listTouch.Clear(); m_listCell.Clear(); m_listNewCell.Clear(); m_listRandomType.Clear(); m_currentRandomType = 0; m_gridState = Grid_State.Falling; m_lastCellPos = Vector2.Zero; m_lastIndexI = 0; m_lastIndexJ = 0; m_currentCellType = Cell_Type.None; m_countCell = 0; m_countBeExplosion = 0; m_countFalling = 0; Cell tempCell; for (int i = 0; i < COL; i++) { for (int j = 0; j < ROW; j++) { if (m_board[i, j] == 1) { int randomNumber = 0; if (Global.GAMEMODE == GameMode.EasyClassic) { randomNumber = random.Next(1, 5); } if (Global.GAMEMODE == GameMode.NormalClassic || Global.GAMEMODE == GameMode.Level) { randomNumber = random.Next(1, 6); } Cell_Type type = (Cell_Type)randomNumber; tempCell = new Cell(this); tempCell.LoadContent(content, i - COL, j, type); m_listNewCell.Add(tempCell); } } } Falling(); }
void InputHandle(GameTime gameTime) { if ((GesturesInput.GetInstance().GetGestureType() == GestureType.FreeDrag || GesturesInput.GetInstance().GetGestureType() == GestureType.HorizontalDrag || GesturesInput.GetInstance().GetGestureType() == GestureType.Hold || GesturesInput.GetInstance().GetGestureType() == GestureType.VerticalDrag) && (m_gridState == Grid_State.Wait || m_gridState == Grid_State.Touching)) { Vector2 posTap = GesturesInput.GetInstance().GetGesturePosition(); int tempI = (int)(posTap.Y - EXTRAPOS.Y) / TILE; int tempJ = (int)(posTap.X - EXTRAPOS.X) / TILE; for (int i = 0; i < m_listCell.Count; i++) { if (m_listCell[i].IsContain(posTap)) { if (isAvailable(tempI, tempJ) && (m_currentCellType == m_listCell[i].m_type || m_currentCellType == Cell_Type.None)) { m_lastCellPos = m_listCell[i].m_position; m_lastIndexI = m_listCell[i].m_indexI; m_lastIndexJ = m_listCell[i].m_indexJ; if (m_listCell[i].m_state == Cell_State.NoTouch) { switch (m_listCell[i].m_type) { case Cell_Type.Type01: SoundManager.GetInstance().PlaySound(ESound.TouchType1); break; case Cell_Type.Type02: SoundManager.GetInstance().PlaySound(ESound.TouchType2); break; case Cell_Type.Type03: SoundManager.GetInstance().PlaySound(ESound.TouchType3); break; case Cell_Type.Type04: SoundManager.GetInstance().PlaySound(ESound.TouchType4); break; case Cell_Type.Type05: SoundManager.GetInstance().PlaySound(ESound.TouchType5); break; case Cell_Type.Type06: SoundManager.GetInstance().PlaySound(ESound.TouchType6); break; case Cell_Type.Type07: SoundManager.GetInstance().PlaySound(ESound.TouchType7); break; case Cell_Type.Type08: SoundManager.GetInstance().PlaySound(ESound.TouchType8); break; } m_listCell[i].setBeginTouch(); m_listTouch.Add(m_listCell[i]); if (m_currentCellType == Cell_Type.None) { m_currentCellType = m_listCell[i].m_type; m_gridState = Grid_State.Touching; } } } } } } if (GesturesInput.GetInstance().GetGestureType() == GestureType.DragComplete) { DragCompleteHandle(); } if (m_countFalling == 0 && m_gridState == Grid_State.Falling) { m_gridState = Grid_State.Wait; } }
public void removeCell(Cell _cell, bool isLast) { if (!isLast) { if (m_countCell >= 3) { SoundManager.GetInstance().PlaySound(ESound.Fly); } } else { SoundManager.GetInstance().PlaySound(ESound.CompleteCell); } m_countBeExplosion--; if (!isLast) { CreateNew(_cell); } m_listCell.Remove(_cell); if (isLast) { m_mainGame.SetGoal(m_currentCellType, m_countCell); if (m_countCell >= 3) { m_mainGame.SetPoint(m_currentCellType, m_countCell, m_lastCellPos); m_mainGame.SetTime(m_currentCellType, m_countCell); } } if (m_gridState == Grid_State.ToTwo) { //m_mainGame.SetPoint(m_currentCellType, m_countCell, m_lastCellPos); } if (m_gridState == Grid_State.ToThree) { if (isLast) { CreateNew(_cell); } } if (m_gridState == Grid_State.ToFour) { if (isLast) { Create(); } } if (m_gridState == Grid_State.ToFive) { if (isLast) { Create(); } } if (m_gridState == Grid_State.ToGold) { if (isLast) { Create(); } } if (m_gridState == Grid_State.ToFinal) { if (isLast) { CreateNew(_cell); } } if (m_countBeExplosion == 0) { m_gridState = Grid_State.Falling; Falling(); m_currentCellType = Cell_Type.None; } }