Exemple #1
0
 private void GameTieMessageHandler(object source, ElapsedEventArgs args)
 {
     GameMessageTimer.Stop();
     // reset player round wins in prim
     ControllerClient.SendOBJEvent(new VMEODEvent((short)VMEODWarGameEvents.ResetWins));
     NextGameHandler((short)VMEODWarGameEvents.NextGame, ControllerClient);
 }
Exemple #2
0
        void UpdateColor(string evt, string body, VMEODClient client)
        {
            var parts = body.Split(',');

            if (parts.Length != 2)
            {
                return;
            }

            if (!Enum.TryParse <VMEODScoreboardTeam>(parts[0], out var team) ||
                !Enum.TryParse <VMEODScoreboardColor>(parts[1], out var color))
            {
                return;
            }


            Persist.Patch(current =>
            {
                var result = current.Clone();
                switch (team)
                {
                case VMEODScoreboardTeam.LHS:
                    result.LHSColor = color;
                    client.SendOBJEvent(new Model.VMEODEvent((short)VMEODScoreboardEvent.SetLHSColor, (short)color));
                    break;

                case VMEODScoreboardTeam.RHS:
                    result.RHSColor = color;
                    client.SendOBJEvent(new Model.VMEODEvent((short)VMEODScoreboardEvent.SetRHSColor, (short)color));
                    break;
                }
                return(result);
            });
        }
Exemple #3
0
        void StateMachine_OnTransition(VMEODPaperChaseState from, VMEODPaperChaseState to)
        {
            Lobby.Broadcast("paperchase_state", ((byte)to).ToString());

            if (Controller == null)
            {
                return;
            }

            switch (to)
            {
            case VMEODPaperChaseState.Lobby:
                ResetGame();
                BroadcastPlayerLetters();
                break;

            case VMEODPaperChaseState.StartRound:
                ResetGame();
                CurrentCombination = Combinations[Random.Next(0, Combinations.Length)];
                StateMachine.TransitionTo(VMEODPaperChaseState.WaitingForThreeLetters);
                break;

            case VMEODPaperChaseState.WaitingForThreeLetters:
                PreviousMatches = Matches;
                BroadcastPlayerLetters();
                Controller.SendOBJEvent(new VMEODEvent((short)VMEODPaperChaseObjEvent.Idle));
                break;

            case VMEODPaperChaseState.ThreeLettersProvided:
                Matches = 0;
                for (var i = 0; i < 3; i++)
                {
                    var playerData = Lobby.GetSlotData(i);
                    if (playerData.Letter == CurrentCombination[i])
                    {
                        Matches++;
                    }

                    Controller.SendOBJEvent(new VMEODEvent((short)VMEODPaperChaseObjEvent.SetLetter,
                                                           (short)(playerData.Letter | (short)((i + 1) << 8)))); //lo: letter, hi: FREESO player id

                    playerData.PreviousLetter = playerData.Letter;
                    playerData.Letter         = null;
                }

                Controller.SendOBJEvent(new VMEODEvent((short)VMEODPaperChaseObjEvent.SetResult, Matches));
                StateMachine.TransitionTo(VMEODPaperChaseState.CheckingResult);
                break;

            case VMEODPaperChaseState.CheckingResult:
                Ticks = 0;
                break;

            case VMEODPaperChaseState.CheckResult:
                Ticks = 0;
                Controller.SendOBJEvent(new VMEODEvent((short)VMEODPaperChaseObjEvent.ShowResult));
                Lobby.Broadcast("paperchase_result", Matches.ToString());
                break;
            }
        }
Exemple #4
0
        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);
            });
        }
