示例#1
0
        /// <summary>
        /// 创建场景
        /// </summary>
        /// <param name="create"></param>
        /// <param name="cb"></param>
        public virtual async Task <CreateZoneNodeResponse> CreateZone(CreateZoneNodeRequest create)
        {
            //if (dungeon_scheduler.IsMapOpen(create.mapTemplateID))
            {
                var area = AreaDispatch(create.expectAreaNode);
                if (area != null)
                {
                    create.managerZoneUUID = (Guid.NewGuid().ToString());
                    //先添加以防止二次进入//
                    var map_data   = RPGServerTemplateManager.Instance.GetMapTemplate(create.mapTemplateID);
                    var scene_data = RPGServerBattleManager.Instance.GetSceneAsCache(map_data.zone_template_id);

                    ZoneInfo info = new ZoneInfo(create.managerZoneUUID, area, map_data, scene_data, create.serverID, create.serverGroupID, create.guildUUID, create.expectAreaNode)
                    {
                        teamID        = create.teamID,
                        createrRoleID = create.createRoleID,
                        roomKey       = create.roomKey
                    };
                    zones.AddZone(info);
                    area.currentZoneCount++;
                    var rsp = await area.service.CallAsync <CreateZoneNodeResponse>(create);

                    if (!Response.CheckSuccess(rsp))
                    {
                        zones.RemoveZone(create.managerZoneUUID);
                        area.currentZoneCount--;
                    }
                    else
                    {
                        log.InfoFormat("CreateZone: {0} : TotalZoneCount={1}", scene_data, zones.Count);
                    }
                    return(rsp);
                }
                else
                {
                    return(new CreateZoneNodeResponse()
                    {
                        s2c_code = CreateZoneNodeResponse.CODE_ERROR,
                    });
                }
            }
        }