//private List<IRuntimeJewel> toRemoveBuff = new List<IRuntimeJewel>(); public override void OnEnterState() { //Logger.Log<EvaluateBoardState>("OnEnterState"); base.OnEnterState(); // Bring in board data IRuntimeJewel[,] jewelMap = board.GetBoardData().GetMap(); if (FindMatchesUtil.FindBestMatches(jewelMap).Count == 0) { OnResetState(); return; } List <List <IRuntimeJewel> > toRemoveBuffs = FindMatchesUtil.FindMatchesBuffer(jewelMap); foreach (var toRemoveBuff in toRemoveBuffs) { if (toRemoveBuff.Count > 3) { OnBonus(toRemoveBuff.Select((jewel) => { return(jewel.Data.JewelID); }).ToList()); } foreach (var jewel in toRemoveBuff) { OnRemove(jewel); } } if (toRemoveBuffs.Count > 0 || FindMatchesUtil.ContainsNullJewel(board.GetBoardData().GetMap())) { OnCascadeState(); } else { OnCleanBoardState(); } }
public override void OnEnterState() { base.OnEnterState(); //Debug.Log("CascadeBoardState"); List <JewelData> jewels = JewelDatabase.Instance.GetFullList(); List <IRuntimeJewel> readyJewels = new List <IRuntimeJewel>(); IRuntimeJewel[,] jewelMap = board.GetBoardData().GetMap(); int width = jewelMap.GetLength(0); int height = jewelMap.GetLength(1); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Vector2 pos = new Vector2(x, y); IRuntimeJewel jewel = FindNextJewel(jewelMap, pos); GameObject UIJewel = jewel == null ? null : GameObject.Find(jewel.JewelID); if (jewel == null || UIJewel == null) { jewel = new RuntimeJewel(jewels[Random.Range(0, jewels.Count)], pos, "Jewel_" + Count++); } else { // Rotate gem's position jewel.RotatePos(pos); // Remove old jewel position from buffer jewelMap[(int)jewel.LastPos.x, (int)jewel.LastPos.y] = null; } // Place Jewel On Board SetJewelData(jewel, pos); // Update UI readyJewels.Add(jewel); // Update temp buffer jewelMap[x, y] = jewel; } } //board.GetBoardData().PrettyJewelMap(); // Update UI foreach (IRuntimeJewel jwl in readyJewels) { OnCascadeJewel(jwl); } }
public override void OnEnterState() { // Look through all jewels IRuntimeJewel[,] jewels = board.GetBoardData().GetMap(); // Right here is where I need to look through all the jewels and see if two jewels are clicked List <IRuntimeJewel> jewelsClicked = new List <IRuntimeJewel>(); for (int x = 0; x < jewels.GetLength(0); x++) { for (int y = 0; y < jewels.GetLength(1); y++) { if (jewels[x, y].IsSelected) { jewelsClicked.Add(jewels[x, y]); } } } if (jewelsClicked.Count <= 1) { // Clean Board state GameEvents.Instance.Notify <ICleanBoard>(i => i.OnBoardCleanCheck()); } else if (jewelsClicked.Count == 2 && FindMatchesUtil.WillCauseMatch(jewels, jewelsClicked[0], jewelsClicked[1])) { // If the two jewels will cause a match, swap the jewels, then swap to evaluate board state GameEvents.Instance.Notify <ISwapBoard>(i => i.OnBoardSwapCheck()); } else { // Remove all selected board state GameEvents.Instance.Notify <IRemoveSelectedBoard>(i => i.OnBoardRemoveSelectedCheck()); } }
public void OnUnselectAll() { IRuntimeJewel[,] jewels = GameBoard.GetBoardData().GetMap(); for (int x = 0; x < jewels.GetLength(0); x++) { for (int y = 0; y < jewels.GetLength(1); y++) { jewels[x, y].DoUnselect(); } } }
public override void OnEnterState() { // Look through all jewels IRuntimeJewel[,] jewels = board.GetBoardData().GetMap(); // Right here is where I need to look through all the jewels and see if two jewels are clicked List <IRuntimeJewel> jewelsClicked = new List <IRuntimeJewel>(); for (int x = 0; x < jewels.GetLength(0); x++) { for (int y = 0; y < jewels.GetLength(1); y++) { if (jewels[x, y].IsSelected) { jewelsClicked.Add(jewels[x, y]); } } } if (jewelsClicked.Count == 2) { Vector2 pos1 = jewelsClicked[0].Pos; Vector2 pos2 = jewelsClicked[1].Pos; jewelsClicked[0].RotatePos(pos2); jewelsClicked[1].RotatePos(pos1); SetJewelData(jewelsClicked[0], jewelsClicked[0].Pos); SetJewelData(jewelsClicked[1], jewelsClicked[1].Pos); MarkPlayerSwap(); OnSwapJewel(jewelsClicked[0], jewelsClicked[1]); } //OnSwapFinished(); }
public override void OnEnterState() { // Look through all jewels IRuntimeJewel[,] jewelMap = board.GetBoardData().GetMap(); List <SwapChoices> matchesBuff = FindMatchesUtil.FindBestMatches(jewelMap); if (matchesBuff.Count == 0) { int width = jewelMap.GetLength(0); int height = jewelMap.GetLength(1); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { OnRemove(jewelMap[x, y]); } } } Notify(); }
public override void OnEnterState() { // Look through all jewels IRuntimeJewel[,] jewels = board.GetBoardData().GetMap(); // Right here is where I need to look through all the jewels and see if two jewels are clicked List <IRuntimeJewel> jewelsClicked = new List <IRuntimeJewel>(); for (int x = 0; x < jewels.GetLength(0); x++) { for (int y = 0; y < jewels.GetLength(1); y++) { if (jewels[x, y].IsSelected) { jewels[x, y].DoUnselect(); } } } OnEvaluateBoardState(); }
public void OnRemoveJewel(IRuntimeJewel jewel) { board.GetBoardData().SetJewel(null, jewel.Pos); }