Exemple #5
0
        public void CalculateFinalRating()
        {
            Rating = (int)Math.Min(Math.Round(SectionRatings.Average() + ControllerPlugin.RoundPercentage() * 20), 100);
            TimeSinceRatingChange = 0;
            //Console.WriteLine(Rating);
            //send it to the object

            if (ControllerClient != null)
            {
                ControllerClient.SendOBJEvent(new VMEODEvent(1, (short)Rating));
            }
        }
        private void Stock(string evt, string data, VMEODClient client)
        {
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == client.Avatar.PersistID);

            if ((Lobby.GetPlayerSlot(client) != 0) || (!isOwner))
            {
                return;
            }

            ulong outfitAssetId;
            var   valid = ulong.TryParse(data, out outfitAssetId);

            if (!valid)
            {
                return;
            }

            var outfit = Content.Content.Get().RackOutfits.GetByRackType(RackType).Outfits.FirstOrDefault(x => x.AssetID == outfitAssetId);

            if (outfit == null)
            {
                return;
            }

            var VM = client.vm;

            //TODO: Do stores get bulk discounts on clothes?
            VM.GlobalLink.PerformTransaction(VM, false, client.Avatar.PersistID, uint.MaxValue, (int)outfit.Price,

                                             (bool success, int transferAmount, uint uid1, uint budget1, uint uid2, uint budget2) =>
            {
                if (success)
                {
                    //Create the outfit
                    VM.GlobalLink.StockOutfit(VM, new VMGLOutfit {
                        owner_type     = VMGLOutfitOwner.OBJECT,
                        owner_id       = Server.Object.PersistID,
                        asset_id       = outfit.AssetID,
                        purchase_price = outfit.Price,
                        sale_price     = outfit.Price,
                        outfit_type    = (byte)GetSuitType(this.RackType),
                        outfit_source  = VMGLOutfitSource.rack
                    }, (bool created, uint outfitId) => {
                        client.SendOBJEvent(new VMEODEvent((short)VMEODRackEvent.StockOutfit, 0));
                        BroadcastOutfits(VM, true);
                    });
                }
                else
                {
                    client.SendOBJEvent(new VMEODEvent((short)VMEODRackEvent.StockOutfit, 0));
                }
            });
        }
 /*
  * This Simantics event only happens after a win or a loss and after each sequence round.
  */
 private void AnimationsFinishedHandler(short evt, VMEODClient client)
 {
     if (State.Equals(VMEODBandStates.MinPayment))
     {
         EnqueueGotoState(VMEODBandStates.Finale);
         Lobby.Broadcast("Band_Win", Data.VMEODGameCompDrawACardData.SerializeStrings(CumulativePayout + "", "" + CurrentSongLength));
         // send the song length for the win animation
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.NewSongLength, CurrentSongLength));
         // get the prorated skill payout amount
         short skillPayout = (short)Math.Round(0m + (CombinedSkillAmount * SKILL_PAYOUT_MULTIPLIER * CurrentSongLength) / MAX_SONG_LENGTH);
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.NewSkillPayout, skillPayout));
         // send the win amount
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.WinRound, (short)CumulativePayout));
     }
     else if (State.Equals(VMEODBandStates.Electric))
     {
         if (Lobby.IsFull())
         {
             EnqueueGotoState(VMEODBandStates.Intermission);
         }
     }
     else
     {
         if (Lobby.IsFull())
         {
             EnqueueGotoState(VMEODBandStates.PreShow);
         }
     }
 }
Exemple #8
0
        private void NewOddsHandler(string evt, Byte[] args, VMEODClient client)
        {
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == UserClient.Avatar.PersistID);

            if (isOwner)
            {
                if ((args != null) && (args.Length > 0))
                {
                    if (args[0] < 80)
                    {
                        MachinePaybackPercent = 80;
                    }
                    else if (args[0] > 110)
                    {
                        MachinePaybackPercent = 110;
                    }
                    else
                    {
                        MachinePaybackPercent = args[0];
                    }
                }
                client.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.SetNewPayout, new short[1] {
                    MachinePaybackPercent
                }));
            }
        }
        void WearCostumeHandler(string evt, string costumeID, VMEODClient client)
        {
            // make sure the requested item is valid and is found in the collection
            ulong assetID = 0;
            var   valid   = ulong.TryParse(costumeID, out var parsedID);

            if (valid)
            {
                assetID = FindInCollection(parsedID);
            }

            // change added 23.10.18 for Halloween event: skeleton body added to costume trunk bypassing collections/purchasebles
            if (assetID == 0 && IsCostumeTrunk)
            {
                assetID = 6000069312525;
            }

            // send event to assign costume to avatar's dynamic costume and disconnect client
            if (assetID != 0)
            {
                client.vm.SendCommand(new VMNetSetOutfitCmd
                {
                    UID    = client.Avatar.PersistID,
                    Scope  = VMPersonSuits.DynamicCostume,
                    Outfit = assetID,
                });
                // now get out
                client.SendOBJEvent(new VMEODEvent((short)VMEODTrunkPluginEvents.Change));
                Server.Disconnect(client);
            }
        }
