Exemple #1
0
        public virtual Task <RoleEnterZoneResponse> DoPlayerEnterReplace(AreaZonePlayer player, RoleEnterZoneRequest enter)
        {
            return(node.QueuePlayerTaskAsync <RoleEnterZoneResponse>(player.RoleUUID, (instancePlayer) =>
            {
                if (instancePlayer == null)
                {
                    return new RoleEnterZoneResponse()
                    {
                        s2c_code = RoleEnterZoneResponse.CODE_ERROR
                    };
                }
                return (new RoleEnterZoneResponse()
                {
                    mapTemplateID = this.MapTemplateID,
                    zoneUUID = this.ZoneUUID,
                    zoneTemplateID = this.ZoneTemplateID,
                    roleBattleData = enter.roleData,
                    roleDisplayName = enter.roleDisplayName,
                    roleUnitTemplateID = enter.roleUnitTemplateID,
                    roleScenePos = new ZonePosition()
                    {
                        x = instancePlayer.X,
                        y = instancePlayer.Y,
                        z = instancePlayer.Z
                    },
                    areaName = service.SelfAddress.ServiceName,
                    areaNode = service.SelfAddress.ServiceNode,
                    guildUUID = enter.guildUUID,
                    s2c_code = RoleEnterZoneResponse.CODE_OK_REPLACE
                });
            }));


            // var client = this.node.GetPlayerClient(player.RoleUUID);

            /*
             * float px = 0, py = 0, pz = 0;
             * if (client != null)
             * {
             *  px = client.Actor.X;
             *  py = client.Actor.Y;
             *  pz = client.Actor.Z;
             * }
             *
             * return (new RoleEnterZoneResponse()
             * {
             *  mapTemplateID = this.MapTemplateID,
             *  zoneUUID = this.ZoneUUID,
             *  zoneTemplateID = this.ZoneTemplateID,
             *  roleBattleData = enter.roleData,
             *  roleDisplayName = enter.roleDisplayName,
             *  roleUnitTemplateID = enter.roleUnitTemplateID,
             *  roleScenePos = new ZonePosition() { x = px, y = py, z = pz},
             *  areaName = service.SelfAddress.ServiceName,
             *  areaNode = service.SelfAddress.ServiceNode,
             *  guildUUID = enter.guildUUID,
             *  s2c_code = RoleEnterZoneResponse.CODE_OK_REPLACE;
             * });
             */
        }
Exemple #2
0
        public virtual Task <RoleLeaveZoneResponse> DoPlayerLeaveAsync(AreaZonePlayer player, RoleLeaveZoneRequest leave)
        {
            var tcs = new System.Threading.Tasks.TaskCompletionSource <RoleLeaveZoneResponse>();

            this.node.PlayerLeave(player,
                                  (c) =>
            {
                tcs.TrySetResult(new RoleLeaveZoneResponse()
                {
                    lastScenePos = new Data.ZonePosition()
                    {
                        x = c.Actor.X,
                        y = c.Actor.Y,
                        z = c.Actor.Z,
                    },
                    curHP             = c.Actor.CurrentHP,
                    curMP             = c.Actor.CurrentMP,
                    LeaveZoneSaveData = c.LastZoneSaveData,
                });
            },
                                  (e) =>
            {
                tcs.TrySetResult(new RoleLeaveZoneResponse()
                {
                    s2c_code = RoleLeaveZoneResponse.CODE_ERROR,
                    s2c_msg  = e.Message,
                });
            });
            return(tcs.Task);
        }
Exemple #3
0
 public virtual async Task <RoleEnterZoneResponse> DoPlayerEnterAsync(AreaZonePlayer player, RoleEnterZoneRequest enter)
 {
     if (await player.OnEnterAsync() == false)
     {
         log.Error("Can Not Find Session Or Logic : " + enter.roleSessionName + " : " + enter.roleUUID);
     }
     try
     {
         player.SessionReconnect();
         var tcs = new System.Threading.Tasks.TaskCompletionSource <RoleEnterZoneResponse>();
         this.node.PlayerEnter(player, ToAddUnit(enter), client =>
         {
             if (HasAddPlayer == false)
             {
                 HasAddPlayer = true;
             }
             client.Actor.SetAttribute(nameof(AreaZonePlayer.RoleSessionName), player.RoleSessionName);
             tcs.TrySetResult(new RoleEnterZoneResponse()
             {
                 s2c_code           = RoleEnterZoneResponse.CODE_OK,
                 mapTemplateID      = this.MapTemplateID,
                 zoneUUID           = this.ZoneUUID,
                 zoneTemplateID     = this.ZoneTemplateID,
                 roleBattleData     = enter.roleData,
                 roleDisplayName    = enter.roleDisplayName,
                 roleUnitTemplateID = enter.roleUnitTemplateID,
                 roleScenePos       = new ZonePosition()
                 {
                     x = client.Actor.X,
                     y = client.Actor.Y,
                     z = client.Actor.Z
                 },
                 areaName  = service.SelfAddress.ServiceName,
                 areaNode  = service.SelfAddress.ServiceNode,
                 guildUUID = enter.guildUUID,
             });
         }, err =>
         {
             tcs.TrySetResult(new RoleEnterZoneResponse()
             {
                 s2c_code = RoleEnterZoneResponse.CODE_ERROR,
                 s2c_msg  = err.Message,
             });
         });
         return(await tcs.Task);
     }
     catch (Exception err)
     {
         log.Error(err);
         return(new RoleEnterZoneResponse()
         {
             s2c_code = RoleEnterZoneResponse.CODE_ERROR,
             s2c_msg = err.Message,
         });
     }
 }
Exemple #4
0
 public Task <GetRolePositionResponse> DoGetPlayerPosition(AreaZonePlayer player, GetRolePositionRequest req)
 {
     return(node.QueuePlayerTaskAsync <GetRolePositionResponse>(player.RoleUUID, (instancePlayer) =>
     {
         return (new GetRolePositionResponse()
         {
             x = instancePlayer.X,
             y = instancePlayer.Y,
             z = instancePlayer.Z,
             s2c_code = GetRolePositionResponse.CODE_OK
         });
     }));
 }
Exemple #5
0
 public virtual Task DoPlayerBeginLeaveAsync(AreaZonePlayer player)
 {
     player.SessionBeginLeave();
     return(this.node.QueueSceneTaskAsync(z => { return 1; }));
 }
Exemple #6
0
 public virtual void DoPlayerReconnect(AreaZonePlayer player)
 {
     player.SessionReconnect();
     this.node.PlayerReconnect(player, (client) => { }, (err) => { });
 }