public override void OnConnection(VMEODClient client) { if (client.Avatar != null) { var args = client.Invoker.Thread.TempRegisters; if (args[0] == 1) { LogicPlayer = client; client.Send("TSOMaze_Show_Logic", new byte[0]); CooldownTimer = 6; } else { CharismaPlayer = client; client.Send("TSOMaze_Show_Charisma", new byte[0]); CooldownTimer = 8; } if (LogicPlayer != null && CharismaPlayer != null) { EnqueueGotoState(VMEODTwoPersonJobObjectMazePluginStates.Ready); } } else { Controller = client; } base.OnConnection(client); }
private void WheelsStoppedHandler(string evt, string uselessString, VMEODClient client) { var winnings = CurrentWinnings; CurrentWinnings = 0; if (winnings > 0) { // send win event with random number for message displayed client.Send("slots_display_win", "" + SlotsRandom.Next(25, 30) + "%" + winnings); // pay the player var VM = client.vm; VM.GlobalLink.PerformTransaction(VM, false, Server.Object.PersistID, client.Avatar.PersistID, winnings, // debit the balance of the machine (bool success, int transferAmount, uint uid1, uint budget1, uint uid2, uint budget2) => { if (success) { MachineBalance = (int)(budget1); } }); } else { // send loss event with random number for message displayed client.Send("slots_display_loss", "" + SlotsRandom.Next(30, 35)); } }
public override void OnConnection(VMEODClient client) { base.OnConnection(client); if (client.Avatar != null) { // get the params, temp 0 is player type var local = client.Invoker.Thread.TempRegisters; if ((local != null) && (local[0] == (short)VMEODWarGamePlayers.Blue)) { BluePlayerClient = client; BluePlayerClient.Send("WarGame_Init", BluePlayerClient.Avatar.ObjectID + "%blue"); NumberOfPlayers++; } else { RedPlayerClient = client; RedPlayerClient.Send("WarGame_Init", RedPlayerClient.Avatar.ObjectID + "%red"); NumberOfPlayers++; } } else { ControllerClient = client; } if ((NumberOfPlayers == 2) && (ControllerClient != null)) { BluePlayerClient.Send("WarGame_Draw_Opponent", RedPlayerClient.Avatar.ObjectID + ""); RedPlayerClient.Send("WarGame_Draw_Opponent", BluePlayerClient.Avatar.ObjectID + ""); NextGameHandler((short)VMEODWarGameEvents.NextGame, ControllerClient); } }
private void BroadcastSharedEvent(string evt, byte[] data) { if (LogicPlayer != null) { LogicPlayer.Send(evt, data); } if (CharismaPlayer != null) { CharismaPlayer.Send(evt, data); } }
private void GameOverHandler(short eventID, VMEODClient player) { // check if object has enough money or too much money, then start new game or send offline message to the player if (IsObjectBalanceInBounds()) { player.Send("slots_new_game", ""); } else { player.Send("slots_close_machine", ""); } }
public override void OnConnection(VMEODClient client) { base.OnConnection(client); PlayerClient = client; // get the registers var args = client.Invoker.Thread.TempRegisters; // get the initial minutes and seconds CurrentDisplayedMinutes = args[2]; CurrentDisplayedSeconds = args[3]; // get the current running states IsRunning = (args[0] == 1) ? true : false; if (Enum.IsDefined(typeof(VMEODTimerPluginStates), args[1])) { State = (VMEODTimerPluginStates)Enum.ToObject(typeof(VMEODTimerPluginStates), args[1]); } else { State = VMEODTimerPluginStates.Countdown; } // show the client: @params - Byte[] { 0 if IsRunning or 1 if !IsRunning, 0 if State = Countdown 1 if State = Stopwatch, Minutes/256, Seconds } PlayerClient.Send("Timer_Show", new Byte[] { (byte)args[0], (byte)args[1], (byte)(CurrentDisplayedMinutes), (byte)CurrentDisplayedSeconds }); }
public override void OnConnection(VMEODClient client) { base.OnConnection(client); var args = client.Invoker.Thread.TempRegisters; var trunkTypeShort = args[0]; // check if the passed params match a trunk bool isValidTrunkParam = Enum.IsDefined(typeof(VMEODTrunkPluginCollections), trunkTypeShort); if (!isValidTrunkParam) { Server.Disconnect(client); } if (trunkTypeShort == (short)VMEODTrunkPluginCollections.costumes) { IsCostumeTrunk = true; } var typeString = Enum.GetName(typeof(VMEODTrunkPluginCollections), trunkTypeShort); // avatar gender affects collection & path var avatar = client.Avatar; bool isMale = (avatar.GetPersonData(VMPersonDataVariable.Gender) == 0); string collectionPath = typeString + (isMale ? "_" : "_fe") + "male.col"; // get the matching trunk collection var content = Content.GameContent.Get; TrunkOutfits = content.AvatarCollections.Get(collectionPath); client.Send("trunk_fill_UI", collectionPath); }
private void StoreDefaultSuit(VMEODClient client, VMPersonSuits category, uint outfitId) { GetOutfit(client.vm, outfitId, outfit => { if (outfit == null) { //You don't own this outfit! return; } if (outfit.outfit_type != (byte)category) { //Wrong category, no swimming in PJs! return; } //Set the default in the vm, this will be persisted on exit avatar persist client.vm.SendCommand(new VMNetSetOutfitCmd { UID = client.Avatar.PersistID, Scope = category, Outfit = outfit.asset_id }); //Have the UI update the default client.Send("dresser_refresh_default", ""); }); }
public override void OnConnection(VMEODClient client) { var args = client.Invoker.Thread.TempRegisters; // client belongs to a player if (client.Avatar != null) { if ((args != null) && (args[0] > -1) && (args[0] < 4)) { if (Lobby.Join(client, args[0])) { client.Send("Band_UI_Init", new byte[] { (byte)args[0] }); var slot = Lobby.GetSlotData(client); if (slot != null) { slot.AvatarName = client.Avatar.Name; slot.Instrument = (VMEODBandInstrumentTypes)Enum.ToObject(typeof(VMEODBandInstrumentTypes), args[0]); slot.SkillAmount = GetAvatarsCurrentSkill(client); if (Lobby.IsFull()) { InitGame(); } } } } } // client belongs to the smart tile, is contoller else { Controller = client; } base.OnConnection(client); }
public override void Tick() { base.Tick(); if (IsRunning) { Tock = 0; if (State.Equals(VMEODTimerPluginStates.Countdown)) { // get the registers var args = PlayerClient.Invoker.Thread.TempRegisters; if ((args[2] == 0) && (args[3] == 0)) { IsRunning = false; UpdatedAfterStop = true; // get the updated minutes and seconds CurrentDisplayedMinutes = args[2]; CurrentDisplayedSeconds = args[3]; PlayerClient.Send("Timer_Off", new byte[] { (byte)State }); PlayerClient.Send("Timer_Update", CurrentDisplayedMinutes + ":" + CurrentDisplayedSeconds); } } } else if (!UpdatedAfterStop) { if (Tock == 0) { PlayerClient.SendOBJEvent(new VMEODEvent((short)VMEODTimerEvents.Update)); } Tock++; if (Tock == 5) { UpdatedAfterStop = true; // get the registers var args = PlayerClient.Invoker.Thread.TempRegisters; // get the final minutes and seconds CurrentDisplayedMinutes = args[2]; CurrentDisplayedSeconds = args[3]; PlayerClient.Send("Timer_Update", CurrentDisplayedMinutes + ":" + CurrentDisplayedSeconds); } } }
private void WheelsStoppedHandler(string evt, string uselessString, VMEODClient client) { var winnings = CurrentWinnings; CurrentWinnings = 0; if (winnings > 0) { // send win event with random number for message displayed client.Send("slots_display_win", "" + SlotsRandom.Next(25, 30) + "%" + winnings); // pay the player var VM = client.vm; VM.GlobalLink.PerformTransaction(VM, false, Server.Object.PersistID, client.Avatar.PersistID, winnings, // debit the balance of the machine (bool success, int transferAmount, uint uid1, uint budget1, uint uid2, uint budget2) => { //TODO: Make this part of global link VM.SendCommand(new VMNetAsyncResponseCmd(0, new VMTransferFundsState { Responded = true, Success = success, TransferAmount = transferAmount, UID1 = uid1, Budget1 = budget1, UID2 = uid2, Budget2 = budget2 })); if (success) { MachineBalance = (int)(budget1); CurrentWinnings = 0; // winning payout cannot be duplicated } else { //Console.WriteLine("VMEODSlotsPlugin.WheelsStoppedHandler: There was an error while paying the player the winnings."); CurrentWinnings = 0; // winning payout cannot be duplicated } }); } else { // send loss event with random number for message displayed client.Send("slots_display_loss", "" + SlotsRandom.Next(30, 35)); } }
protected override void OnConnected(VMEODClient client) { //all this plugin needs to do is get the info from the database, and send it //on it's merry way Server.vm.GlobalLink.GetDynPayouts((data) => { client.Send("newspaper_state", data); }); }
public override void OnConnection(VMEODClient client) { if (client.Avatar != null) { EODType = VMEODGameshowBuzzerPluginType.Player; MyBuzzerEnabled = false; // get the score from the object's via tempregisters MyScore = client.Invoker.Thread.TempRegisters[0]; MyClient = client; MyClient.Send("BuzzerEOD_Init", new byte[] { (byte)VMEODGameshowBuzzerPluginType.Player }); // update the UI to match their buzzer object's score MyClient.Send("Buzzer_Player_Score", BitConverter.GetBytes(MyScore)); SyncEvent += PlayerSyncHandler; } base.OnConnection(client); }
private void UpdateScore(string evt, string body, VMEODClient client) { var parts = body.Split(','); if (parts.Length != 2) { return; } VMEODScoreboardTeam team; short difference; if (!Enum.TryParse <VMEODScoreboardTeam>(parts[0], out team) || !short.TryParse(parts[1], out difference)) { return; } Persist.Patch(current => { var result = current.Clone(); switch (team) { case VMEODScoreboardTeam.LHS: result.LHSScore += difference; if (result.LHSScore < 0) { result.LHSScore = 0; } if (result.LHSScore > 999) { result.LHSScore = 999; } client.SendOBJEvent(new Model.VMEODEvent((short)VMEODScoreboardEvent.SetLHSScore, result.LHSScore)); break; case VMEODScoreboardTeam.RHS: result.RHSScore += difference; if (result.RHSScore < 0) { result.RHSScore = 0; } if (result.RHSScore > 999) { result.RHSScore = 999; } client.SendOBJEvent(new Model.VMEODEvent((short)VMEODScoreboardEvent.SetRHSScore, result.RHSScore)); break; } client.Send("scoreboard_state", result); return(result); }); }
public override void Tick() { base.Tick(); if ((Data != null) && (!IsRackNameInitialized) && (Client != null)) { // send event to initialize rack name along with the name Client.Send("rack_initialize_name", Data.RackName); IsRackNameInitialized = true; } }
/// <summary> /// Execute an Incorrect Answer Sequence on the specified player index. /// </summary> /// <param name="evt">Buzzer_Host_PlayerIncorrect</param> /// <param name="playerBytes">player index 0-3</param> /// <param name="host"></param> private void PlayerIncorrectHandler(string evt, byte[] playerBytes, VMEODClient host) { lock (PlayerConfigLock) { var playerIndex = BitConverter.ToInt32(playerBytes, 0); lock (ConnectedContestants) { if (!BuzzerEnabled) { string playerName = null; var player = ConnectedContestants[playerIndex]; if (player != null && player.EODType.Equals(VMEODGameshowBuzzerPluginType.Player)) { playerName = player.AvatarName; player.ExecuteIncorrectAnswer((short)(_Options.AutoDeductWrongPoints ? _Options.CorrectAnswerScore : 0)); if (_Options.AutoDisableOnWrong) { SetPlayerBuzzer(playerIndex, false); } // other players should react var players = GetConnectedPlayers(playerIndex, true); foreach (var otherPlayers in players) { otherPlayers.ExecuteOthersAnswer(0, playerName); } // update host UI host.Send("BuzzerEOD_Answer", new byte[0]); // execute host event for host avatar to acknowledge player avatar's answer Controller.SendOBJEvent(new Model.VMEODEvent((short)VMEODGameshowHostPluginEvents.Judge_Answer_Incorrect, player.MyClient?.Avatar?.ObjectID ?? 0)); } ChangeBuzzerState(VMEODGameshowBuzzerStates.Disabled); } else { // buzzer enabled error host.Send("Buzzer_Host_Error", new byte[(byte)VMEODGameshowBuzzerPluginErrors.H_NoChangesAllowed]); } SendContestantRoster(); } } }
public void PlayerHandUpdate(VMEODClient client, VMEODPizzaPlayer player) { string msg = ""; foreach (var item in player.Hand) { msg += ((item == null) ? "--" : item.ToString()) + "\n"; } client.Send("pizza_hand", msg); }
protected override void OnConnected(VMEODClient client) { //Send current state to the user Persist.GetData().ContinueWith(x => { if (!x.IsFaulted && x.Result != null) { client.Send("scoreboard_state", x.Result); } }); }
public override void OnConnection(VMEODClient client) { if (client.Avatar != null) { client.Send("dance_show", ""); } else { //we're the dance floor controller! ControllerClient = client; } }
internal FreeSOMazeCardinals GetTargetCardinal(AbstractMazeCell <FreeSOMazeData> source, AbstractMazeCell <FreeSOMazeData> target) { _Client.Send("FreeSOMaze_alert", "Server: source is: " + source.Row + " " + source.Column + " and target: " + target.Row + " " + target.Column); if (source?.North_Neighbor?.Equals(target) ?? false) { return(FreeSOMazeCardinals.North); } if (source?.East_Neighbor?.Equals(target) ?? false) { return(FreeSOMazeCardinals.East); } if (source?.West_Neighbor?.Equals(target) ?? false) { return(FreeSOMazeCardinals.West); } if (source?.South_Neighbor?.Equals(target) ?? false) { return(FreeSOMazeCardinals.South); } return(FreeSOMazeCardinals.Invalid); }
public override void OnConnection(VMEODClient client) { if (client.Avatar == null) { //we're the controller! SendClientBulletinData(client); } else { var param = client.Invoker.Thread.TempRegisters; Mode = (VMEODSignsMode)param[0]; client.Send("bulletin_show", (param[0]).ToString()); } }
public override void OnConnection(VMEODClient client) { if (client.Avatar != null) { PlayerClient = client; client.Send("dance_show", GroupID.ToString()); } else { //we're the dance floor controller! ControllerClient = client; GroupID = client.Invoker.GetValue(SimAntics.Model.VMStackObjectVariable.GroupID); } }
/// <summary> /// /// </summary> /// <param name="client"></param> public override void OnConnection(VMEODClient client) { if (client.Avatar != null) { // get the temps, [0] == 1 is logic, 2 is charisma var args = client.Invoker.Thread.TempRegisters; if (args[0] == 1) { LogicPlayer = new FreeSOMazePlayer(client, client.Avatar.GetPersonData(SimAntics.Model.VMPersonDataVariable.LogicSkill) / 100m, true); client.Send("FreeSOMaze_show_l", BitConverter.GetBytes(client.Avatar.ObjectID)); } else { CharismaPlayer = new FreeSOMazePlayer(client, client.Avatar.GetPersonData(SimAntics.Model.VMPersonDataVariable.CharismaSkill) / 100m, false); client.Send("FreeSOMaze_show_c", BitConverter.GetBytes(client.Avatar.ObjectID)); } EnqueueGotoState(FreeSOMazeStates.Lobby); base.OnConnection(client); } else { Controller = client; } }
/// <summary> /// Execute a search for a new player to replace the specificed index. /// </summary> /// <param name="evt">Buzzer_Host_FindNewPlayer</param> /// <param name="playerIndex">0-3</param> /// <param name="host"></param> private void FindNewPlayerHandler(string evt, byte[] playerIndex, VMEODClient host) { if (!BuzzerEnabled) { var index = BitConverter.ToInt32(playerIndex, 0); if (index > -1 && index < 4) { lock (PlayerConfigLock) FillContestantSpot(index, true); } } else { // buzzer enabled error host.Send("Buzzer_Host_Error", new byte[(byte)VMEODGameshowBuzzerPluginErrors.H_NoChangesAllowed]); } }
/// <summary> /// Enables or Disables one specfic player from buzzing in when the MasterBuzzer is enabled. This cannot be changed when the MasterBuzzer is enabled. /// </summary> /// <param name="evt">Buzzer_Host_ToggleEnablePlayer</param> /// <param name="data">1 if enabled, 0 if disabled</param> /// <param name="host"></param> private void ToggleEnablePlayerHandler(string evt, byte[] data, VMEODClient host) { lock (ConnectedContestants) { if (!BuzzerEnabled) { TogglePlayerBuzzer(BitConverter.ToInt32(data, 0)); } else { // buzzer enabled error host.Send("Buzzer_Host_Error", new byte[(byte)VMEODGameshowBuzzerPluginErrors.H_NoChangesAllowed]); } } lock (PlayerConfigLock) SendContestantRoster(); }
public override void OnConnection(VMEODClient client) { Client = client; var param = client.Invoker.Thread.TempRegisters; if (client.Avatar != null) { var rackType = param[0]; if (!Lobby.Join(client, 0)) { return; } RackType = (RackType)rackType; client.Send("rack_show", ((short)RackType).ToString()); BroadcastOutfits(client.vm, false); } }
public override void OnConnection(VMEODClient client) { var param = client.Invoker.Thread.TempRegisters; if (client.Avatar != null) { //take tuning settings from object PhoneWaitSeconds = param[1]; ContributionTimeoutSeconds = param[2]; RestartDelaySeconds = param[3]; CardsPerSmallIngredient = param[4]; CardsPerMediumIngredient = param[5]; CardsPerLargeIngredient = param[6]; CardsPerBonusIngredientPerSize = param[7]; //what part are we trying to join? var station = param[0]; if (Players[station] != null) { //what? someone's already here... Server.Disconnect(client); } else { client.Send("pizza_show", ""); Players[station] = client; //if not initialized, set up this player with an empty hand //otherwise inherit the last hand. if (PizzaPlayers[station] == null) { PizzaPlayers[station] = new VMEODPizzaPlayer(); } PlayerRosterUpdate(); } } else { //we're the pizza controller! ControllerClient = client; } }
public override void OnConnection(VMEODClient client) { if (client.Avatar != null) { _Random = new Random(DateTime.Now.Millisecond + client.Avatar.ObjectID); EODType = VMEODGameshowBuzzerPluginType.Host; MyClient = client; SessionStamp = ClientListRefreshedStamp = _Random.NextDouble(); _BuzzerState = VMEODGameshowBuzzerStates.Disabled; _Options = new VMEODGameshowBuzzerHostOptions(); // subscribe to player connection events ClientConnect += NewClientConnectedHandler; ClientDisconnect += ClientDisconnectedHandler; PlayerBuzzed += PlayerBuzzedHandler; // find players already connected FillContestantSpots(); client.Send("BuzzerEOD_Init", new byte[] { (byte)VMEODGameshowBuzzerPluginType.Host }); } base.OnConnection(client); }
/// <summary> /// Move the player at the specified index to the right. /// </summary> /// <param name="evt">Buzzer_Host_MovePlayerRight</param> /// <param name="sourcePlayerIndex">0-2</param> /// <param name="host"></param> private void MovePlayerRightHandler(string evt, byte[] sourcePlayerIndex, VMEODClient host) { if (!BuzzerEnabled) { lock (PlayerConfigLock) { var sourceIndex = BitConverter.ToInt32(sourcePlayerIndex, 0); lock (ConnectedContestants) { var targetIndex = sourceIndex + 1; if (targetIndex > 3) { targetIndex = 0; } if (IsValidConnectedContestant(sourceIndex)) { var sourcePlayer = ConnectedContestants[sourceIndex]; if (IsValidConnectedContestant(targetIndex)) { ConnectedContestants[sourceIndex] = ConnectedContestants[targetIndex]; } else { ConnectedContestants[sourceIndex] = null; } ConnectedContestants[targetIndex] = sourcePlayer; } SendContestantRoster(); } } } else { // buzzer enabled error host.Send("Buzzer_Host_Error", new byte[(byte)VMEODGameshowBuzzerPluginErrors.H_NoChangesAllowed]); } }
public override void OnConnection(VMEODClient client) { Client = client; var param = client.Invoker.Thread.TempRegisters; if (client.Avatar != null) { var rackType = param[0]; if (!Lobby.Join(client, 0)) { return; } RackType = (RackType)rackType; client.Send("rack_show", ((short)RackType).ToString()); if (((VMTSOObjectState)Server.Object.TSOState).OwnerID == client.Avatar.PersistID) { BroadcastOutfits(client.vm, true); } else { BroadcastOutfits(client.vm, false); } } }
public override void OnConnection(VMEODClient client) { var param = client.Invoker.Thread.TempRegisters; if (client.Avatar != null) { //take tuning settings from object PhoneWaitSeconds = param[1]; ContributionTimeoutSeconds = param[2]; RestartDelaySeconds = param[3]; CardsPerSmallIngredient = param[4]; CardsPerMediumIngredient = param[5]; CardsPerLargeIngredient = param[6]; CardsPerBonusIngredientPerSize = param[7]; //what part are we trying to join? var station = param[0]; if (Players[station] != null) { //what? someone's already here... Server.Disconnect(client); } else { client.Send("pizza_show", ""); Players[station] = client; PizzaPlayers[station] = new VMEODPizzaPlayer(); PlayerRosterUpdate(); } } else { //we're the pizza controller! ControllerClient = client; } }