Exemple #10
0
        private void TryOutfitOn(string evt, string data, VMEODClient client)
        {
            uint outfitId = 0;

            if (!uint.TryParse(data, out outfitId))
            {
                return;
            }

            GetOutfit(client.vm, outfitId, outfit => {
                if (outfit == null)
                {
                    return;
                }

                var slot = GetSuitSlot(true);

                //store the outfit under dynamic costume
                client.vm.SendCommand(new VMNetSetOutfitCmd {
                    UID    = client.Avatar.PersistID,
                    Scope  = slot,
                    Outfit = outfit.asset_id
                });
                //3 uses dynamic costume, by using this we avoid updating default outfits without a good reason to
                client.SendOBJEvent(new VMEODEvent((short)VMEODRackEvent.TryOnOutfit, (short)RackType));
            });
        }
Exemple #11
0
        private void WearCostumeHandler(string evt, string costumeID, VMEODClient client)
        {
            // make sure the requested item is valid and is found in the collection
            ulong parsedID;
            ulong assetID;
            var   valid = ulong.TryParse(costumeID, out parsedID);

            if (valid)
            {
                assetID = FindInCollection(parsedID);
            }
            else
            {
                assetID = 0;
            }

            // send event to assign costume to avatar's dynamic costume and disconnect client
            if (assetID != 0)
            {
                client.vm.SendCommand(new VMNetSetOutfitCmd
                {
                    UID    = client.Avatar.PersistID,
                    Scope  = VMPersonSuits.DynamicCostume,
                    Outfit = assetID,
                });
                // now get out
                client.SendOBJEvent(new VMEODEvent((short)VMEODTrunkPluginEvents.Change));
                Server.Disconnect(client);
            }
        }
 private void SendClientBulletinData(VMEODClient client)
 {
     //todo: get info from client
     Server.vm.GlobalLink.GetBulletinState(Server.vm, (lastID, activity) =>
     {
         client.SendOBJEvent(new Model.VMEODEvent((short)VMEODBulletinEvent.Info, new short[] { (short)lastID, (short)(lastID >> 16), (short)activity }));
     });
 }
Exemple #13
0
        private void ToggleOnOffHandler(string evt, string OnOffStateString, VMEODClient client)
        {
            bool isOwner = (((VMTSOObjectState)Server.Object.TSOState).OwnerID == UserClient.Avatar.PersistID);

            if (isOwner)
            {
                client.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.ToggleOnOff));
            }
        }
Exemple #14
0
 /*
  * The object handles the payout, but the payout amount must be sent. The song length is sent for the animations of winning.
  */
 void GameOver(bool win)
 {
     SetTimer(-1);
     State = VMEODBandStates.Finale;
     if (win)
     {
         Lobby.Broadcast("Band_Win", CumulativePayout + "");
         // send the song length for the win animation
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.NewSongLength, CurrentSongLength));
         // get the prorated skill payout amount
         short skillPayout = (short)Math.Round(0m + (CombinedSkillAmount * SKILL_PAYOUT_MULTIPLIER * CurrentSongLength) / MAX_SONG_LENGTH);
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.NewSkillPayout, skillPayout));
         // send the win amount
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.WinRound, (short)CumulativePayout));
     }
     else
     {
         Controller.SendOBJEvent(new VMEODEvent((short)VMEODBandEventTypes.LoseRound));
     }
 }
Exemple #15
0
 public void P_DanceButton(string evt, string text, VMEODClient client)
 {
     if (!byte.TryParse(text, out var num))
     {
         return;
     }
     if (ControllerClient != null)
     {
         ControllerClient.SendOBJEvent(new VMEODEvent(num, client.Avatar.ObjectID));
     }
 }
Exemple #16
0
 protected void ExecuteQueuedEvents()
 {
     lock (SimanticsQueue)
     {
         var queue = new List <VMEODEvent>(SimanticsQueue);
         SimanticsQueue.Clear();
         foreach (var evt in queue)
         {
             Controller.SendOBJEvent(evt);
         }
     }
 }
