/// <summary> /// 创建部下角色 /// </summary> /// <param name="classId"></param> /// <returns></returns> private FollowingRole CreateFollowingRole(int classId) { FollowingRole role = new FollowingRole(NextRoleGUID++); RoleData template = GetOrCreateFollowingTemplate(classId); if (!role.Load(template)) { return(null); } return(role); }
/// <summary> /// 获取或创建角色 /// 独有角色: characterId /// 部下杂兵角色: classId /// </summary> /// <returns></returns> public Role GetOrCreateRole(int id, RoleType roleType) { if (roleType == RoleType.Unique) { if (!uniqueRoles.TryGetValue(id, out UniqueRole role)) { role = CreateUniqueRole(id); if (role != null) { uniqueRoles.Add(role.CharacterId, role); } } return(role); } FollowingRole followingRole = CreateFollowingRole(id); if (followingRole != null) { followingRoles.Add(followingRole.Guid, followingRole); } return(followingRole); }