public static void Animate(Tuple<string,string,string> AnimationData, LabyrinthBlock[,] CurrentBoard, LabyrinthBlock[] CurrentReserves, Player[] CurrentPlayers, float scale, float offset) { if (IsAnimating) return; CurrentOperation = AnimationData; GameBoard = CurrentBoard; GameReserves = CurrentReserves; GamePlayers = CurrentPlayers; Scale = scale; Offset = offset; DataSetter set; if(CurrentOperation == null) { Game1.CurrentTurn++; Game1.CurrentPlayerIndex++; AnimationDone(); return; } switch (CurrentOperation.Item1) { case "PawnMoved": set = SetPlayerMovementData; break; case "HallShifted": set = SetShiftingData; break; case "BlockRotated": set = SetRotationData; break; default: AnimationDone(); return; } set.Invoke(); IsAnimating = true; }
private void RandomizeBoard(List<int> Blocks) { List<int> BlockNumbers = new List<int>() { 0, 1, 2 }; // Remove any indexes if 0 pieces have been selected for (int i = Blocks.Count - 1; i >= 0; i--) if (Blocks[i] <= 0) BlockNumbers.RemoveAt(i); for(int i = 0; i < Board.GetLength(0); i++) for(int x = 0; x < Board.GetLength(1); x++) { LabyrinthBlock LockedPiece; if((LockedPiece = FindLocked(i, x, Board.GetLength(0))) != null) { Board[i, x] = LockedPiece; if (LockedPiece.Type == BlockType.Straight) Board[i, x] = null; continue; } int Index = GlobalMethods.NextRandom(BlockNumbers.Count); int Type = BlockNumbers[Index]; Board[i, x] = new LabyrinthBlock((BlockType)Type, GlobalMethods.NextRandom(0,4)); Blocks[Type]--; if (Blocks[Type] <= 0) BlockNumbers.RemoveAt(Index); } int index = 0; for (int i = 0; i < 3; i++) { while(Blocks[i] > 0) { Reserves[index] = new LabyrinthBlock((BlockType)i, 0); Blocks[i]--; index++; } } }