Exemple #17
0
        private void PutOnNow(VMGLOutfit outfit, VMEODClient client)
        {
            var slot = GetSuitSlot(false);

            client.vm.SendCommand(new VMNetSetOutfitCmd
            {
                UID    = client.Avatar.PersistID,
                Scope  = slot,
                Outfit = outfit.asset_id
            });
            client.SendOBJEvent(new VMEODEvent((short)VMEODRackEvent.PutOnNow, (short)RackType));
        }
 public void S_AnimChanged(short evt, VMEODClient client)
 {
     if (NextAnimChange == -1)
     {
         AnimInProgress = false;
     }
     else
     {
         client.SendOBJEvent(new Model.VMEODEvent(NextAnimChange));
         NextAnimChange = -1;
     }
 }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="caller"></param>
        /// <param name="target"></param>
        /// <param name="cardinal"></param>
        /// <param name="partner"></param>
        private void ValidateLegalMove(FreeSOMazePlayer caller, AbstractMazeCell <FreeSOMazeData> target, FreeSOMazeCardinals cardinal, FreeSOMazePlayer partner)
        {
            if (caller != null && partner != null)
            {
                lock (MoveLock)
                {
                    if (GameState.Equals(FreeSOMazeStates.NavigatingMaze) && NextState.Equals(FreeSOMazeStates.Invalid) && caller.Cooldown >= GLOBAL_COOLDOWN)
                    {
                        bool rollForHint = true;
                        caller.MoveTo(target);
                        caller.Cooldown = 0;
                        caller.CurrentFacingCardinal = cardinal;
                        // is the partner at the target, meaning have the two met in any cell
                        if (partner.Location.Equals(target))
                        {
                            // gameover win!
                            rollForHint = false;
                            EnqueueGotoState(FreeSOMazeStates.Gameover);

                            // payout data
                            var skillPayout       = (int)Math.Round((caller.Skill + partner.Skill) * SKILL_PAYOUT_MULTIPLIER, 0);
                            var callerPayoutData  = new string[] { BasePayouts[ChosenMazeDifficulty] + "", skillPayout + "", RoundTimes[ChosenMazeDifficulty] - MazeTimeRemaining + "", caller.TotalMoves + "", partner.TotalMoves + "" };
                            var partnerPayoutData = new string[] { BasePayouts[ChosenMazeDifficulty] + "", skillPayout + "", RoundTimes[ChosenMazeDifficulty] - MazeTimeRemaining + "", partner.TotalMoves + "", caller.TotalMoves + "" };
                            var totalPayout       = skillPayout + BasePayouts[ChosenMazeDifficulty];

                            // queue gameover for caller
                            caller.QueuePayoutEvent("FreeSOMaze_win", callerPayoutData, totalPayout);
                            // queue gameover for partner
                            partner.QueuePayoutEvent("FreeSOMaze_win", partnerPayoutData, totalPayout);

                            // pay the object owner now, keeping in tradition with 10% of participant(s) payout
                            Controller.SendOBJEvent(new VMEODEvent((short)FreeSOMazeEvents.PayOwner, new short[] { (short)(totalPayout / 10) }));
                        }
                        caller.Send("FreeSOMaze_move_to", caller.GetLocationData(GetHint(caller, rollForHint)));
                        if (rollForHint) // don't send allow maze event on a gameover
                        {
                            SendAllowMazeEvent(caller, false);
                        }
                    }
                }
            }
        }
        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);
                }
            }
        }
Exemple #21
0
        public override void OnConnection(VMEODClient client)
        {
            var param = client.Invoker.Thread.TempRegisters;

            if (client.Avatar != null)
            {
                var slot = param[0];
                if (Lobby.Join(client, (short)(slot - 1)))
                {
                    client.SendOBJEvent(new VMEODEvent((short)VMEODPaperChaseObjEvent.Idle));

                    if (Lobby.IsFull())
                    {
                        StateMachine.TransitionTo(VMEODPaperChaseState.StartRound);
                    }
                }
            }
            else
            {
                Controller = client;
            }
        }
        public void P_Mode(string evt, string text, VMEODClient client)
        {
            //client has claimed they are in a different part of the bulletin board.
            //tell the object to change the animation

            short code;

            if (short.TryParse(text, out code))
            {
                if (code >= 0 && code < 3)
                {
                    if (AnimInProgress)
                    {
                        NextAnimChange = (short)(code + 2);
                    }
                    else
                    {
                        client.SendOBJEvent(new Model.VMEODEvent((short)(code + 2)));
                        AnimInProgress = true;
                    }
                }
            }
        }
