public static void AdjustUserPosition(int id, float x, float y, float z, float time, float dir) { CharacterInfo info = WorldSystem.Instance.GetCharacterById(id); if (null != info) { MovementStateInfo msi = info.GetMovementStateInfo(); if (time < 1000) { Vector3 pos = msi.GetPosition3D(); float speed = info.GetActualProperty().MoveSpeed; float distance = (speed * time) / 1000; float len = pos.Length(); float nz = (float)(z + distance * Math.Cos(dir)); float nx = (float)(x + distance * Math.Sin(dir)); int ctrlId = ControllerIdCalculator.Calc(ControllerType.Position, id); PositionController ctrl = ControlSystem.Instance.PositionControllerPool.Alloc(); if (null != ctrl) { ctrl.Init(ctrlId, id, nx - pos.X, 0, nz - pos.Z, 1000); ControlSystem.Instance.AddController(ctrl); } LogSystem.Debug("PositionController start, dx:{0} dz:{1} time:{2}", nx - pos.X, nz - pos.Z, 500); } else { msi.SetPosition2D(x, z); LogSystem.Debug("PositionController just move to pos, x:{0} z:{1}", x, z); } } }
public static byte [] ReadFileAsArray(string filePath) { byte[] buffer = null; try { //Note:客户端使用引擎接口读取, by lixiaojiang if (GlobalVariables.Instance.IsClient) { if (handlerReadFile != null) { buffer = handlerReadFile(filePath); } else { LogSystem.Debug("ReadFileByEngine handler have not register: {0}", filePath); } } else { using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { buffer = new byte[fs.Length]; fs.Read(buffer, 0, (int)fs.Length); fs.Close(); } } } catch (Exception e) { LogSystem.Debug("Exception:{0}\n", e.Message); Helper.LogCallStack(); return(null); } return(buffer); }
private void OnImpactSkill(CharacterInfo sender, int skillId) { Scene scene = sender.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = sender.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || !skillInfo.IsSkillActivated) { scene.SkillSystem.StartSkill(sender.GetId(), skillId); Msg_RC_NpcSkill skillBuilder = new Msg_RC_NpcSkill(); skillBuilder.npc_id = sender.GetId(); skillBuilder.skill_id = skillId; ArkCrossEngineMessage.Position posBuilder1 = new ArkCrossEngineMessage.Position(); posBuilder1.x = sender.GetMovementStateInfo().GetPosition3D().X; posBuilder1.z = sender.GetMovementStateInfo().GetPosition3D().Z; skillBuilder.stand_pos = posBuilder1; skillBuilder.face_direction = (float)sender.GetMovementStateInfo().GetFaceDir(); LogSystem.Debug("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}", sender.GetId(), skillId); scene.NotifyAreaUser(sender, skillBuilder); } } }
/** * @brief 将字符串解析为int数组 * * @param vec 字符串,类似于"1,2,3,4" * * @return */ public static List <T> ConvertNumericList <T>(string vec) { List <T> list = new List <T>(); string strPos = vec; string[] resut = strPos.Split(s_ListSplitString, StringSplitOptions.None); try { if (resut != null && resut.Length > 0 && resut[0] != "") { for (int index = 0; index < resut.Length; index++) { list.Add((T)Convert.ChangeType(resut[index], typeof(T))); } } } catch (System.Exception ex) { string info = string.Format("ConvertNumericList vec:{0} ex:{1} stacktrace:{2}", vec, ex.Message, ex.StackTrace); LogSystem.Debug(info); list.Clear(); } return(list); }
public static IMessage Decode(byte[] msgbuf) { int id = (int)(((int)msgbuf[0] << 8) | ((int)msgbuf[1])); if (id < 0) { LogSystem.Debug("decode error:message id({0}) error !!!", id); return(null); } IMessage msg = Serialize.CreateMessage(id); if (msg == null) { LogSystem.Debug("decode error:can't find id {0} !!!", id); return(null); } byte[] rmsg = new byte[msgbuf.Length - 2]; Buffer.BlockCopy(msgbuf, 2, rmsg, 0, msgbuf.Length - 2); object[] param2 = new object[] { rmsg }; Type[] param = new Type[] { rmsg.GetType() }; MethodInfo method = msg.GetType().GetMethod("ParseFrom", param); if (method == null) { LogSystem.Debug("decode error:can't find ParseFrom!"); return(null); } return((IMessage)method.Invoke(msg, param2)); }
private void TickUsers() { for (LinkedListNode <UserInfo> linkNode = m_UserMgr.Users.FirstValue; null != linkNode; linkNode = linkNode.Next) { UserInfo info = linkNode.Value; if (info.LevelChanged || info.GetShootStateInfo().WeaponChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged) { LogSystem.Debug("UserAttrCalculate LevelChanged:{0} WeaponChanged:{1} BuffChanged:{2} EquipmentChanged:{3}", info.LevelChanged, info.GetShootStateInfo().WeaponChanged, info.GetSkillStateInfo().BuffChanged, info.GetEquipmentStateInfo().EquipmentChanged); UserAttrCalculator.Calc(info); info.LevelChanged = false; info.GetShootStateInfo().WeaponChanged = false; info.GetSkillStateInfo().BuffChanged = false; info.GetEquipmentStateInfo().EquipmentChanged = false; } } UserInfo player = WorldSystem.Instance.GetPlayerSelf(); if (null != player && player.Hp <= 0) { if (player.DeadTime <= 0) { GfxSystem.PublishGfxEvent("ge_show_relive", "ui", null); player.DeadTime = TimeUtility.GetServerMilliseconds(); } } }
private static bool CanGo(CharacterInfo obj, float x, float y, float dir, float forecastDistance, bool logging) { float cosV = (float)Math.Cos(dir); float sinV = (float)Math.Sin(dir); float tryY = (float)(y + forecastDistance * cosV); float tryX = (float)(x + forecastDistance * sinV); Vector3 spos = obj.GetMovementStateInfo().GetPosition3D(); Vector3 dpos = new Vector3(tryX, 0, tryY); bool ret = obj.SpatialSystem.CanPass(spos, dpos); if (logging) { int srow, scol, drow, dcol; obj.SpatialSystem.GetCellMapView(1).GetCell(spos, out srow, out scol); obj.SpatialSystem.GetCellMapView(1).GetCell(dpos, out drow, out dcol); if (ret) { LogSystem.Debug("MoveController CanGo return true, ({0},{1})->({2},{3}), dir:{4}", srow, scol, drow, dcol, dir); } else { LogSystem.Debug("MoveController CanGo return false, ({0},{1})->({2},{3}), dir:{4}", srow, scol, drow, dcol, dir); } } return(ret); }
public bool GetCharacterPosition(int entityId, out ScriptRuntime.Vector3 pos) { pos = ScriptRuntime.Vector3.Zero; if (m_UserMgr.Users.Contains(entityId)) { if (null != m_SpatialSystem) { CharacterInfo info = m_UserMgr.Users[entityId]; if (null != info) { pos = info.SpaceObject.GetPosition(); return(true); } } } if (m_NpcMgr.Npcs.Contains(entityId)) { if (null != m_SpatialSystem) { CharacterInfo info = m_NpcMgr.Npcs[entityId]; if (null != info) { pos = info.SpaceObject.GetPosition(); return(true); } } } LogSystem.Debug("GetCharacterPosition return false, id:{0}", entityId); return(false); }
public static Assembly GetAssembly(string assemblyPath, string assemblyName, string className) { Assembly assembly = null; if (Helper.StringIsNullOrEmpty(assemblyPath)) { if (Helper.StringIsNullOrEmpty(assemblyName)) { assembly = Assembly.GetExecutingAssembly(); } else { assembly = Assembly.Load(assemblyName); } } else { assembly = Assembly.LoadFile(string.Format("[0][1].dll", assemblyPath, assemblyName)); } if (assembly == null) { LogSystem.Debug("Warn: KernelUtil.LoadClassByName Assembly load failed!"); } return(assembly); }
private void OnUserSkill(UserInfo user, int skillId) { Scene scene = user.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = user.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || !skillInfo.IsSkillActivated) { scene.SkillSystem.StartSkill(user.GetId(), skillId); Msg_CRC_Skill skillBuilder = new Msg_CRC_Skill(); skillBuilder.role_id = user.GetId(); skillBuilder.skill_id = skillId; ArkCrossEngineMessage.Position posBuilder1 = new ArkCrossEngineMessage.Position(); posBuilder1.x = user.GetMovementStateInfo().GetPosition3D().X; posBuilder1.z = user.GetMovementStateInfo().GetPosition3D().Z; skillBuilder.stand_pos = posBuilder1; skillBuilder.face_direction = (float)user.GetMovementStateInfo().GetFaceDir(); skillBuilder.want_face_dir = (float)user.GetMovementStateInfo().GetFaceDir(); LogSystem.Debug("Send Msg_CRC_Skill, EntityId={0}, SkillId={1}", user.GetId(), skillId); scene.NotifyAreaUser(user, skillBuilder, false); } } }
public void UpdateWeaponModel(CharacterInfo entity) { if (null == entity) { return; } if (null == entity.GetShootStateInfo().GetAllWeapon()) { //LogSystem.Debug("--weapon: no weapon!"); return; } if (0 != m_GunActor) { GfxSystem.DetachGameObject(m_GunActor); GfxSystem.DestroyGameObject(m_GunActor); } List <WeaponInfo> weapons = entity.GetShootStateInfo().GetAllWeapon(); if (null == weapons || weapons.Count == 0) { //LogSystem.Debug("---weapon attach: no weapon!"); return; } foreach (WeaponInfo weapon in weapons) { string weaponResName = weapon.ResourceName; string[] wrn_peer = weaponResName.Split(new string[] { "|", "," }, StringSplitOptions.None); if (wrn_peer.Length < 2) { continue; } string wrnResName = wrn_peer[0]; string wrnSkeleton = wrn_peer[1]; bool ret = false; for (int j = 0; j < CurWeaponList.Count; ++j) { if (CurWeaponList[j].Equals(wrnResName)) { ret = true; } } if (ret) { //LogSystem.Debug("---weapon change: weapon is same"); return; } GetCurActionConfig(); CurWeaponList.Add(wrnResName); m_GunActor = GameObjectIdManager.Instance.GenNextId(); GfxSystem.CreateGameObjectForAttach(m_GunActor, wrnResName); GfxSystem.AttachGameObject(m_GunActor, m_Actor, wrnSkeleton); GfxSystem.SetGameObjectVisible(m_GunActor, true); LogSystem.Debug("User {0} Weapon {1} Res {2} Bind {3}", m_Actor, m_GunActor, wrnResName, wrnSkeleton); } }
private void LoadObjects() { m_SceneState = SceneState.Running; LogSys.Log(LOG_TYPE.DEBUG, "Scene {0} start Running.", m_SceneResId); // TODO: m_GameStartTime should be set when game of this scene // is really started m_GameTime.Start(); m_SceneContext.StartTime = m_GameTime.StartTime; Room room = GetRoom(); if (null != room && null != m_MapData) { MyDictionary <int, object> units = m_MapData.m_UnitMgr.GetData(); foreach (Data_Unit unit in units.Values) { if (null != unit && unit.m_IsEnable) { NpcInfo npc = m_NpcMgr.AddNpc(unit); if (null != npc) { if (room.RoomUsers.Count() > 0) { npc.OwnerId = room.RoomUsers[0].RoleId; LogSystem.Debug("User {0} is responsible for npc {1}", npc.OwnerId, npc.GetId()); } else { LogSystem.Warn("No User is responsible for npc"); } } } } MyDictionary <int, object> slogics = m_MapData.m_SceneLogicMgr.GetData(); foreach (SceneLogicConfig sc in slogics.Values) { if (null != sc && sc.m_IsServer) { m_SceneLogicInfoMgr.AddSceneLogicInfo(sc.GetId(), sc); } } foreach (User us in room.RoomUsers) { UserInfo info = us.Info; Data_Unit unit = m_MapData.ExtractData(DataMap_Type.DT_Unit, info.GetUnitId()) as Data_Unit; if (null != unit) { info.GetMovementStateInfo().SetPosition(unit.m_Pos); info.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle); info.RevivePoint = unit.m_Pos; } } } }
//************************************************************************ // Note:此函数只供客户端使用, by lixiaojiang //************************************************************************ public static void RegisterReadFileHandler(delegate_ReadFile handler) { if (GlobalVariables.Instance.IsClient) { // Note:Client确保只拥有唯一的读取函数,即ScriptRuntime.Util.ReadFile(...), by lixiaojiang handlerReadFile = handler; } else { LogSystem.Debug("[Err] RegisterReadFileHandler only for Client."); } }
private void TickBlindage(CharacterInfo obj) { if (obj.BlindageLeftTime > 1000) { obj.BlindageLeftTime -= 1000; } else { obj.BlindageLeftTime = 0; obj.Blindage = null; obj.BlindageId = 0; LogSystem.Debug("obj {0} leave blindage", obj.GetId()); } }
/** * @brief 载入文件 * * @param path * * @return */ public bool Load(string path) { bool ret = false; if (path == "" || !FileReaderProxy.Exists(path)) { return(ret); } Stream ms = null; StreamReader sr = null; try { ms = FileReaderProxy.ReadFileAsMemoryStream(path); if (ms == null) { LogSystem.Debug("DBC, Warning, Load file error or file is empty: {0}", path); return(false); } m_FileName = path; ms.Seek(0, SeekOrigin.Begin); m_FileSize = ms.Length; if (m_FileSize <= 0 || m_FileSize >= int.MaxValue) { return(ret); } System.Text.Encoding encoding = System.Text.Encoding.UTF8; sr = new StreamReader(ms, encoding); ret = LoadFromStream(sr); ret = true; } catch (Exception e) { string err = "Exception:" + e.Message + "\n" + e.StackTrace + "\n"; System.Diagnostics.Debug.WriteLine(err); } finally { if (sr != null) { sr.Close(); } if (ms != null) { ms.Close(); } } return(ret); }
private void DoMove() { UserInfo myself = WorldSystem.Instance.GetPlayerSelf(); if (null != myself) { float moveDir = myself.GetMovementStateInfo().GetMoveDir(); myself.GetMovementStateInfo().IsMoveMeetObstacle = false; float newDir = CalcDir(moveDir, m_DirOffset); myself.GetMovementStateInfo().SetMoveDir(newDir); NetworkSystem.Instance.SyncPlayerMoveStart((float)newDir); LogSystem.Debug("MoveController adjust MoveDir:{0}+{1}", moveDir, m_DirOffset); } }
/** * @brief * dump all data */ public void Dump() { LogSystem.Debug("Id={0}", SkillId); LogSystem.Debug("Icon={0}", SkillIcon); LogSystem.Debug("Name={0}", SkillDescription); LogSystem.Debug("Level={0}", SkillLevel); LogSystem.Debug("Passivity={0}", SkillPassivity); LogSystem.Debug("TargetType={0}", TargetType); LogSystem.Debug("TargetSelectType={0}", TargetSelectType); LogSystem.Debug("Cooldown={0}", CoolDownTime); LogSystem.Debug("CostHp={0}", CostHp); LogSystem.Debug("CostEnergy={0}", CostEnergy); LogSystem.Debug("CostEnergyCore={0}", CostEnergyCore); LogSystem.Debug("CostItemId={0}", CostItemId); }
public override void Adjust() { long curTime = TimeUtility.GetServerMilliseconds(); if (m_LastAdjustTime + 100 < curTime) { m_LastAdjustTime = curTime; UserInfo myself = WorldSystem.Instance.GetPlayerSelf(); if (null != myself) { float moveDir = myself.GetMovementStateInfo().GetMoveDir(); Vector2 pos = myself.GetMovementStateInfo().GetPosition2D(); if (!myself.GetMovementStateInfo().IsMoving)//玩家已经停止移动,控制停止 { m_IsTerminated = true; NetworkSystem.Instance.SyncPlayerMoveStop(); LogSystem.Debug("MoveController finish because stop move, adjust MoveDir:{0}", moveDir); } else if (!Geometry.IsSameDouble(WorldSystem.Instance.InputMoveDir, m_InputDir))//玩家输入的移动方向改变,控制停止 { m_IsTerminated = true; LogSystem.Debug("MoveController finish because change move dir, adjust MoveDir:{0}", moveDir); } else if (CanGo(myself, pos.X, pos.Y, m_InputDir, c_ForecastDistance * 3, false))//如果输入移动方向可以行走,则恢复移动方向,并停止控制 { m_DirOffset = 0; myself.GetMovementStateInfo().SetMoveDir(m_InputDir); DoMove(); m_IsTerminated = true; LogSystem.Debug("MoveController finish because restore move dir, adjust MoveDir:{0}", moveDir); } } else { m_IsTerminated = true; LogSystem.Debug("MoveController finish because can't find player"); } if (m_IsTerminated) { WorldSystem.Instance.MoveDirAdjustCount = 0; } } }
public static MemoryStream ReadFileAsMemoryStream(string filePath) { try { byte[] buffer = ReadFileAsArray(filePath); if (buffer == null) { LogSystem.Debug("Err ReadFileAsMemoryStream failed:{0}\n", filePath); return(null); } return(new MemoryStream(buffer)); } catch (Exception e) { LogSystem.Debug("Exception:{0}\n", e.Message); Helper.LogCallStack(); return(null); } }
public void StartGame() { UserInfo user = GetPlayerSelf(); if (null != user) { EntityManager.Instance.DestroyUserView(user.GetId()); DestroyCharacterById(user.GetId()); } user = CreatePlayerSelf(1, NetworkSystem.Instance.HeroId); user.SetCampId(NetworkSystem.Instance.CampId); Data_Unit unit = m_CurScene.StaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(NetworkSystem.Instance.CampId)) as Data_Unit; if (null != unit) { user.GetMovementStateInfo().SetPosition(unit.m_Pos); user.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle); user.SetHp(Operate_Type.OT_Absolute, user.GetActualProperty().HpMax); } EntityManager.Instance.CreatePlayerSelfView(1); UserView view = EntityManager.Instance.GetUserViewById(1); if (null != view) { view.Visible = true; } foreach (Data_Unit npcUnit in m_CurScene.StaticData.m_UnitMgr.GetData().Values) { if (npcUnit.m_IsEnable) { NpcInfo npc = m_NpcMgr.GetNpcInfoByUnitId(npcUnit.GetId()); if (null == npc) { npc = m_NpcMgr.AddNpc(npcUnit); } if (null != npc) { EntityManager.Instance.CreateNpcView(npc.GetId()); } } } GfxSystem.PublishGfxEvent("ge_on_game_start", "story"); LogSystem.Debug("start game"); }
public override void Adjust() { CharacterInfo info = m_SceneContext.GetCharacterInfoById(m_ObjId); if (null != info) { float curTime = TimeUtility.GetLocalMilliseconds(); float delta = curTime - m_LastTime; m_LastTime = curTime; m_CurTotalTime += delta; float moveDir = info.GetMovementStateInfo().GetMoveDir(); if (m_CurTotalTime >= m_TotalTime || Math.Abs(moveDir - m_MoveDir) <= 0.1f) { info.GetMovementStateInfo().SetMoveDir(m_MoveDir); LogSystem.Debug("MoveDir adjust {0}", m_MoveDir); m_IsTerminated = true; } else { float offset = c_PI - (m_MoveDir + c_2PI - moveDir) % c_2PI; if (offset * m_DeltaDir <= 0) { info.GetMovementStateInfo().SetMoveDir(m_MoveDir); LogSystem.Debug("MoveDir adjust {0}", m_MoveDir); m_IsTerminated = true; } else { float newMoveDir = (moveDir + c_2PI + delta * m_DeltaDir / m_TotalTime) % c_2PI; info.GetMovementStateInfo().SetMoveDir(newMoveDir); LogSystem.Debug("MoveDirController {0}, obj:{1}, moveDir:{2}->{3}, delta:{4} totalTime:{5} deltaDir:{6} targetDir:{7}", m_Id, m_ObjId, moveDir, newMoveDir, delta, m_TotalTime, m_DeltaDir, m_MoveDir); } } } else { m_IsTerminated = true; } }
/** * @brief 从Xml节点中读取数值类型,使用时,必须在函数中指明数值类型 * 如: int id = ExtractNumeric<int>(xmlNode, "Id", -1, true); * * @param node xml节点 * @param nodeName 节点名字 * @param defualtVal 默认值 * @param isMust 是否强制不能为空 * * @return */ public static T ExtractNumeric <T>(XmlNode node, string nodeName, T defualtVal, bool isMust) { T result = defualtVal; if (node == null || !node.HasChildNodes || node.SelectSingleNode(nodeName) == null) { if (isMust) { string errorInfo = string.Format("ExtractNumeric Error node:{0} nodeName:{1}", node.Name, nodeName); LogSystem.Assert(false, errorInfo); } return(result); } XmlNode childNode = node.SelectSingleNode(nodeName); string nodeText = childNode.InnerText; if (Helper.StringIsNullOrEmpty(nodeText)) { if (isMust) { string errorInfo = string.Format("ExtractNumeric Error node:{0} nodeName:{1}", node.Name, nodeName); LogSystem.Assert(false, errorInfo); } } else { try { result = (T)Convert.ChangeType(nodeText, typeof(T)); } catch (System.Exception ex) { string info = string.Format("ExtractNumeric Error node:{0} nodeName:{1} ex:{2} stacktrace:{3}", node.Name, nodeName, ex.Message, ex.StackTrace); LogSystem.Debug(info); } } return(result); }
/** * @brief 从Xml节点中读取数值类型,使用时,必须在函数中指明数值类型 * 如: int id = ExtractNumeric<int>(xmlNode, "Id", -1, true); * * @param node xml节点 * @param nodeName 节点名字 * @param defualtVal 默认值 * @param isMust 是否强制不能为空 * * @return */ public static T ExtractNumeric <T>(DBC_Row node, string nodeName, T defualtVal, bool isMust) { T result = defualtVal; if (node == null || !node.HasFields || node.SelectFieldByName(nodeName) == null) { if (isMust) { string errorInfo = string.Format("ExtractNumeric Error node:{0} nodeName:{1}", node.RowIndex, nodeName); LogSystem.Assert(false, errorInfo); } return(result); } string nodeText = node.SelectFieldByName(nodeName); if (Helper.StringIsNullOrEmpty(nodeText)) { if (isMust) { string errorInfo = string.Format("ExtractNumeric Error node:{0} nodeName:{1}", node.RowIndex, nodeName); LogSystem.Assert(false, errorInfo); } } else { try { result = (T)Convert.ChangeType(nodeText, typeof(T)); } catch (System.Exception ex) { string info = string.Format("ExtractNumeric Error node:{0} nodeName:{1} ex:{2} stacktrace:{3}", node.RowIndex, nodeName, ex.Message, ex.StackTrace); LogSystem.Debug(info); Helper.LogCallStack(); } } return(result); }
private void OnNpcStopSkill(NpcInfo npc) { Scene scene = npc.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = npc.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || skillInfo.IsSkillActivated) { scene.SkillSystem.StopSkill(npc.GetId()); } Msg_CRC_NpcStopSkill skillBuilder = new Msg_CRC_NpcStopSkill(); skillBuilder.npc_id = npc.GetId(); LogSystem.Debug("Send Msg_RC_NpcStopSkill, EntityId={0}", npc.GetId()); scene.NotifyAreaUser(npc, skillBuilder); } }
private void CreateNpcByStory(int unitIdFrom, int unitIdTo) { LogSystem.Debug("start = {0}, to = {1}", unitIdFrom, unitIdTo); for (int i = unitIdFrom; i <= unitIdTo; i++) { Data_Unit mapUnit = GetCurScene().StaticData.ExtractData(DataMap_Type.DT_Unit, i) as Data_Unit; if (null == mapUnit) { LogSystem.Debug("i = {0}", i); } if (null != mapUnit) { NpcInfo npc = m_NpcMgr.AddNpc(mapUnit); if (null != npc) { EntityManager.Instance.CreateNpcView(npc.GetId()); } } } }
private void OnUserStopSkill(UserInfo user) { Scene scene = user.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = user.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || skillInfo.IsSkillActivated) { scene.SkillSystem.StopSkill(user.GetId()); } Msg_CRC_StopSkill skillBuilder = new Msg_CRC_StopSkill(); skillBuilder.role_id = user.GetId(); LogSystem.Debug("Send Msg_CRC_StopSkill, EntityId={0}", user.GetId()); scene.NotifyAreaUser(user, skillBuilder, false); } }
public static void AdjustUserMove() { UserInfo myself = WorldSystem.Instance.GetPlayerSelf(); if (null != myself) { float dir; if (MoveController.CanControl(myself, out dir)) { int ctrlId = ControllerIdCalculator.Calc(ControllerType.Move, 0); bool canAdjust = true; if (ControlSystem.Instance.ExistController(ctrlId)) { ++WorldSystem.Instance.MoveDirAdjustCount; if (WorldSystem.Instance.MoveDirAdjustCount > 8)//最多可重复调节8次 { canAdjust = false; } } if (canAdjust) { MoveController ctrl = ControlSystem.Instance.MoveControllerPool.Alloc(); if (null != ctrl) { ctrl.Init(ctrlId, WorldSystem.Instance.InputMoveDir, dir); ControlSystem.Instance.AddController(ctrl); } LogSystem.Debug("MoveController start, offset dir:{0}", dir); } else { LogSystem.Debug("MoveController cancel because aleady a controller exist"); } } else { LogSystem.Debug("MoveController can't control, no suitable dir"); } } }
public void Tick() { try { foreach (IController ctrl in m_Controllers.Values) { ctrl.Adjust(); if (ctrl.IsTerminated) { m_WaitDeletedControllers.Add(ctrl); } } foreach (IController ctrl in m_WaitDeletedControllers) { m_Controllers.Remove(ctrl.Id); ctrl.Recycle(); } m_WaitDeletedControllers.Clear(); } catch (Exception ex) { LogSystem.Debug("ControlSystem Exception:%s\n%s", ex.Message, ex.StackTrace); } }
/** * @brief * dump all data */ public void Dump() { LogSystem.Debug("ActionId={0}", ActionId); LogSystem.Debug("ActionLogicId={0}", ActionLogicId); LogSystem.Debug("BreakLevel={0}", BreakLevel); LogSystem.Debug("CallbackPoint={0}", CallbackPoint); LogSystem.Debug("SectionNum={0}", SectionNumber); for (int i = 0; i < SectionNumber; i++) { LogSystem.Debug("Section No.{0}:", i + 1); LogSystem.Debug("---ActionType={0}", SectionList [i].ActionType); LogSystem.Debug("---PlaySpeed={0}", SectionList [i].PlaySpeed); LogSystem.Debug("---PlayTime={0}", SectionList [i].PlayTime); LogSystem.Debug("---MoveSpeed={0}", SectionList [i].MoveSpeed); LogSystem.Debug("---MoveTowards={0}", SectionList [i].MoveTowards); LogSystem.Debug("---AccelerateY={0}", SectionList [i].AccelerateY); } for (int i = 0; i < ParamNum; i++) { LogSystem.Debug("ExtraParam{0}={1}", i, ExtraParams [i]); } }
private void OnLoadFinish() { if (WorldSystem.Instance.IsObserver) { UserInfo myself = WorldSystem.Instance.CreatePlayerSelf(0x0ffffffe, 1); if (null != myself)//观战客户端创建一个虚拟玩家(不关联view,血量不要为0,主要目的是为了适应客户端代码里对主角的判断) { myself.SetLevel(16); myself.SetHp(Operate_Type.OT_Absolute, 999999); } NotifyUserEnter(); } if (WorldSystem.Instance.IsObserver) { DashFireMessage.Msg_CR_Observer build = new DashFireMessage.Msg_CR_Observer(); NetworkSystem.Instance.SendMessage(build); LogSystem.Debug("send Msg_CR_Observer to roomserver"); } else if (WorldSystem.Instance.IsPveScene()) { //单机游戏逻辑启动 WorldSystem.Instance.StartGame(); NotifyUserEnter(); } else { DashFireMessage.Msg_CRC_Create build = new DashFireMessage.Msg_CRC_Create(); NetworkSystem.Instance.SendMessage(build); LogSystem.Debug("send Msg_CRC_Create to roomserver"); } GfxSystem.GfxLog("SceneResource.OnLoadFinish"); m_IsWaitSceneLoad = false; GfxSystem.PublishGfxEvent("ge_loading_finish", "ui"); }