public static void ActivateBellFunction(BoardManager board, BoardElement secondElement) { for (int row = 0; row < board.elementsPositions.GetLength(1); row++) { for (int collum = 0; collum < board.elementsPositions.GetLength(0); collum++) { int elementIndex = board.elementsPositions[collum, row].GetTransformIndex() [board.elementsPositions[collum, row].GetTransformIndex().Length - 1]; if (secondElement.GetElementClassType() == typeof(BoardElement)) { if (board.elementsPositions[collum, row].GetElementValue() == secondElement.GetElementValue() && board.elementsPositions[collum, row].GetElementClassType() == typeof(BoardElement)) { board.currentMessageID += 1; board.messagesToClient.Add(new Messages.AnimationMessage(board.currentMessageID, -1, Messages.AnimationMessage.AnimationMessageTypes.ChangeSprite, board.elementsPositions[collum, row].GetImageTransformIndex(), (int)ConstantValues.AvailableSprites.bell, Vector4.One)); board.elementsPositions[collum, row].OnElementDestruction(board); board.matchedElemPositions[collum, row] = true; } } else if (secondElement.GetElementClassType() == typeof(CrossBoardElement)) { if (board.elementsPositions[collum, row].GetElementValue() == secondElement.GetElementValue() && board.elementsPositions[collum, row].GetElementClassType() == typeof(BoardElement)) { board.elementsPositions[collum, row] = new CrossBoardElement(board.elementsPositions[collum, row].GetTransformIndex(), board.elementsPositions[collum, row].GetElementValue()); board.currentMessageID += 1; board.messagesToClient.Add(new Messages.AnimationMessage(board.currentMessageID, -1, Messages.AnimationMessage.AnimationMessageTypes.ChangeSprite, board.elementsPositions[collum, row].GetImageTransformIndex(), (int)ConstantValues.AvailableSprites.cross, board.elementsPositions[collum, row].GetElementValue())); board.elementsPositions[collum, row].OnElementDestruction(board); board.matchedElemPositions[collum, row] = true; } } else if (secondElement.GetElementClassType() == typeof(BombBoardElement)) { if (board.elementsPositions[collum, row].GetElementClassType() == typeof(BombBoardElement)) { board.elementsPositions[collum, row].OnElementDestruction(board); board.matchedElemPositions[collum, row] = true; } } else if (secondElement.GetElementClassType() == typeof(BellBoardElement)) { board.currentMessageID += 1; board.messagesToClient.Add(new Messages.AnimationMessage(board.currentMessageID, -1, Messages.AnimationMessage.AnimationMessageTypes.ChangeSprite, board.elementsPositions[collum, row].GetImageTransformIndex(), (int)ConstantValues.AvailableSprites.bell, Vector4.One)); if (board.elementsPositions[collum, row].GetElementClassType() != typeof(CashBoardElement)) { board.elementsPositions[collum, row] = new BoardElement(board.elementsPositions[collum, row].GetTransformIndex(), Vector4.One); } //board.elementsPositions[collum, row].OnElementDestruction(board); board.matchedElemPositions[collum, row] = true; } } } }
public static BoardElement CreateNewElement(BoardElement previousElement, BoardElement.BoardElementTypes type) { int randomNum = random.Next(0, ConstantValues.GetAvailableColors().Length); Vector4 newColor = ConstantValues.GetAvailableColors() [randomNum]; switch (type) { case BoardElement.BoardElementTypes.Cross: previousElement = new CrossBoardElement(previousElement.GetTransformIndex(), previousElement.GetElementValue()); break; case BoardElement.BoardElementTypes.Bomb: previousElement = new BombBoardElement(previousElement.GetTransformIndex()); break; case BoardElement.BoardElementTypes.Bell: previousElement = new BellBoardElement(previousElement.GetTransformIndex()); break; case BoardElement.BoardElementTypes.Default: if (previousElement.GetElementClassType() != typeof(BoardElement)) { previousElement = new BoardElement(previousElement.GetTransformIndex(), newColor); } else { previousElement.OnElementAppearance(newColor); } break; } return(previousElement); }