Exemple #23
0
 /*
  * Upon a disconnect event, check to see if the deck has changed by way of the appopriate boolean. If so all of the Game variables are copied into the
  * variables of the Data. It's important to note steps have been taken to ensure that no empty strings are copied.
  * @param:client — the VMEODClient sending the disconnect event
  */
 public override void OnDisconnection(VMEODClient client)
 {
     if (DeckHasChanged)
     {
         bool errorThrown = false;
         // get the game info and put it into the data
         Data.GameTitle       = Game.GameTitle;
         Data.GameDescription = Game.GameDescription;
         Data.LastIndex       = (byte)Game.CurrentCardIndex;
         Data.CardText        = new List <string>(Game.Deck.Count);
         Data.EachCardsCount  = new List <byte>(Game.Deck.Count);
         foreach (var card in Game.Deck)
         {
             Data.CardText.Add(card.Text);
             Data.EachCardsCount.Add(card.Frequency);
         }
         try
         {
             lock (this) {
                 Server.vm.GlobalLink.SavePluginPersist(Server.vm, Server.Object.PersistID, Server.PluginID, Data.Save());
             }
         }
         catch (Exception)
         {
             errorThrown = true;
             // don't crash the server
         }
         // Send special event to clear the "pluginCardDrawn" flag in the object so the "View Current Card" interaction disappears until next "Draw Card"
         // but only do so if a new card deck was indeed successfully saved to the server. This was created via object .pif file.
         if (!errorThrown)
         {
             client.SendOBJEvent(new VMEODEvent(1));
         }
     }
     base.OnDisconnection(client);
 }
        public override void Tick()
        {
            base.Tick();
            Fresh.Tick();
            //push out ratings when we have a real client
            //under event 1
            if (ControllerPlugin == null)
            {
                ControllerPlugin = Server.vm.EODHost.GetFirstHandler <VMEODNightclubControllerPlugin>();
            }
            else if (ControllerClient != null)
            {
                if (TimeToRating-- == 0)
                {
                    TimeToRating = 5 * 30;
                    //todo: periodic send
                    bool newPatternCorrect = false;
                    for (int i = 0; i < 4; i++)
                    {
                        if (PatternDirty[i])
                        {
                            var p    = Patterns[i];
                            var ind  = (short)((p[0] - '0') * 16 + (p[1] - '0') * 4 + (p[2] - '0'));
                            var dist = ControllerPlugin.CurrentWinningDJPattern[i] - ind;

                            if (dist == 0 && !PatternCorrect[i])
                            {
                                PatternCorrect[i] = true;
                                newPatternCorrect = true;
                            }
                            Fresh.SendCommand(ind, i);

                            var distPct = 1 - Math.Abs(dist / 64f);

                            PatternRatings[i] = (distPct) * (distPct);
                            PatternDirty[i]   = false;
                        }
                    }
                    //recalculate our rating. send it out too!
                    var avg = PatternRatings.Average();

                    Rating = (int)Math.Min(100, Math.Round(100 * (0.8f * avg * Fresh.GoodScoreFreshness + 0.25f * ControllerPlugin.RoundPercentage())));
                    ControllerClient.SendOBJEvent(new VMEODEvent(1, (short)Rating));

                    if (newPatternCorrect)
                    {
                        var stationPos = ControllerClient.Invoker.Position;
                        ControllerPlugin.DanceFloor.AddParticle(VMEODNCParticleType.Arrow,
                                                                ControllerPlugin.DanceFloor.GetDirection(new Point(stationPos.TileX, stationPos.TileY)), 0, GroupID);
                    }
                    else if (LastRating != Rating && LastRating != -1)
                    {
                        if (LastRating > Rating)
                        {
                            ControllerPlugin.DanceFloor.AddParticle(VMEODNCParticleType.Colder, 0, 0, GroupID);
                        }
                        else
                        {
                            var rand = new Random();
                            ControllerPlugin.DanceFloor.AddParticle(VMEODNCParticleType.Line, (float)(rand.Next(8) * Math.PI / 4), 0, GroupID);
                        }
                    }
                    LastRating = Rating;
                }
            }
        }
