Пример #1
0
        private void OnPingPongCompleted(Error error, Guid clientId)
        {
            //Currently MatchEngine will be launched immediately and it does not care about different RTT for diffierent clients.
            //Some clients will look -50 ms to the past and some clients will look -500 ms or more to the past.
            //Is this a big deal? Don't know... Further investigation and playtest needed

            if (m_engine == null)
            {
                throw new InvalidOperationException("m_engine == null");
            }


            m_readyToPlayAllArgs = GetReadyToPlayAllArgs(error);

            if (HasError(error))
            {
                ReadyToPlayAll(error, m_readyToPlayAllArgs);
            }
            else
            {
                m_botControlManager = new BotControlManager(
                    m_time,
                    m_engine,
                    m_room.Players.Select(p => m_players.ContainsKey(p) ? m_players[p] : null).ToArray(),
                    m_clientIds.ToArray());
                m_botControlManager.ActivateNext();
            }
        }
Пример #2
0
        public void Broadcast(RemoteEvent.Evt evt, Error error, ServerEventArgs globalArgs, params RemoteArg[] args)
        {
            RemoteEvent remoteEvent = new RemoteEvent(evt, error, args);

            byte[] result = m_serializer.Serialize(remoteEvent);
            if (globalArgs.Targets != null && globalArgs.Targets.Length > 0)
            {
                Broadcast(globalArgs.Targets, result);
            }
            else
            {
                BroadcastAllExcept(globalArgs.Except, result);
            }
        }
Пример #3
0
        public void GetState(Guid clientId, ServerEventHandler <Player[], Dictionary <Guid, Dictionary <Guid, Player> >, VoxelAbilitiesArray[], SerializedTaskArray[], SerializedTaskTemplatesArray[], AssignmentGroupArray[], Room, MapRoot> callback)
        {
            Error error = new Error(StatusCode.OK);

            if (!m_clientIdToPlayers.ContainsKey(clientId))
            {
                error.Code = StatusCode.NotRegistered;
                callback(error, null, null, null, null, null, null, null, null);
                return;
            }


            m_readyToPlayAllArgs = GetReadyToPlayAllArgs(error);
            callback(error, m_readyToPlayAllArgs.Arg, m_readyToPlayAllArgs.Arg2, m_readyToPlayAllArgs.Arg3, m_readyToPlayAllArgs.Arg4, m_readyToPlayAllArgs.Arg5, m_readyToPlayAllArgs.Arg6, m_readyToPlayAllArgs.Arg7, m_engine.Map);
        }
 private void OnRoomDestoryed(Error error, ServerEventArgs args)
 {
     Broadcast(RemoteEvent.Evt.RoomDestroyed, error, args);
 }
 private void OnRoomsListChanged(Error error, ServerEventArgs args)
 {
     Broadcast(RemoteEvent.Evt.RoomsListChanged, error, args);
 }
 private void OnLoggedOff(Error error, ServerEventArgs <Guid[]> args)
 {
     Broadcast(RemoteEvent.Evt.LoggedOff, error, args, RemoteArg.Create(args.Arg));
 }
 private void OnLoggedIn(Error error, ServerEventArgs args)
 {
     Broadcast(RemoteEvent.Evt.LoggedIn, error, args);
 }
 private void OnChatMessage(Error error, ServerEventArgs <ChatMessage> args)
 {
     Broadcast(RemoteEvent.Evt.ChatMessage, error, args, RemoteArg.Create(args.Arg));
 }
 private void OnLaunched(Error error, ServerEventArgs <string> args)
 {
     Broadcast(RemoteEvent.Evt.Launched, error, args, RemoteArg.Create(args.Arg));
 }
 private void OnReadyToLaunch(Error error, ServerEventArgs <Room> args)
 {
     Broadcast(RemoteEvent.Evt.ReadyToLaunch, error, args, RemoteArg.Create(args.Arg));
 }
 private void OnLeftRoom(Error error, ServerEventArgs <Guid[], Room> args)
 {
     Broadcast(RemoteEvent.Evt.LeftRoom, error, args, RemoteArg.Create(args.Arg), RemoteArg.Create(args.Arg2));
 }
 private void OnPaused(Error error, ServerEventArgs <bool> args)
 {
     Broadcast(RemoteEvent.Evt.Pause, error, args, RemoteArg.Create(args.Arg));
 }
 private void OnPing(Error error, ServerEventArgs <RTTInfo> args)
 {
     Broadcast(RemoteEvent.Evt.Ping, error, args, RemoteArg.Create(args.Arg));
 }
Пример #14
0
        GetReadyToPlayAllArgs(Error error)
        {
            Player[] players;
            VoxelAbilitiesArray[]          abilities;
            SerializedTaskArray[]          taskInfo;
            SerializedTaskTemplatesArray[] taskTemplateInfo;
            AssignmentGroupArray[]         assignmentGroupArray;
            if (m_room != null)
            {
                enabled        = true;
                m_prevTickTime = m_time.Time;
                m_initialized  = true;

                error.Code = StatusCode.OK;
                players    = new Player[m_players.Count];

                List <IBotController> bots = new List <IBotController>();

                //Will override or
                abilities            = new VoxelAbilitiesArray[m_players.Count];
                taskInfo             = new SerializedTaskArray[m_players.Count];
                taskTemplateInfo     = new SerializedTaskTemplatesArray[m_players.Count];
                assignmentGroupArray = new AssignmentGroupArray[players.Length];
                for (int i = 0; i < m_players.Count; ++i)
                {
                    Player player = m_players[m_room.Players[i]];

                    players[i]              = player;
                    abilities[i]            = m_abilities[m_room.Players[i]];
                    taskInfo[i]             = m_taskTemplates[m_room.Players[i]];
                    taskTemplateInfo[i]     = m_taskTemplatesInfo[m_room.Players[i]];
                    assignmentGroupArray[i] = new AssignmentGroupArray
                    {
                        Groups = m_engine.GetPlayerView(i).AssignmentsController.GetGroups()
                    };
                    if (player.IsBot && player.BotType != BotType.Replay)
                    {
                        bots.Add(MatchFactory.CreateBotController(player, m_engine.GetTaskEngine(i)));
                    }
                }

                m_bots = bots.ToArray();
            }
            else
            {
                error.Code           = StatusCode.NotFound;
                error.Message        = "Room not found";
                players              = new Player[0];
                abilities            = new VoxelAbilitiesArray[0];
                taskInfo             = new SerializedTaskArray[0];
                taskTemplateInfo     = new SerializedTaskTemplatesArray[0];
                assignmentGroupArray = new AssignmentGroupArray[0];
            }


            var readyToPlayAllArgs = new ServerEventArgs <Player[], Dictionary <Guid, Dictionary <Guid, Player> >, VoxelAbilitiesArray[], SerializedTaskArray[], SerializedTaskTemplatesArray[], AssignmentGroupArray[], Room>();

            readyToPlayAllArgs.Arg    = players;
            readyToPlayAllArgs.Arg2   = m_clientIdToPlayers;
            readyToPlayAllArgs.Arg3   = abilities;
            readyToPlayAllArgs.Arg4   = taskInfo;
            readyToPlayAllArgs.Arg5   = taskTemplateInfo;
            readyToPlayAllArgs.Arg6   = assignmentGroupArray;
            readyToPlayAllArgs.Arg7   = m_room;
            readyToPlayAllArgs.Except = Guid.Empty;
            return(readyToPlayAllArgs);
        }