protected override void FixedUpdate()
 {
     base.FixedUpdate();
     if (IsServer)
     {
         ClusterClient.Update();
         if (ClusterClient.IsAppRegistered)
         {
             if (restartingScenes.Count > 0)
             {
                 string tempRestartingScenes;
                 while (restartingScenes.TryDequeue(out tempRestartingScenes))
                 {
                     SpawnMap(tempRestartingScenes, true);
                 }
             }
         }
         if (mainThreadActions.Count > 0)
         {
             Action tempMainThreadAction;
             while (mainThreadActions.TryDequeue(out tempMainThreadAction))
             {
                 if (tempMainThreadAction != null)
                 {
                     tempMainThreadAction.Invoke();
                 }
             }
         }
     }
 }
        public override void WarpCharacterToInstance(BasePlayerCharacterEntity playerCharacterEntity, string mapName, Vector3 position, bool overrideRotation, Vector3 rotation)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            if (!CanWarpCharacter(playerCharacterEntity))
            {
                return;
            }
            // Generate instance id
            string instanceId = GenericUtils.GetUniqueId();
            // Prepare data for warp character later when instance map server registered to this map server
            HashSet <uint> instanceMapWarpingCharacters = new HashSet <uint>();
            PartyData      party;
            if (ServerPartyHandlers.TryGetParty(playerCharacterEntity.PartyId, out party))
            {
                // If character is party leader, will bring party member to join instance
                if (party.IsLeader(playerCharacterEntity.Id))
                {
                    List <BasePlayerCharacterEntity> aliveAllies = playerCharacterEntity.FindAliveCharacters <BasePlayerCharacterEntity>(CurrentGameInstance.joinInstanceMapDistance, true, false, false);
                    foreach (BasePlayerCharacterEntity aliveAlly in aliveAllies)
                    {
                        if (!party.IsMember(aliveAlly.Id))
                        {
                            continue;
                        }
                        instanceMapWarpingCharacters.Add(aliveAlly.ObjectId);
                        aliveAlly.IsWarping = true;
                    }
                    instanceMapWarpingCharacters.Add(playerCharacterEntity.ObjectId);
                    playerCharacterEntity.IsWarping = true;
                }
                else
                {
                    ServerGameMessageHandlers.SendGameMessage(playerCharacterEntity.ConnectionId, UITextKeys.UI_ERROR_PARTY_MEMBER_CANNOT_ENTER_INSTANCE);
                    return;
                }
            }
            else
            {
                // If no party enter instance alone
                instanceMapWarpingCharacters.Add(playerCharacterEntity.ObjectId);
                playerCharacterEntity.IsWarping = true;
            }
            instanceMapWarpingCharactersByInstanceId.TryAdd(instanceId, instanceMapWarpingCharacters);
            instanceMapWarpingLocations.TryAdd(instanceId, new InstanceMapWarpingLocation()
            {
                mapName          = mapName,
                position         = position,
                overrideRotation = overrideRotation,
                rotation         = rotation,
            });
            ClusterClient.SendRequest(MMORequestTypes.RequestSpawnMap, new RequestSpawnMapMessage()
            {
                mapId                        = mapName,
                instanceId                   = instanceId,
                instanceWarpPosition         = position,
                instanceWarpOverrideRotation = overrideRotation,
                instanceWarpRotation         = rotation,
            }, responseDelegate: (responseHandler, responseCode, response) => OnRequestSpawnMap(responseHandler, responseCode, response, instanceId), millisecondsTimeout: mapSpawnMillisecondsTimeout);
#endif
        }
Exemple #3
0
        public async UniTaskVoid IncreaseGuildExp(IPlayerCharacterData playerCharacter, int exp)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            ValidateGuildRequestResult validateResult = this.CanIncreaseGuildExp(playerCharacter, exp);
            if (!validateResult.IsSuccess)
            {
                return;
            }
            AsyncResponseData <GuildResp> resp = await DbServiceClient.IncreaseGuildExpAsync(new IncreaseGuildExpReq()
            {
                GuildId = validateResult.GuildId,
                Exp     = exp,
            });

            if (!resp.IsSuccess)
            {
                return;
            }
            GuildData guild = resp.Response.GuildData;
            SetGuild(validateResult.GuildId, guild);
            // Broadcast via chat server
            if (ClusterClient.IsNetworkActive)
            {
                ClusterClient.SendSetGuildLevelExpSkillPoint(MMOMessageTypes.UpdateGuild, guild.id, guild.level, guild.exp, guild.skillPoint);
            }
            GameInstance.ServerGameMessageHandlers.SendSetGuildLevelExpSkillPointToMembers(guild);
#endif
        }
 public override void OnStartServer()
 {
     this.InvokeInstanceDevExtMethods("OnStartServer");
     ClusterClient.OnAppStart();
     spawningPort = startPort;
     portCounter  = startPort;
     base.OnStartServer();
 }
        protected override void Start()
        {
            // Force use TcpTransport for server-to-server connections.
            useWebSocket     = false;
            TransportFactory = gameObject.GetOrAddComponent <TcpTransportFactory>();
            maxConnections   = int.MaxValue;
            base.Start();
#if UNITY_STANDALONE && !CLIENT_BUILD
            ClusterClient = new ClusterClient(this);
            ClusterClient.onResponseAppServerRegister = OnResponseAppServerRegister;
            ClusterClient.RegisterRequestHandler <RequestSpawnMapMessage, ResponseSpawnMapMessage>(MMORequestTypes.RequestSpawnMap, HandleRequestSpawnMap);
#endif
        }
 public override void OnStopServer()
 {
     ClusterClient.OnAppStop();
     Clean();
     base.OnStopServer();
 }