Exemple #25
0
 public override void OnDisconnection(VMEODClient client)
 {
     client.SendOBJEvent(new VMEODEvent((short)VMEODRackEvent.PutClothesBack, (short)RackType));
     base.OnDisconnection(client);
 }
        private void GotoState(VMEODTwoPersonJobObjectMazePluginStates state)
        {
            switch (state)
            {
            case VMEODTwoPersonJobObjectMazePluginStates.Waiting_For_Player:
            {
                Reset();         // get a maze
                GameState = state;
                BroadcastSharedEvent("TSOMaze_Show_Waiting", new byte[0]);
                break;
            }

            case VMEODTwoPersonJobObjectMazePluginStates.Ready:
            {
                Tock = 0;
                RoundTimeRemaining = ReactionSeconds;
                GameState          = state;
                break;
            }

            case VMEODTwoPersonJobObjectMazePluginStates.Solving:
            {
                Tock = 0;
                RoundTimeRemaining = RoundSeconds;
                GameState          = state;
                SendCharismaPlayerData(false);         // finally allow input
                break;
            }

            case VMEODTwoPersonJobObjectMazePluginStates.Reacting:
            {
                if (MazeSolved)
                {
                    Controller.SendOBJEvent(new VMEODEvent((short)VMEODTwoPersonObjectMazePluginEvents.Success));
                    BroadcastSharedEvent("TSOMaze_Show_Result", new byte[] { 1 });         // win dialog as UIAlert
                    // send the Logic Player the solution by sending (y,x) coords
                    List <byte> solutionCoords = new List <byte>();
                    // but send the cell color first
                    solutionCoords.Add((byte)ThisRoundOriginColor);
                    for (int index = 0; index < SolutionPath.Count - 1; index++)
                    {
                        solutionCoords.Add((byte)SolutionPath[index].Row);
                        solutionCoords.Add((byte)SolutionPath[index].Column);
                    }
                    if (LogicPlayer != null)
                    {
                        LogicPlayer.Send("TSOMaze_Draw_Solution", solutionCoords.ToArray());
                    }
                }
                else         // failed to solve
                {
                    Controller.SendOBJEvent(new VMEODEvent((short)VMEODTwoPersonObjectMazePluginEvents.Failure));
                    BroadcastSharedEvent("TSOMaze_Show_Result", new byte[] { 0 });         // loss dialog as UIAlert
                }
                Tock = 0;
                RoundTimeRemaining = ReactionSeconds;
                GameState          = state;
                break;
            }
            }
        }
        public override void Tick()
        {
            if (ControllerClient != null)
            {
                if (Timer > 0)
                {
                    if (++TimerFrames >= 30)
                    {
                        TimerFrames = 0;
                        Timer--;
                        SendTime();
                    }
                }

                switch (State)
                {
                case VMEODPizzaState.Lobby:
                    int count = 0;
                    foreach (var player in Players)
                    {
                        if (player != null)
                        {
                            count++;
                        }
                    }
                    if (count == 4)
                    {
                        EnterState(VMEODPizzaState.PhoneCall);
                    }
                    break;

                case VMEODPizzaState.PhoneCall:
                    if (Timer == 0)
                    {
                        ControllerClient.SendOBJEvent(new VMEODEvent((short)VMEODPizzaObjEvent.RingPhone, Players[1].Avatar.ObjectID));
                        Timer = -1;
                    }
                    break;

                case VMEODPizzaState.Contribution:
                    if (Timer == 0)
                    {
                        Timer = -1;
                        //bake enter state will assign unassigned players.
                        if (State == VMEODPizzaState.Contribution)
                        {
                            EnterState(VMEODPizzaState.Bake);
                        }
                    }
                    break;

                case VMEODPizzaState.Bake:
                    break;

                case VMEODPizzaState.Break:
                    if (Timer == 0)
                    {
                        Timer = -1;
                        EnterState(VMEODPizzaState.Lobby);
                    }
                    break;
                }
            }
        }
