/// <summary> /// /// </summary> /// <param name="evt"></param> /// <param name="chosenDifficulty"></param> /// <param name="client"></param> private void ChooseDifficultyHandler(string evt, byte[] chosenDifficulty, VMEODClient client) { if (GameState.Equals(FreeSOMazeStates.Lobby) && NextState.Equals(FreeSOMazeStates.Invalid)) { FreeSOMazePlayer caller = null; FreeSOMazePlayer partner = null; if (LogicPlayer != null && client.Equals(LogicPlayer.Client)) { caller = LogicPlayer; partner = CharismaPlayer; } else { caller = CharismaPlayer; partner = LogicPlayer; } int difficultyNum = BitConverter.ToInt32(chosenDifficulty, 0); FreeSOMazeDifficulties difficulty = FreeSOMazeDifficulties.Unselected; if (Enum.IsDefined(typeof(FreeSOMazeDifficulties), difficultyNum)) { difficulty = (FreeSOMazeDifficulties)Enum.ToObject(typeof(FreeSOMazeDifficulties), difficultyNum); } ValidateDifficulty(caller, difficulty, partner); } }
private void CharismaButtonClickedHandler(string evt, byte[] direction, VMEODClient charPlayer) { // validate move, make move, check for solution if (charPlayer.Equals(CharismaPlayer) && direction.Length == 1 && GameState.Equals(VMEODTwoPersonJobObjectMazePluginStates.Solving)) { var directionByte = direction[0]; AbstractMazeCell <TSOMazeData> nextCell = null; switch (directionByte) { case (byte)AbstractMazeCellCardinalDirections.North: { nextCell = CharismaPlayerOrigin.North_Neighbor; break; } case (byte)AbstractMazeCellCardinalDirections.West: { nextCell = CharismaPlayerOrigin.West_Neighbor; break; } case (byte)AbstractMazeCellCardinalDirections.East: { nextCell = CharismaPlayerOrigin.East_Neighbor; break; } case (byte)AbstractMazeCellCardinalDirections.South: { nextCell = CharismaPlayerOrigin.South_Neighbor; break; } } // if it's a valid move if (nextCell != null) { CharismaPlayerOrigin = nextCell; // if it's the solution/exit if (CharismaPlayerOrigin.CellData.IsExit) { MazeSolved = true; EnqueueGotoState(VMEODTwoPersonJobObjectMazePluginStates.Reacting); } } if (MazeSolved) { SendCharismaPlayerCellData("TSOMaze_Final_Cell"); } else { SendCharismaPlayerCellData("TSOMaze_Update_Cell"); } } }
public override void OnDisconnection(VMEODClient client) { if (client.Equals(LogicPlayer)) { LogicPlayer = null; } else if (client.Equals(CharismaPlayer)) { CharismaPlayer = null; } if (LogicPlayer == null && CharismaPlayer == null) { Server.Shutdown(); } else { EnqueueGotoState(VMEODTwoPersonJobObjectMazePluginStates.Waiting_For_Player); } base.OnDisconnection(client); }
/// <summary> /// When the user has loaded all of the textures for the first time. If their partner exists, send their object id and their difficulty choice, if applicable. /// </summary> /// <param name="evt">"FreeSOMaze_loaded"</param> /// <param name="nothing"></param> /// <param name="client"></param> private void FirstLoadHandler(string evt, byte[] nothing, VMEODClient client) { FreeSOMazePlayer caller = null; FreeSOMazePlayer partner = null; if (LogicPlayer != null && client.Equals(LogicPlayer.Client)) { caller = LogicPlayer; partner = CharismaPlayer; } else { caller = CharismaPlayer; partner = LogicPlayer; } caller.Loaded(); SendLobbyInfoEvent(caller, partner); SendLobbyInfoEvent(partner, caller); }
private void PieceSelectionHandler(string evt, Byte[] chosenPieceNum, VMEODClient playerClient) { // is this an active player client? short playerNum = -1; if (BluePlayerClient.Equals(playerClient)) { playerNum = (short)VMEODWarGamePlayers.Blue; } else if (RedPlayerClient.Equals(playerClient)) { playerNum = (short)VMEODWarGamePlayers.Red; } else { return; } // verify that the piece is a legal selection bool isLegal = Enum.IsDefined(typeof(VMEODWarGamePieceTypes), chosenPieceNum[0]); // finally, make sure that the valid player's valid choice is not already defeated if (isLegal) { foreach (var piece in Players[playerNum].Pieces) { if ((byte)piece.PieceType == chosenPieceNum[0]) { SetPlayerPiece(playerNum, piece); return; } } } // either the chosen piece is illegal or the chosen piece is already defeated, force a piece choice ForcePieceChoice(playerNum); }