private void TickPreloading() { long curTime = TimeUtility.GetServerMilliseconds(); if (m_LastPreloadingTickTime + c_PreloadingTickInterval < curTime) { m_LastPreloadingTickTime = curTime; bool canStart = true; foreach (User us in m_Room.RoomUsers) { if (!us.IsEntered && !us.IsTimeout()) { canStart = false; } } if (canStart) { LoadObjects(); CalculateDropOut(); m_StorySystem.StartStory(1); for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next) { UserInfo user = linkNode.Value; UserAttrCalculator.Calc(user); user.LevelChanged = false; user.SetHp(Operate_Type.OT_Absolute, user.GetActualProperty().HpMax); user.SetEnergy(Operate_Type.OT_Absolute, user.GetActualProperty().EnergyMax); } //先让各客户端创建自己与场景相关信息 foreach (User us in m_Room.RoomUsers) { if (us.IsEntered) { SyncUserToSelf(us); SyncSceneObjectsToUser(us); } } //再通知其他客户端看见自己 foreach (User us in m_Room.RoomUsers) { if (us.IsEntered) { SyncUserToOthers(us); } } //给观察者发初始玩家与场景对象信息 foreach (Observer observer in m_Room.RoomObservers) { if (null != observer && !observer.IsIdle && observer.IsEntered) { SyncForNewObserver(observer); } } } } }
internal void OnUserRevive(Msg_LR_UserReLive msg) { User user = m_Room.GetUserByGuid(msg.UserGuid); if (null != user) { UserInfo info = user.Info; info.SetHp(Operate_Type.OT_Absolute, info.GetActualProperty().HpMax); info.SetEnergy(Operate_Type.OT_Absolute, info.GetActualProperty().EnergyMax); info.DeadTime = 0; DataSyncUtility.SyncUserPropertyToCaredUsers(info); DataSyncUtility.SyncUserReliveToCaredUsers(info); } }
private void TickRecover() { float hp_coefficient = 1.0f; float mp_coefficient = 1.0f; Data_SceneConfig scene_data = SceneConfigProvider.Instance.GetSceneConfigById(m_SceneResId); if (null != scene_data) { hp_coefficient = scene_data.m_RecoverHpCoefficient; mp_coefficient = scene_data.m_RecoverMpCoefficient; } for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next) { UserInfo info = linkNode.Value; if (!info.IsDead()) { float hpRecover = info.GetActualProperty().HpRecover *hp_coefficient; float epRecover = info.GetActualProperty().EnergyRecover *mp_coefficient; if (hpRecover > 0.0001) { if (info.Hp + (int)hpRecover >= info.GetActualProperty().HpMax) { info.SetHp(Operate_Type.OT_Absolute, (int)info.GetActualProperty().HpMax); } else { info.SetHp(Operate_Type.OT_Relative, (int)hpRecover); } } if (epRecover > 0.0001) { if (info.Energy + (int)epRecover >= info.GetActualProperty().EnergyMax) { info.SetEnergy(Operate_Type.OT_Absolute, (int)info.GetActualProperty().EnergyMax); } else { info.SetEnergy(Operate_Type.OT_Relative, (int)epRecover); } } if (hpRecover > 0.0001 || epRecover > 0.0001) { Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info); NotifyAreaUser(info, builder, false); } } } for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next) { NpcInfo info = linkNode.Value; if (!info.IsDead()) { float hpRecover = info.GetActualProperty().HpRecover; float npRecover = info.GetActualProperty().EnergyRecover; if (hpRecover > 0.0001) { if (info.Hp + (int)hpRecover >= info.GetActualProperty().HpMax) { info.SetHp(Operate_Type.OT_Absolute, (int)info.GetActualProperty().HpMax); } else { info.SetHp(Operate_Type.OT_Relative, (int)hpRecover); } } if (npRecover > 0.0001) { if (info.Energy + (int)npRecover >= info.GetActualProperty().EnergyMax) { info.SetEnergy(Operate_Type.OT_Absolute, (int)info.GetActualProperty().EnergyMax); } else { info.SetEnergy(Operate_Type.OT_Relative, (int)npRecover); } } if (hpRecover > 0.0001 || npRecover > 0.0001) { Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info); NotifyAreaUser(info, builder, false); } } } }