Exemple #28
0
        private void BetHandler(string evt, string betAmountString, VMEODClient client)
        {
            bool  betIsValid = false;
            short betAmount;
            bool  inputIsValid = Int16.TryParse(betAmountString, out betAmount);

            // Check to make sure the valid input is actually a valid bet by testing MachineBetDenomination and betAmount
            if (inputIsValid)
            {
                if (betAmount % MachineBetDenomination == 0)
                {
                    if (betAmount >= MachineBetDenomination)
                    {
                        if (betAmount <= MachineBetDenomination * 5)
                        {
                            betIsValid = true;
                        }
                    }
                }
            }

            if (betIsValid)
            {
                // roll the slots rng and get result, send to UI and send to SlotResultHandler() to determine amount of winnings, winnings = 0 is a loss
                var thisGameBetAndResults = RollNewGame(betAmount);
                var winnings = SlotResultHandler(thisGameBetAndResults);

                // attempt to debit player the bet amount
                var VM = client.vm;

                VM.GlobalLink.PerformTransaction(VM, false, client.Avatar.PersistID, Server.Object.PersistID, (int)(betAmount),

                                                 (bool success, int transferAmount, uint uid1, uint budget1, uint uid2, uint budget2) =>
                {
                    if (success)
                    {
                        // update the balance of the machine
                        MachineBalance  = (int)(budget2);
                        CurrentWinnings = winnings;
                        if (CurrentWinnings > 0)
                        {
                            // dispatch event to tell object the winning amount
                            UserClient.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.SetWinAmount, new short[1] {
                                (short)(CurrentWinnings)
                            }));
                            // dispatch event to tell the object that the user has won
                            UserClient.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.ExecuteWin, new short[1] {
                                betAmount
                            }));
                        }
                        else
                        {
                            // dispatch event to tell object that the user has lost
                            UserClient.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.ExecuteLoss, new short[1] {
                                betAmount
                            }));
                        }
                        // send spins results to UI to simulate gameplay
                        UserClient.Send("slots_spin", new Byte[] { (byte)SlotsStops[thisGameBetAndResults[1]], (byte)SlotsStops[thisGameBetAndResults[2]],
                                                                   (byte)SlotsStops[thisGameBetAndResults[3]] });
                    }
                    else
                    {
                        CurrentWinnings = 0; // forfeit any winnings
                        client.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.InsufficientFunds));
                    }
                });
            }
            else
            {
                // bet input was invalid due to a modified client or some major server communication error
                client.SendOBJEvent(new VMEODEvent((short)VMOEDSlotsObjectEvents.InsufficientFunds));
            }
        }
Exemple #29
0
 public override void OnDisconnection(VMEODClient client)
 {
     client.SendOBJEvent(new VMEODEvent((short)VMEODDresserEvent.CloseDresser));
     base.OnDisconnection(client);
 }
Exemple #30
0
        private void ChangeOutfit(string evt, string data, VMEODClient client)
        {
            uint outfitId = 0;

            if (!uint.TryParse(data, out outfitId))
            {
                return;
            }

            GetOutfit(client.vm, outfitId, outfit =>
            {
                if (outfit == null)
                {
                    return;
                }
                var type = (VMPersonSuits)outfit.outfit_type;

                VMPersonSuits storageType = VMPersonSuits.DynamicDaywear;
                VMDresserOutfitTypes dresserOutfitType = VMDresserOutfitTypes.DynamicDaywear;

                switch (type)
                {
                case VMPersonSuits.DefaultDaywear:
                    storageType       = VMPersonSuits.DynamicDaywear;
                    dresserOutfitType = VMDresserOutfitTypes.DynamicDaywear;
                    break;

                case VMPersonSuits.DefaultSleepwear:
                    storageType       = VMPersonSuits.DynamicSleepwear;
                    dresserOutfitType = VMDresserOutfitTypes.DynamicSleepwear;
                    break;

                case VMPersonSuits.DefaultSwimwear:
                    storageType       = VMPersonSuits.DynamicSwimwear;
                    dresserOutfitType = VMDresserOutfitTypes.DynamicSwimwear;
                    break;

                case VMPersonSuits.DecorationHead:
                    storageType       = VMPersonSuits.DecorationHead;
                    dresserOutfitType = VMDresserOutfitTypes.DecorationHead;
                    break;

                case VMPersonSuits.DecorationBack:
                    storageType       = VMPersonSuits.DecorationBack;
                    dresserOutfitType = VMDresserOutfitTypes.DecorationBack;
                    break;

                case VMPersonSuits.DecorationShoes:
                    storageType       = VMPersonSuits.DecorationShoes;
                    dresserOutfitType = VMDresserOutfitTypes.DecorationShoes;
                    break;

                case VMPersonSuits.DecorationTail:
                    storageType       = VMPersonSuits.DecorationTail;
                    dresserOutfitType = VMDresserOutfitTypes.DecorationTail;
                    break;
                }

                client.vm.SendCommand(new VMNetSetOutfitCmd
                {
                    UID    = client.Avatar.PersistID,
                    Scope  = storageType,
                    Outfit = outfit.asset_id
                });
                client.SendOBJEvent(new VMEODEvent((short)VMEODDresserEvent.ChangeClothes, (short)dresserOutfitType));
            });
        }