Beispiel #1
0
        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);
        }
Beispiel #2
0
 private void OnConnected(VMEODClient client)
 {
     Lobby.GetSlotData(client).PlayerPersist = client.Avatar.PersistID;
     if (Lobby.IsFull())
     {
         HadTwoPlayers = true;
         BroadcastTradeData(false);
     }
 }
Beispiel #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;
            }
        }