public override void Run(HexBoardTile tile) { List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); HexBoardTile[] runTiles = new HexBoardTile[2] { tile.adjTiles[(int)Hexinal.W], tile.adjTiles[(int)Hexinal.E] }; bool isDone = false; while (!isDone) { isDone = true; visualUpdateTiles.Clear(); if (runTiles[0] != null) { isDone = false; runTiles[0].UpdateElement(-1); visualUpdateTiles.Add(runTiles[0]); runTiles[0] = runTiles[0].adjTiles[(int)Hexinal.W]; } if (runTiles[1] != null) { isDone = false; runTiles[1].UpdateElement(-1); visualUpdateTiles.Add(runTiles[1]); runTiles[1] = runTiles[1].adjTiles[(int)Hexinal.E]; } BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); } }
public override void Run(HexBoardTile tile) { HexBoardTile runTile = tile; bool nextIsRight = false; bool hasHitSomething = false; while (!hasHitSomething) { if (nextIsRight) { runTile = runTile.adjTiles[(int)Hexinal.SE]; } else { runTile = runTile.adjTiles[(int)Hexinal.SW]; } if (runTile == null) { hasHitSomething = true; } else { hasHitSomething = (runTile.ReadElementID() != -1); runTile.UpdateElement(id); } nextIsRight = !nextIsRight; BoardVisualUpdateSequencer.AddToQueue(runTile); } }
public override void Run(HexBoardTile tile) { HexBoardTile[] runTiles = new HexBoardTile[6]; List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); tile.adjTiles.CopyTo(runTiles, 0); int[] prevID = new int[6] { -1, -1, -1, -1, -1, -1 }; int temp = -1; bool isDone = false; while (!isDone) { isDone = true; visualUpdateTiles.Clear(); for (int i = 0; i < 6; i++) { if (runTiles[i] != null) { isDone = false; temp = runTiles[i].ReadElementID(); runTiles[i].UpdateElement(prevID[i]); visualUpdateTiles.Add(runTiles[i]); prevID[i] = temp; runTiles[i] = runTiles[i].adjTiles[i]; } } BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); } }
public override void Run(HexBoardTile tile) { List <HexBoardTile> runtiles = new List <HexBoardTile>(); List <HexBoardTile> runtilesQueue = new List <HexBoardTile>(); List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); runtiles.Add(tile); while (runtiles.Count > 0) { for (int i = 0; i < 6; i++) { if (runtiles[0].adjTiles[i] != null && runtiles[0].adjTiles[i].ReadElementID() == -1) { for (int a = 0; a < 6; a++) { if (runtiles[0].adjTiles[i].adjTiles[a] != null && runtiles[0].adjTiles[i].adjTiles[a].ReadElementID() >= 0 && runtiles[0].adjTiles[i].adjTiles[a].ReadElementID() != id) { runtiles[0].adjTiles[i].UpdateElement(id); visualUpdateTiles.Add(runtiles[0].adjTiles[i]); runtilesQueue.Add(runtiles[0].adjTiles[i]); break; } } } } runtiles.RemoveAt(0); if (runtiles.Count == 0) { BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); visualUpdateTiles.Clear(); runtiles.AddRange(runtilesQueue); runtilesQueue.Clear(); } } }
public override void Run(HexBoardTile tile) { List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); int[] ids = new int[6]; for (int i = 0; i < tile.adjTiles.Length; i++) { if (tile.adjTiles[i] != null) { HexBoardTile ht = tile.adjTiles[(i + 1) % tile.adjTiles.Length]; if (ht != null) { ids[i] = ht.ReadElementID(); } else { ids[i] = -1; } } } for (int i = 0; i < tile.adjTiles.Length; i++) { if (tile.adjTiles[i] != null) { tile.adjTiles[i].UpdateElement(ids[i]); visualUpdateTiles.Add(tile.adjTiles[i]); } } BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); }
public static void EndTurn() { for (int i = 0; i < endTurnEffectsTiles.Count; i++) { HexBoardTile ht = endTurnEffectsTiles.ElementAt(i); if (ht.ReadElementID() != -1) { GridElementManager.elements[ht.ReadElementID()].OnTurnEnd(ht); } else { //endTurnEffectsTiles.Remove(endTurnEffectsTiles.ElementAt(i)); i--; //Debug.Log("Invalid End Turn Effect!"); } } for (int i = 0; i < endTurnUpdateQueue.Count; i++) { endTurnUpdateQueue[i].UpdateElement(endTurnUpdateQueueId[i]); } BoardVisualUpdateSequencer.AddToQueue(endTurnUpdateQueue); for (int i = 0; i < endTurnEffectsTilesQueue.Count; i++) { endTurnEffectsTiles.Add(endTurnEffectsTilesQueue.ElementAt(i)); } endTurnEffectsTilesQueue.Clear(); endTurnUpdateQueue.Clear(); endTurnUpdateQueueId.Clear(); }
public override void Run(HexBoardTile tile) { HexBoardTile[] runTiles = new HexBoardTile[6]; tile.adjTiles.CopyTo(runTiles, 0); bool isDone = false; while (!isDone) { isDone = true; List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); for (int i = 0; i < 6; i++) { if (runTiles[i] == null) { continue; } else { if (runTiles[i].ReadElementID() == -1) { runTiles[i].UpdateElement(id); visualUpdateTiles.Add(runTiles[i]); isDone = false; runTiles[i] = runTiles[i].adjTiles[i]; } else { runTiles[i] = null; } } } BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); } }
public override void Run(HexBoardTile tile) { List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); for (int i = 0; i < tile.adjTiles.Length; i++) { if (tile.adjTiles[i] != null) { tile.adjTiles[i].UpdateElement(-1); visualUpdateTiles.Add(tile.adjTiles[i]); } } BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); }
public override void Run(HexBoardTile tile) { HexBoardTile tile2run = tile.adjTiles[(int)Hexinal.W]; if (tile2run != null) { BoardVisualUpdateSequencer.AddToQueue(tile2run); tile2run.UpdateElement(tile2run.ReadElementID()); if (tile2run.ReadElementID() >= 0) { GridElementManager.elements[tile2run.ReadElementID()].Run(tile2run); } } }
public override void Run(HexBoardTile tile) { HexBoardTile runTile = tile; for (int i = 0; i < 6; i++) { while (runTile.adjTiles[i] != null && runTile.adjTiles[i].ReadElementID() == -1) { runTile = runTile.adjTiles[i]; runTile.UpdateElement(id); BoardVisualUpdateSequencer.AddToQueue(runTile); } } }
public override void Run(HexBoardTile tile) { HexBoardTile[] runTiles = new HexBoardTile[6]; List <List <HexBoardTile> > visualUpdateGroup = new List <List <HexBoardTile> >(); List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); tile.adjTiles.CopyTo(runTiles, 0); bool isDone = false; while (!isDone) { isDone = true; visualUpdateTiles.Clear(); for (int i = 0; i < 6; i++) { if (runTiles[i] == null) { continue; } visualUpdateTiles.Add(runTiles[i]); if (runTiles[i].adjTiles[i] != null) { runTiles[i].UpdateElement(runTiles[i].adjTiles[i].ReadElementID()); runTiles[i] = runTiles[i].adjTiles[i]; isDone = false; } else { runTiles[i].UpdateElement(-1); runTiles[i] = null; } } visualUpdateGroup.Add(new List <HexBoardTile>(visualUpdateTiles)); } visualUpdateGroup.Reverse(); BoardVisualUpdateSequencer.AddToQueue(visualUpdateGroup); }
public override void Run(HexBoardTile tile) { List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); List <HexBoardTile> checkList = new List <HexBoardTile>(tile.adjTiles); List <HexBoardTile> checkListQueue = new List <HexBoardTile>(); while (checkList.Count > 0 || checkListQueue.Count > 0) { visualUpdateTiles.Clear(); while (checkList.Count > 0) { if (checkList[0] != null && checkList[0].ReadElementID() == -1) { checkList[0].UpdateElement(id); visualUpdateTiles.Add(checkList[0]); checkListQueue.AddRange(checkList[0].adjTiles); } checkList.RemoveAt(0); } checkList.AddRange(new List <HexBoardTile>(checkListQueue)); checkListQueue.Clear(); BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); } }
public override void Run(HexBoardTile tile) { List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); HexBoardTile pivot = tile; while (true) { if (pivot.adjTiles[(int)Hexinal.W] != null) { pivot = pivot.adjTiles[(int)Hexinal.W]; } else { break; } } HexBoardTile[] axialRunTiles = new HexBoardTile[2] { pivot.adjTiles[(int)Hexinal.SE], pivot.adjTiles[(int)Hexinal.NE] }; HexBoardTile[] runTiles = new HexBoardTile[2]; int idToCopy = -1; while (true) { visualUpdateTiles.Clear(); axialRunTiles.CopyTo(runTiles, 0); bool rowDone = false; while (!rowDone) { rowDone = true; if (runTiles[0] != null) { rowDone = false; idToCopy = runTiles[0].ReadElementID(); runTiles[0].UpdateElement(idToCopy); visualUpdateTiles.Add(runTiles[0]); runTiles[0] = runTiles[0].adjTiles[(int)Hexinal.E]; } else { idToCopy = -1; } if (runTiles[1] != null) { rowDone = false; runTiles[1].UpdateElement(idToCopy); visualUpdateTiles.Add(runTiles[1]); runTiles[1] = runTiles[1].adjTiles[(int)Hexinal.E]; } } //Copy stuff outside board aka -1 axialRunTiles.CopyTo(runTiles, 0); for (int i = 0; i < 2; i++) { if (runTiles[i] == null) { continue; } while (true) { runTiles[i] = runTiles[i].adjTiles[(int)Hexinal.W]; if (runTiles[i] != null) { if (i == 1) { runTiles[i].UpdateElement(-1); } visualUpdateTiles.Add(runTiles[i]); } else { break; } } } BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); if (axialRunTiles[0] != null) { axialRunTiles[0] = axialRunTiles[0].adjTiles[(int)Hexinal.SE]; } if (axialRunTiles[1] != null) { axialRunTiles[1] = axialRunTiles[1].adjTiles[(int)Hexinal.NE]; } if (axialRunTiles[0] == null && axialRunTiles[1] == null) { break; } } }
public override void Run(HexBoardTile tile) { selectedTile = new HexBoardTile[6]; selectedId = new int[6] { -1, -1, -1, -1, -1, -1 }; allSelected = new List <List <HexBoardTile> >(); List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); for (int i = 0; i < 6; i++) { allSelected.Add(new List <HexBoardTile>()); } tile.adjTiles.CopyTo(selectedTile, 0); for (int i = 0; i < 6; i++) { if (selectedTile[i] == null) { continue; } if (selectedTile[i].ReadElementID() == id) { selectedId[i] = id; break; } else { selectedId[i] = selectedTile[i].ReadElementID(); } } //====== HexBoardTile pivot = tile; while (pivot.adjTiles[(int)Hexinal.W] != null) { pivot = pivot.adjTiles[(int)Hexinal.W]; } HexBoardTile[] axialRunTiles = new HexBoardTile[2] { pivot.adjTiles[(int)Hexinal.NE], pivot }; HexBoardTile[] runTiles = new HexBoardTile[4]; while (true) { axialRunTiles.CopyTo(runTiles, 0); axialRunTiles.CopyTo(runTiles, 2); bool rowDone = false; while (!rowDone) { rowDone = true; for (int i = 0; i < 4; i++) { if (runTiles[i] != null) { rowDone = false; TryAddToAllSelected(runTiles[i]); if (i < 2) { runTiles[i] = runTiles[i].adjTiles[(int)Hexinal.E]; } else { runTiles[i] = runTiles[i].adjTiles[(int)Hexinal.W]; } } } } if (axialRunTiles[0] != null) { axialRunTiles[0] = axialRunTiles[0].adjTiles[(int)Hexinal.NE]; } if (axialRunTiles[1] != null) { axialRunTiles[1] = axialRunTiles[1].adjTiles[(int)Hexinal.SE]; } if (axialRunTiles[0] == null && axialRunTiles[1] == null) { break; } } //====== for (int i = 0; i < 6; i++) { if (selectedTile[i] != null) { BoardVisualUpdateSequencer.AddToQueue(selectedTile[i]); } if (selectedId[i] != -1 && selectedTile[i].ReadElementID() != -1) { for (int a = 0; a < allSelected[i].Count; a++) { allSelected[i][a].UpdateElement(-1); } BoardVisualUpdateSequencer.AddToQueue(allSelected[i]); } if (selectedId[i] == id) { return; } } }
public override void Run(HexBoardTile tile) { List <HexBoardTile> visualUpdateTiles = new List <HexBoardTile>(); HexBoardTile pivot = tile; while (true) { if (pivot.adjTiles[(int)Hexinal.SW] != null) { pivot = pivot.adjTiles[(int)Hexinal.SW]; } else { break; } } HexBoardTile[] axialRunTiles = new HexBoardTile[2] { pivot.adjTiles[(int)Hexinal.NW], pivot.adjTiles[(int)Hexinal.E] }; HexBoardTile[] runTiles = new HexBoardTile[2]; int[] runTilesOriID = new int[2]; while (true) { visualUpdateTiles.Clear(); axialRunTiles.CopyTo(runTiles, 0); //Copy NE to E row and vise-versa bool rowDone = false; while (!rowDone) { rowDone = true; for (int i = 0; i < 2; i++) { if (runTiles[i] != null) { rowDone = false; runTilesOriID[i] = runTiles[i].ReadElementID(); } else { runTilesOriID[i] = -1; } } for (int i = 0; i < 2; i++) { if (runTiles[i] != null) { rowDone = false; runTiles[i].UpdateElement(runTilesOriID[1 - i]); visualUpdateTiles.Add(runTiles[i]); runTiles[i] = runTiles[i].adjTiles[(int)Hexinal.NE]; } } } //Set everything reflected from outside board to -1 axialRunTiles.CopyTo(runTiles, 0); for (int i = 0; i < 2; i++) { if (runTiles[i] == null) { continue; } while (true) { runTiles[i] = runTiles[i].adjTiles[(int)Hexinal.SW]; if (runTiles[i] != null) { runTiles[i].UpdateElement(-1); visualUpdateTiles.Add(runTiles[i]); } else { break; } } } BoardVisualUpdateSequencer.AddToQueue(visualUpdateTiles); if (axialRunTiles[0] != null) { axialRunTiles[0] = axialRunTiles[0].adjTiles[(int)Hexinal.NW]; } if (axialRunTiles[1] != null) { axialRunTiles[1] = axialRunTiles[1].adjTiles[(int)Hexinal.E]; } if (axialRunTiles[0] == null && axialRunTiles[1] == null) { break; } } }