public static Gamer Create(long userId, long sessionId) { Gamer gamer = ComponentFactory.CreateWithId <Gamer>(userId); gamer.AddComponent <GamerGateComponent, long>(sessionId); return(gamer); }
/// <summary> /// 建立關係申請 /// </summary> /// <param name="uid"></param> /// <param name="targetUid"></param> /// <returns></returns> public static async ETTask <RelationshipApply> AddRelationshipApply(long senderUid, long receiverUid) { bool exist = await ExistRelationshipApply(senderUid, receiverUid); if (exist) { return(null); } var relationshipApply = ComponentFactory.CreateWithId <RelationshipApply>(IdGenerater.GenerateId()); relationshipApply.applyId = relationshipApply.Id; var senderUser = await UserDataHelper.FindOneUser(senderUid); relationshipApply.senderUid = senderUid; relationshipApply.senderName = senderUser.name; relationshipApply.senderLocation = senderUser.location; relationshipApply.senderMileage = senderUser.playerRideTotalInfo.Mileage; var receiverUser = await UserDataHelper.FindOneUser(receiverUid); relationshipApply.receiverUid = receiverUid; relationshipApply.receiverName = receiverUser.name; relationshipApply.receiverLocation = receiverUser.location; relationshipApply.receiverMileage = receiverUser.playerRideTotalInfo.Mileage; await dbProxy.Save(relationshipApply); await dbProxy.SaveLog(senderUid, DBLog.LogType.RelationshipApply, relationshipApply); return(relationshipApply); }
public static Monster ToMonster(this Monsterdb self) { Monster monster = ComponentFactory.CreateWithId <Monster>(self.Id); monster.spawnPosition = new Vector3((float)self.spawnVec[0], (float)self.spawnVec[1], (float)self.spawnVec[2]); return(monster); }
//进去签到 public static async Task <bool> UserTodaySingIn(this SingInActivityComponent singInActivityComponent, long userId) { List <UserSingInState> userSingInStates = await singInActivityComponent.dbProxyComponent.Query <UserSingInState>(userSingInState => userSingInState.UserId == userId); if (userSingInStates.Count > 0) { if (userSingInStates[0].SingInTime != 0 && TimeTool.TimeStampIsToday(userSingInStates[0].SingInTime)) { return(false); } } UserSingInState sueSingInState = ComponentFactory.CreateWithId <UserSingInState>(userId); sueSingInState.SingInTime = TimeTool.GetCurrenTimeStamp(); sueSingInState.UserId = userId; sueSingInState.SingInDays = 1; if (userSingInStates.Count > 0) { sueSingInState.SingInDays = userSingInStates[0].SingInDays + 1; } await singInActivityComponent.SendUserGetGoods(userId, sueSingInState.SingInDays); await singInActivityComponent.dbProxyComponent.Save(sueSingInState); return(true); }
protected override async ETTask Run(Session session, G2M_CreateUnit request, M2G_CreateUnit response, Action reply) { Unit unit = ComponentFactory.CreateWithId <Unit>(IdGenerater.GenerateId()); unit.Position = new Vector3(-10, 0, -10); unit.AddComponent <MoveComponent>(); unit.AddComponent <UnitPathComponent>(); await unit.AddComponent <MailBoxComponent>().AddLocation(); unit.AddComponent <UnitGateComponent, long>(request.GateSessionId); Game.Scene.GetComponent <UnitComponent>().Add(unit); response.UnitId = unit.Id; // 广播创建的unit M2C_CreateUnits createUnits = new M2C_CreateUnits(); Unit[] units = Game.Scene.GetComponent <UnitComponent>().GetAll(); foreach (Unit u in units) { UnitInfo unitInfo = new UnitInfo(); unitInfo.X = u.Position.x; unitInfo.Y = u.Position.y; unitInfo.Z = u.Position.z; unitInfo.UnitId = u.Id; createUnits.Units.Add(unitInfo); } MessageHelper.Broadcast(createUnits); reply(); }
/// <summary> /// 建立關係 /// </summary> /// <param name="uid"></param> /// <param name="targetUid"></param> /// <returns></returns> public static async ETTask <Relationship> AddRelationship(long uid, long targetUid) { bool exist = await ExistRelationship(uid, targetUid); if (exist) { return(null); } long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); Relationship relationship1 = ComponentFactory.CreateWithId <Relationship>(IdGenerater.GenerateId()); relationship1.uid = uid; relationship1.targetUid = targetUid; relationship1.relationshipType = (int)Relationship.RelationType.Friend; relationship1.confirmedAt = now; relationship1.createAt = now; Relationship relationship2 = ComponentFactory.CreateWithId <Relationship>(IdGenerater.GenerateId()); relationship2.uid = targetUid; relationship2.targetUid = uid; relationship2.relationshipType = (int)Relationship.RelationType.Friend; relationship2.confirmedAt = now; relationship2.createAt = now; var list = new List <ComponentWithId> { relationship1, relationship2 }; await dbProxy.SaveBatch(list); await dbProxy.SaveLogBatch(uid, DBLog.LogType.Relationship, list); return(relationship1); }
//记录一周获胜记录 //如果只变化财富或胜场数 对应的另外一个输入时为0 public static async Task RecordWeekRankLog(long uid, long wealth, int count) { try { DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); List <Log_Rank> logs = await proxyComponent.QueryJson <Log_Rank>($"{{UId:{uid}}}"); if (logs.Count <= 0) { Log_Rank info = ComponentFactory.CreateWithId <Log_Rank>(IdGenerater.GenerateId()); info.UId = uid; info.WinGameCount += count; info.Wealth += wealth; await proxyComponent.Save(info); } else { logs[0].WinGameCount += count; logs[0].Wealth += wealth; await proxyComponent.Save(logs[0]); } } catch (Exception e) { Log.Error(e); } }
public static Unit CreateStaticObj_Box(UnitData unitData, PBoxData pBoxData) { Unit unit = ComponentFactory.CreateWithId <Unit>(IdGenerater.GenerateId()); AddCollider_BoxData(unit, unitData, false, pBoxData, true); return(unit); }
protected override async void Run(Session session, C2R_Register message, Action <R2C_Register> reply) { Log.Info($"----{JsonHelper.ToJson(message)}"); R2C_Register register = new R2C_Register(); try { string query = $"{"{"}'Account':'{message.Account}'{"}"}"; Log.Info($"----{query}"); List <AccountInfo> accounts = await Game.Scene.GetComponent <DBProxyComponent>().QueryJson <AccountInfo>(query); if (accounts.Count > 0) { register.Error = ErrorCode.ERR_AccountExist; reply(register); return; } Log.Info($"----{accounts.Count}"); AccountInfo accountInfo = ComponentFactory.CreateWithId <AccountInfo>(IdGenerater.GenerateId()); accountInfo.Account = message.Account; accountInfo.Password = message.Password; await Game.Scene.GetComponent <DBProxyComponent>().Save(accountInfo); reply(register); } catch (Exception e) { Log.Error(e.ToString()); ReplyError(register, e, reply); } }
public static async ETVoid CreateUser(string account, string password) { //数据库操作对象 DBProxyComponent dbProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); //新建账号 AccountInfo newAccount = ComponentFactory.CreateWithId <AccountInfo>(IdGenerater.GenerateId()); newAccount.Account = account; newAccount.Password = password; //新建用户信息 UserInfo newUser = ComponentFactory.CreateWithId <UserInfo>(newAccount.Id); newUser.NickName = $"召唤师{account}"; newUser.Level = 1; newUser.points = 10000; newUser.Diamods = 10000; newUser.Goldens = 10000; newUser._1v1Wins = 0; newUser._1v1Loses = 0; newUser._5v5Wins = 0; newUser._5v5Loses = 0; // 保存用户数据到数据库 await dbProxyComponent.Save(newAccount); await dbProxyComponent.Save(newUser); }
/// <summary> /// 攻击 CD 计时 /// </summary> /// <param name="self"></param> public static void AttackTarget(this AttackComponent self) { if (self.delTime == 0) { //普通攻击,相当于施放技能41101,技能等级为0 SkillItem skillItem = ComponentFactory.CreateWithId <SkillItem>(41101); skillItem.UpdateLevel(0); skillItem.GetComponent <ChangeType>().CastId = self.GetParent <Unit>().Id; skillItem.GetComponent <NumericComponent>().Set(NumericType.CaseBase, 14); self.target.GetComponent <AttackComponent>().TakeDamage(skillItem); self.startTime = TimeHelper.ClientNowSeconds(); } long timeNow = TimeHelper.ClientNowSeconds(); self.delTime = timeNow - self.startTime + 1; if (self.delTime > (self.attcdTime + 1)) { self.delTime = 0; } }
/// <summary> /// 合併兩筆以上的可堆疊道具紀錄 /// 出現Bug的時候才會執行 /// </summary> /// <param name="uid"></param> /// <param name="equipmentList"></param> /// <returns></returns> private static async ETTask _MergeEquipment(long uid, params Equipment[] equipmentList) { var first = equipmentList[0]; var set = new HashSet <long>(equipmentList.Length); for (int i = 1; i < equipmentList.Length; i++) { var equipmentInfo = equipmentList[i]; if (first.configId == equipmentInfo.configId) { first.count += equipmentInfo.count; set.Add(equipmentInfo.Id); } } await dbProxy.Save(first); await dbProxy.DeleteJson <Equipment>(entity => set.Contains(entity.Id)); CharacterConfig characterConfig = (CharacterConfig)configComponent.Get(typeof(CharacterConfig), first.configId); DBLog dBLog = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId()); dBLog.uid = uid; dBLog.logType = (int)DBLog.LogType.MergeEquipment; dBLog.document = new BsonDocument { { "mergedId", new BsonArray(equipmentList.Select(e => e.Id)) }, // 紀錄參與合併的道具紀錄Ids { "configType", characterConfig.Type }, { "configId", first.configId }, { "mergeCount", first.count }, // 合併後的數量 }; dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); await dbProxy.Save(dBLog); }
public static void Cast(this UnitSkillComponent self, string keycode) { RayUnitComponent ray = self.GetParent <Unit>().GetComponent <RayUnitComponent>(); AttackComponent attack = self.GetParent <Unit>().GetComponent <AttackComponent>(); self.currentKey = keycode; self.keycodeIds.TryGetValue(self.currentKey, out long skid); if (skid == 0) { skid = 41101; } Skill skill = Game.Scene.GetComponent <SkillComponent>().Get(skid); self.curSkillItem = ComponentFactory.CreateWithId <SkillItem>(skid); self.curSkillItem.UpdateLevel(10); if (ray.target != null) { attack.target = ray.target; } if (attack.target != null) { attack.target.GetComponent <AttackComponent>().TakeDamage(self.curSkillItem); } }
protected async ETVoid RunAsync(Session session, G2M_MapUnitCreate message, Action <M2G_MapUnitCreate> reply) { M2G_MapUnitCreate response = new M2G_MapUnitCreate(); try { //建立MapUnit MapUnit mapUnit = ComponentFactory.CreateWithId <MapUnit, MapUnitType>(IdGenerater.GenerateId(), MapUnitType.Hero); mapUnit.Uid = message.Uid; await mapUnit.AddComponent <MailBoxComponent>().AddLocation(); mapUnit.AddComponent <MapUnitGateComponent, long>(message.GateSessionId); Game.Scene.GetComponent <MapUnitComponent>().Add(mapUnit); mapUnit.SetInfo(message.MapUnitInfo); await mapUnit.EnterRoom(message.MapUnitInfo.RoomId); await Game.Scene.GetComponent <RoomComponent>().Update(mapUnit.Room); //回傳MapUnitId給進入者 response.MapUnitId = mapUnit.Id; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
// 发送邮件 public static async Task SendMail(long uid, string EmailTitle, string Content, string RewardItem) { try { DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); EmailInfo emailInfo = ComponentFactory.CreateWithId <EmailInfo>(IdGenerater.GenerateId()); emailInfo.UId = uid; /* * ************************************************ ************************************************** ************************************************** * 注意:按照10万人,每人只有2000条邮件的额度 * ************************************************ * ************************************************ * ************************************************* */ { long curAllCount = await proxyComponent.QueryJsonCount <EmailInfo>("{}"); emailInfo.EmailId = (int)++curAllCount; } emailInfo.EmailTitle = EmailTitle; emailInfo.Content = Content; emailInfo.RewardItem = RewardItem; await proxyComponent.Save(emailInfo); } catch (Exception e) { Log.Error("SendMail异常:" + e); } }
protected override async void Run(Session session, C2R_Register message, Action <R2C_Register> reply) { R2C_Register response = new R2C_Register(); try { //验证账号格式 if (!Regex.IsMatch(message.Account, "^[A-Za-z0-9]*$")) { response.Error = ProtocolErrorCode.ERR_IllegalCharacter; reply(response); return; } //验证密码格式 if (!Regex.IsMatch(message.Password, "^[A-Za-z0-9]*$")) { response.Error = ProtocolErrorCode.ERR_IllegalCharacter; reply(response); return; } //数据库操作对象 DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); //查询账号是否存在 var result = await dbProxy.Query <DB_Account>((p) => p.Account == message.Account); if (result.Count > 0) { response.Error = ProtocolErrorCode.ERR_AccountAlreadyRegister; reply(response); return; } //新建账号 DB_Account newAccount = ComponentFactory.CreateWithId <DB_Account>(IdGenerater.GenerateId()); newAccount.Account = message.Account; newAccount.Password = message.Password; Log.Info($"注册新账号:{MongoHelper.ToJson(newAccount)}"); //新建用户信息 DB_UserInfo newUser = ComponentFactory.CreateWithId <DB_UserInfo>(newAccount.Id); newUser.Account = $"用户{message.Account}"; newUser.RoleDataList.Add(1001); //保存到数据库 await dbProxy.Save(newAccount); await dbProxy.Save(newUser, false); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2R_Register_Req message, Action <R2C_Register_Res> reply) { R2C_Register_Res response = new R2C_Register_Res(); try { DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); List <ComponentWithId> result = await dbProxy.Query <AccountInfo>(_account => _account.Account == message.Account); if (result.Count > 0) { response.Error = ErrorCode.ERR_AccountAlreadyRegister; response.Message = "当前账号已经被注册 !!!"; reply(response); return; } AccountInfo newAccount = ComponentFactory.CreateWithId <AccountInfo>(IdGenerater.GenerateId()); newAccount.Account = message.Account; newAccount.Password = message.Password; Log.Info($"注册新账号:{MongoHelper.ToJson(newAccount)}"); ETModel.UserInfo newUser = UserInfoFactory.Create(newAccount.Id, session); if (newUser.GetComponent <MailBoxComponent>() != null) { newUser.RemoveComponent <MailBoxComponent>(); } await newUser.AddComponent <MailBoxComponent>().AddLocation(); newUser.PlayerId = RandomHelper.GenerateRandomPlayerId(6); newUser.Account = message.Account; newUser.Nickname = $"{ RandomHelper.GenerateRandomCode(4):0000}"; newUser.HeadId = RandomHelper.GetRandom().Next(1, 11); if (newUser.HeadId < 6) { newUser.Gender = 1; } else { newUser.Gender = 2; } newUser.Gold = 100000; newUser.IsTourist = false; await dbProxy.Save(newAccount); await dbProxy.Save(newUser); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
public static HotfixUnit CreateHotfixUnit(Unit unit, bool IsPlayer = false) { HotfixUnit hotfixUnit = ComponentFactory.CreateWithId <HotfixUnit, Unit>(unit.Id, unit); //Log.Info($"此英雄的热更层ID为{hotfixUnit.Id}"); Game.Scene.GetComponent <M5V5GameComponent>().AddHotfixUnit(hotfixUnit.Id, hotfixUnit); return(hotfixUnit); }
/// <summary> /// 创建玩家对象 /// </summary> /// <param name="playerId"></param> /// <param name="userId"></param> /// <returns></returns> public static Gamer Create(long playerId, long userId, long?id = null) { Gamer gamer = ComponentFactory.CreateWithId <Gamer, long>(id ?? IdGenerater.GenerateId(), userId); gamer.PlayerID = playerId; return(gamer); }
protected override async void Run(Session session, C2G_Chengjiu message, Action <G2C_Chengjiu> reply) { G2C_Chengjiu response = new G2C_Chengjiu(); try { List <TaskInfo> taskInfoList = new List <TaskInfo>(); ConfigComponent configCom = Game.Scene.GetComponent <ConfigComponent>(); DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); List <ChengjiuInfo> chengjiuInfoList = await proxyComponent.QueryJson <ChengjiuInfo>($"{{UId:{message.Uid}}}"); if (chengjiuInfoList.Count < configCom.GetAll(typeof(ChengjiuConfig)).Length) { foreach (ChengjiuConfig config in configCom.GetAll(typeof(ChengjiuConfig))) { List <ChengjiuInfo> infos = await proxyComponent.QueryJson <ChengjiuInfo> ($"{{UId:{message.Uid},TaskId:{ config.Id}}}"); if (infos.Count <= 0) { ChengjiuInfo info = ComponentFactory.CreateWithId <ChengjiuInfo>(IdGenerater.GenerateId()); info.UId = message.Uid; info.Name = config.Name; info.TaskId = (int)config.Id; info.Target = config.Target; info.Reward = config.Reward; info.Desc = config.Desc; info.CurProgress = 0; await proxyComponent.Save(info); } } } chengjiuInfoList = await proxyComponent.QueryJson <ChengjiuInfo>($"{{UId:{message.Uid}}}"); for (int i = 0; i < chengjiuInfoList.Count; ++i) { TaskInfo taskInfo = new TaskInfo(); ChengjiuInfo chengjiu = chengjiuInfoList[i]; taskInfo.Id = chengjiu.TaskId; taskInfo.TaskName = chengjiu.Name; taskInfo.Desc = chengjiu.Desc; taskInfo.Reward = chengjiu.Reward; taskInfo.IsComplete = chengjiu.IsComplete; taskInfo.IsGet = chengjiu.IsGet; taskInfo.Progress = chengjiu.CurProgress; taskInfo.Target = chengjiu.Target; taskInfoList.Add(taskInfo); } response.ChengjiuList = taskInfoList; reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
public static async ETTask <Invite> CreateInvite(this InviteComponent self, InviteData inviteData) { Invite invite = ComponentFactory.CreateWithId <Invite>(IdGenerater.GenerateId()); invite.SetData(inviteData); self._Create(invite); await self.MemorySync.Create(invite); return(invite); }
public static async ETTask <Reservation> CreateReservation(this ReservationComponent self, ReservationAllData reservationData) { Reservation reservation = ComponentFactory.CreateWithId <Reservation>(reservationData.ReservationId); reservation.SetData(reservationData); await self.MemorySync.Create(reservation); reservation.IsInitialized = true; return(reservation); }
public static async ETTask SaveLog(this DBProxyComponent self, long uid, DBLog.LogType logType, BsonDocument record) { DBLog dBLog = ComponentFactory.CreateWithId <DBLog>(IdGenerater.GenerateId()); dBLog.uid = uid; dBLog.logType = (int)logType; dBLog.document = record; dBLog.createAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); await self.SaveLog(dBLog); }
/// <summary> /// 创建玩家对象 /// </summary> /// <param name="playerId"></param> /// <param name="userId"></param> /// <returns></returns> public static async Task <Gamer> Create(long playerId, long userId, long?id = null) { Gamer gamer = ComponentFactory.CreateWithId <Gamer, long>(id ?? IdGenerater.GenerateId(), userId); gamer.PlayerID = playerId; gamer.isOffline = false; gamer.playerBaseInfo = await DBCommonUtil.getPlayerBaseInfo(userId); return(gamer); }
public static Unit CreateEmitObj(long id, UnitData unitData, string key) { UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); Unit unit = ComponentFactory.CreateWithId <Unit>(id); unit.AddComponent <UnitStateComponent>(); AddCollider(unit, unitData, true, key); unit.AddComponent <EmitObjMoveComponent>(); return(unit); }
protected override async void Run(Session session, C2G_UseZhuanPan message, Action <G2C_UseZhuanPan> reply) { G2C_UseZhuanPan response = new G2C_UseZhuanPan(); try { DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); PlayerBaseInfo playerBaseInfo = await DBCommonUtil.getPlayerBaseInfo(message.Uid); if (playerBaseInfo.ZhuanPanCount <= 0) { response.Error = ErrorCode.TodayHasSign; response.Message = "您的抽奖次数不足"; reply(response); return; } else { playerBaseInfo.ZhuanPanCount -= 1; playerBaseInfo.LuckyValue += 1; response.itemId = getRewardItemId(playerBaseInfo.LuckyValue); response.reward = getReward(response.itemId, playerBaseInfo.LuckyValue); // 满99后重置 if (playerBaseInfo.LuckyValue >= 99) { playerBaseInfo.LuckyValue = 0; } await proxyComponent.Save(playerBaseInfo); reply(response); { await DBCommonUtil.changeWealthWithStr(message.Uid, response.reward, "转盘奖励"); // 转盘日志 { Log_UseZhuanPan log_UseZhuanPan = ComponentFactory.CreateWithId <Log_UseZhuanPan>(IdGenerater.GenerateId()); log_UseZhuanPan.Uid = message.Uid; log_UseZhuanPan.Reward = response.reward; await proxyComponent.Save(log_UseZhuanPan); } } } } catch (Exception e) { Log.Debug(e.ToString()); ReplyError(response, e, reply); } }
/// <summary> /// 发货接口 /// </summary> /// <param name="orderId"></param> /// <param name="userId"></param> /// <param name="goodsId"></param> /// <param name="goodsNum"></param> /// <param name="price"></param> public static async Task UserRecharge(int orderId, long userId, int goodsId, int goodsNum, float price) { try { string reward = ""; DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); ShopConfig config = ConfigHelp.Get <ShopConfig>(goodsId); List <Log_Recharge> log_Recharge = await proxyComponent.QueryJson <Log_Recharge>($"{{Uid:{userId}}}"); if (log_Recharge.Count == 0) { reward = "1:120000;105:20;104:1;107:1"; await DBCommonUtil.changeWealthWithStr(userId, reward, "首充奖励"); } reward = config.Items; await DBCommonUtil.changeWealthWithStr(userId, reward, "购买元宝"); //向gate服务器发送请求 StartConfigComponent startConfig = Game.Scene.GetComponent <StartConfigComponent>(); IPEndPoint gateIPEndPoint = startConfig.GateConfigs[0].GetComponent <InnerConfig>().IPEndPoint; Session gateSession = Game.Scene.GetComponent <NetInnerComponent>().Get(gateIPEndPoint); G2H_GamerCharge g2HGamerCharge = (G2H_GamerCharge)await gateSession.Call(new H2G_GamerCharge() { goodsId = goodsId, UId = userId }); // UserComponent userComponent = Game.Scene.GetComponent<UserComponent>(); // User user = userComponent.Get(userId); // //给玩家发送消息 // user?.session?.Send(new Actor_GamerBuyYuanBao() // { // goodsId = goodsId // }); // 记录日志 { Log_Recharge log_recharge = ComponentFactory.CreateWithId <Log_Recharge>(IdGenerater.GenerateId()); log_recharge.Uid = userId; log_recharge.GoodsId = config.Id; log_recharge.Price = config.Price; log_recharge.OrderId = orderId; await proxyComponent.Save(log_recharge); } } catch (Exception e) { Log.Error(e); } }
public static Unit Create(long id, int typeId, UnitData unitData) { UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); Unit unit = ComponentFactory.CreateWithId <Unit>(id); UnitConfig unitConfig = Game.Scene.GetComponent <ConfigComponent>().Get(typeof(UnitConfig), typeId) as UnitConfig; unit.AddComponent <NumericComponent, int>(typeId); unit.AddComponent <UnitStateComponent>(); unit.AddComponent <UnitPathComponent>(); unit.AddComponent <BuffMgrComponent>(); var activeSkillCom = unit.AddComponent <ActiveSkillComponent>(); var passiveSkillCom = unit.AddComponent <PassiveSkillComponent>(); unit.AddComponent <SkillEffectComponent>(); //添加碰撞体 AddCollider(unit, unitData, true, unitConfig.AssetName); unit.AddComponent <CharacterStateComponent>(); unit.AddComponent <CharacterMoveComponent>(); unit.AddComponent <CalNumericComponent>(); if (unitConfig.Skills != null && unitConfig.Skills.Length > 0) { SkillConfigComponent skillConfigComponent = Game.Scene.GetComponent <SkillConfigComponent>(); foreach (var v in unitConfig.Skills) { if (string.IsNullOrEmpty(v)) { continue; } var activeSkill = skillConfigComponent.GetActiveSkill(v); if (activeSkill != null) { Log.Debug(string.Format("{0} 添加主动技能 {1} ({2})成功!", typeId, v, activeSkill.skillName)); activeSkillCom.AddSkill(v); continue; } var passiveSkill = skillConfigComponent.GetPassiveSkill(v); if (passiveSkill != null) { Log.Debug(string.Format("{0} 添加被动技能 {1} ({2})成功!", typeId, v, passiveSkill.skillName)); passiveSkillCom.AddSkill(v); continue; } Log.Error(v + " 这样的技能不存在!"); } } //unit.AddComponent<TurnComponent>(); unitComponent.Add(unit); return(unit); }
public static Userdb ToUserdb(this User self) { Userdb userdb = ComponentFactory.CreateWithId <Userdb>(self.Id); userdb.account = self.Account; userdb.password = self.Password; userdb.phonenumber = self.phonenumber; userdb.playerids = self.playerids; userdb.createdate = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); return(userdb); }
public static User ToUser(this Userdb self) { User user = ComponentFactory.CreateWithId <User>(self.Id); user.Account = self.account; user.Password = self.password; user.phonenumber = self.phonenumber; user.playerids = self.playerids; user.createdate = self.createdate; return(user); }