static public int constructor(IntPtr l) { try { GameFramework.LogSystem o; o = new GameFramework.LogSystem(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
public ImpactInfo SendImpact(TableConfig.Skill cfg, int seq, int curObjId, int srcObjId, int targetId, int impactId, bool isFinal, Dictionary <string, object> args) { EntityViewModel view = GetEntityViewById(targetId); if (null != view && null != view.Entity && null != view.Actor && !view.Entity.IsDeadSkillCasting()) { EntityInfo npc = view.Entity; if (null != cfg) { UnityEngine.Quaternion hitEffectRotation = UnityEngine.Quaternion.identity; UnityEngine.GameObject srcObj = GetGameObject(srcObjId); UnityEngine.GameObject targetObj = view.Actor; if (null != srcObj && null != targetObj) { hitEffectRotation = srcObj.transform.localRotation; } var addArgs = new Dictionary <string, object> { { "hitEffectRotation", hitEffectRotation } }; ImpactInfo impactInfo = null; if (impactId <= 0 || impactId >= SkillInstance.c_FirstInnerHitSkillId) { impactInfo = new ImpactInfo(PredefinedSkill.Instance.HitSkillCfg); impactId = PredefinedSkill.c_HitSkillId; } else { impactInfo = new ImpactInfo(impactId); } if (null != impactInfo.ConfigData) { if (TryInitImpactInfo(impactInfo, cfg, seq, curObjId, srcObjId, args)) { if (impactInfo.ConfigData.type == (int)SkillOrImpactType.Buff) { ImpactInfo oldImpactInfo = npc.GetSkillStateInfo().FindImpactInfoById(impactInfo.ImpactId); if (null != oldImpactInfo) { oldImpactInfo.DurationTime += impactInfo.DurationTime; return(oldImpactInfo); } } impactInfo.DamageData.IsFinal = isFinal; npc.GetSkillStateInfo().AddImpact(impactInfo); SkillInfo skillInfo = npc.GetSkillStateInfo().GetCurSkillInfo(); if (null != skillInfo && cfg.skillData.isInterrupt) { GfxSkillSystem.Instance.StopSkill(targetId, skillInfo.SkillId, 0, true); } GfxSkillSystem.Instance.StartSkill(targetId, impactInfo.ConfigData, impactInfo.Seq, args, addArgs); return(impactInfo); } } else { LogSystem.Error("impact {0} config can't found !", impactInfo.ImpactId); } } } return(null); }
private void BuildImpl() { int nextUnusedNode = 1; m_BuildStack.Push(0); m_BuildStack.Push(m_ObjectNum); m_BuildStack.Push(0); while (m_BuildStack.Count >= 3) { int begin = m_BuildStack.Pop(); //待分类数据对象开始位置 int end = m_BuildStack.Pop(); //待分类数据对象结束位置的后一个位置 int node = m_BuildStack.Pop(); //kdtree上用来构造新结点的位置 KdTreeObject obj0 = m_Objects[begin]; float minX = obj0.MinX; float maxX = obj0.MaxX; float minZ = obj0.MinZ; float maxZ = obj0.MaxZ; for (int i = begin + 1; i < end; ++i) { KdTreeObject obj = m_Objects[i]; float newMaxX = obj.MaxX; float newMinX = obj.MinX; float newMaxZ = obj.MaxZ; float newMinZ = obj.MinZ; if (minX > newMinX) { minX = newMinX; } if (maxX < newMaxX) { maxX = newMaxX; } if (minZ > newMinZ) { minZ = newMinZ; } if (maxZ < newMaxZ) { maxZ = newMaxZ; } } m_KdTree[node].m_MinX = minX; m_KdTree[node].m_MaxX = maxX; m_KdTree[node].m_MinZ = minZ; m_KdTree[node].m_MaxZ = maxZ; if (end - begin > c_MaxLeafSize) { //kdtree上2个子结点的位置预留 m_KdTree[node].m_Left = nextUnusedNode; ++nextUnusedNode; m_KdTree[node].m_Right = nextUnusedNode; ++nextUnusedNode; bool isVertical = (maxX - minX > maxZ - minZ); float splitValue = (isVertical ? 0.5f * (maxX + minX) : 0.5f * (maxZ + minZ)); int begin0 = begin; int left = begin; int right = end; //接下来,变量涵义如下: //begin0为当前结点上挂的数据对象的起始位置 //begin为当前结点上挂的数据对象的结束位置的后一个位置,同时也是左子树的数据对象的起始位置 //left为左子树的数据对象的结束位置的后一个位置,也是待分类数据对象的起始位置 //right为当前已确定的右子树数据对象的起始位置 //end为右子树数据对象结束位置的后一个位置 bool canSplit = false; while (left < right) { while (left < right) { KdTreeObject obj = m_Objects[left]; if ((isVertical ? obj.MaxX : obj.MaxZ) < splitValue) { //obj为左子树上的数据对象,标记要拆分子树 ++left; canSplit = true; } else if ((isVertical ? obj.MinX : obj.MinZ) <= splitValue) { //obj为当前结点上的数据对象,后续要调整begin的数据与begin位置 obj.Indexed = true; break; } else { break; } } while (left < right) { KdTreeObject obj = m_Objects[right - 1]; if ((isVertical ? obj.MinX : obj.MinZ) > splitValue) { //obj为右子树上的数据对象,这里不需要标记拆分 --right; } else if ((isVertical ? obj.MaxX : obj.MaxZ) >= splitValue) { //obj为当前结点上的数据对象,后续要调整begin的数据与begin位置 obj.Indexed = true; break; } else { break; } } if (left < right) { if (m_Objects[left].Indexed || m_Objects[right - 1].Indexed) { if (m_Objects[left].Indexed) { KdTreeObject tmp = m_Objects[begin]; m_Objects[begin] = m_Objects[left]; m_Objects[left] = tmp; ++begin; ++left; canSplit = true; //将数据对象挂到当前结点上(数据交换到begin位置),begin后移一个位置,left也后移一个位置 } if (left < right && m_Objects[right - 1].Indexed) { KdTreeObject tmp = m_Objects[begin]; m_Objects[begin] = m_Objects[right - 1]; m_Objects[right - 1] = m_Objects[left]; m_Objects[left] = tmp; ++begin; ++left; canSplit = true; //将数据对象挂到当前结点上(数据交换到begin位置),left位置的数据对象放到right-1(继续处理),begin后移一个位置,left也后移一个位置 } //处理完要挂接的数据后,继续处理(可能left或right-1位置有一处是不合分类标准的数据) } else { KdTreeObject tmp = m_Objects[left]; m_Objects[left] = m_Objects[right - 1]; m_Objects[right - 1] = tmp; ++left; --right; canSplit = true; //left与right-1位置都是不符合分类标准的数据,交换数据后继续处理 } } } if (canSplit) { m_KdTree[node].m_Begin = begin0; m_KdTree[node].m_End = begin; if (left > begin) { m_BuildStack.Push(m_KdTree[node].m_Left); m_BuildStack.Push(left); m_BuildStack.Push(begin); } else { m_KdTree[node].m_Left = 0; } if (end > left) { m_BuildStack.Push(m_KdTree[node].m_Right); m_BuildStack.Push(end); m_BuildStack.Push(left); } else { m_KdTree[node].m_Right = 0; } } else { m_KdTree[node].m_Begin = begin0; m_KdTree[node].m_End = begin0; m_KdTree[node].m_Left = 0; m_KdTree[node].m_Right = 0; nextUnusedNode -= 2; LogSystem.Error("KdTree build error, node {0} has no objs [{1}-{1}) and no sub tree.", node, begin0); } } else { m_KdTree[node].m_Begin = begin; m_KdTree[node].m_End = end; m_KdTree[node].m_Left = 0; m_KdTree[node].m_Right = 0; } } }
private StoryInstance NewStoryInstance(string storyId, string _namespace, bool logIfNotFound, params string[] overloadFiles) { if (!string.IsNullOrEmpty(_namespace)) { storyId = string.Format("{0}:{1}", _namespace, storyId); } StoryInstance instance = GetStoryInstance(storyId); if (null == instance) { TableConfig.Level cfg = TableConfig.LevelProvider.Instance.GetLevel(m_Scene.SceneResId); if (null != cfg) { string[] filePath; if (overloadFiles.Length <= 0) { int ct1 = cfg.SceneDslFile.Count; int ct2 = cfg.RoomDslFile.Count; filePath = new string[ct1 + ct2]; for (int i = 0; i < ct1; i++) { filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + cfg.SceneDslFile[i]); } for (int i = 0; i < ct2; i++) { filePath[ct1 + i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + cfg.RoomDslFile[i]); } } else { int ct = overloadFiles.Length; filePath = new string[ct]; for (int i = 0; i < ct; i++) { filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + overloadFiles[i]); } } StoryConfigManager.Instance.LoadStories(m_Scene.SceneResId, _namespace, filePath); instance = StoryConfigManager.Instance.NewStoryInstance(storyId, m_Scene.SceneResId); if (instance == null) { if (logIfNotFound) { LogSystem.Error("Can't load story config, story:{0} scene:{1} !", storyId, m_Scene.SceneResId); } return(null); } for (int ix = 0; ix < filePath.Length; ++ix) { Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(filePath[ix]); if (null != stories) { foreach (KeyValuePair <string, StoryInstance> pair in stories) { if (pair.Key != storyId) { AddStoryInstance(pair.Key, pair.Value.Clone()); } } } } AddStoryInstance(storyId, instance); return(instance); } else { if (logIfNotFound) { LogSystem.Error("Can't find story config, story:{0} scene:{1} !", storyId, m_Scene.SceneResId); } return(null); } } else { return(instance); } }
internal bool StartSkill(int actorId, TableConfig.Skill configData, int seq, params Dictionary <string, object>[] locals) { bool ret = false; if (null == configData) { LogSystem.Error("{0} can't cast skill, config is null !", actorId, seq); Helper.LogCallStack(); return(false); } if (!m_Scene.EntityController.CanCastSkill(actorId, configData, seq)) { m_Scene.EntityController.CancelCastSkill(actorId); LogSystem.Warn("{0} can't cast skill {1} {2}, cancel.", actorId, configData.id, seq); m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); return(false); } GfxSkillSenderInfo senderInfo = m_Scene.EntityController.BuildSkillInfo(actorId, configData, seq, m_Scene); if (null != senderInfo && null != senderInfo.GfxObj) { int skillId = senderInfo.SkillId; EntityInfo obj = senderInfo.GfxObj; SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq); if (logicInfo != null) { LogSystem.Warn("{0} is casting skill {1} {2}, cancel.", actorId, skillId, seq); m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); return(false); } SkillInstanceInfo inst = null; SkillInstance innerInstance = null; if (skillId == PredefinedSkill.c_EmitSkillId) { for (int i = 0; i < locals.Length; ++i) { object instObj; if (locals[i].TryGetValue("emitskill", out instObj)) { innerInstance = instObj as SkillInstance; } } if (null == innerInstance) { LogSystem.Warn("{0} use predefined skill {1} {2} but not found emitskill, cancel.", actorId, skillId, seq); //m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); //return false; } } else if (skillId == PredefinedSkill.c_HitSkillId) { for (int i = 0; i < locals.Length; ++i) { object instObj; if (locals[i].TryGetValue("hitskill", out instObj)) { innerInstance = instObj as SkillInstance; } } if (null == innerInstance) { LogSystem.Warn("{0} use predefined skill {1} {2} but not found hitskill, cancel.", actorId, skillId, seq); //m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); //return false; } } if (null == innerInstance) { inst = NewSkillInstance(skillId, senderInfo.ConfigData); } else { inst = NewInnerSkillInstance(skillId, innerInstance); } if (null != inst) { m_SkillLogicInfos.Add(new SkillLogicInfo(senderInfo, inst)); } else { LogSystem.Warn("{0} cast skill {1} {2}, alloc failed.", actorId, skillId, seq); m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); return(false); } logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq); if (null != logicInfo) { if (null != locals) { int localCount = locals.Length; for (int i = 0; i < localCount; ++i) { foreach (KeyValuePair <string, object> pair in locals[i]) { logicInfo.SkillInst.SetVariable(pair.Key, pair.Value); } } } EntityInfo target = senderInfo.TargetGfxObj; if (null != target && target != obj && configData.type == (int)SkillOrImpactType.Skill) { TriggerUtil.Lookat(m_Scene, obj, target.GetMovementStateInfo().GetPosition3D()); } m_Scene.EntityController.ActivateSkill(actorId, skillId, seq); logicInfo.SkillInst.Context = m_Scene; logicInfo.SkillInst.Start(logicInfo.Sender); ret = true; } } return(ret); }
public static bool Convert(string file, string outFile, Encoding encoding) { try { string[] lines = File.ReadAllLines(file, encoding); if (lines.Length >= 2) { string[] types = lines[0].Split('\t'); string[] fields = lines[1].Split('\t'); string dirName = Path.GetDirectoryName(file); string fileName = Path.GetFileName(file); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file); int fieldCount = 0; int excelColumnCount = types.Length; if (fields.Length != excelColumnCount) { LogSystem.Error("[line:2] “{0}” field count != {1}", lines[1], excelColumnCount); return(false); } for (int ix = 0; ix < excelColumnCount; ++ix) { if (string.IsNullOrEmpty(types[ix]) || string.IsNullOrEmpty(fields[ix])) { continue; } ++fieldCount; } BinaryTable table = new BinaryTable(); for (int rowIndex = 2; rowIndex < lines.Length; ++rowIndex) { if (lines[rowIndex].StartsWith("#") || lines[rowIndex].StartsWith("//")) { continue; } int colIndex = 0; string[] fieldValues = lines[rowIndex].Split('\t'); if (fieldValues.Length != excelColumnCount) { LogSystem.Error("[line:{0}] “{1}” field count != {2}", rowIndex + 1, lines[rowIndex], excelColumnCount); continue; } byte[] record = new byte[fieldCount * sizeof(int)]; table.Records.Add(record); for (int ix = 0; ix < excelColumnCount; ++ix) { if (string.IsNullOrEmpty(fields[ix]) || string.IsNullOrEmpty(types[ix])) { continue; } string type = types[ix].Trim(); string val = fieldValues[ix].Trim(); try { if (0 == type.CompareTo("int") || 0 == type.CompareTo("int32") || 0 == type.CompareTo("long") || 0 == type.CompareTo("int64")) { int v = 0; if (!string.IsNullOrEmpty(val)) { v = int.Parse(val); } WriteIndex(record, colIndex, v); } else if (0 == type.CompareTo("float")) { float v = 0; if (!string.IsNullOrEmpty(val)) { v = float.Parse(val); } WriteFloat(record, colIndex, v); } else if (0 == type.CompareTo("bool")) { bool v = false; if (!string.IsNullOrEmpty(val)) { v = (val == "true" || val == "1"); } WriteIndex(record, colIndex, v ? 1 : 0); } else if (0 == type.CompareTo("string")) { int index = table.AddString(val); WriteIndex(record, colIndex, index); } else if (0 == type.CompareTo("int[]") || 0 == type.CompareTo("int32[]") || 0 == type.CompareTo("long[]") || 0 == type.CompareTo("int64[]")) { int index = -1; if (!string.IsNullOrEmpty(val)) { string[] v = val.Split(',', ';', '|', ' '); int[] vals = new int[v.Length]; for (int i = 0; i < v.Length; ++i) { vals[i] = int.Parse(v[i]); } index = table.AddIntList(vals); } WriteIndex(record, colIndex, index); } else if (0 == type.CompareTo("float[]")) { int index = -1; if (!string.IsNullOrEmpty(val)) { string[] v = val.Split(',', ';', '|', ' '); float[] vals = new float[v.Length]; for (int i = 0; i < v.Length; ++i) { vals[i] = float.Parse(v[i]); } index = table.AddFloatList(vals); } WriteIndex(record, colIndex, index); } else if (0 == type.CompareTo("bool[]")) { int index = -1; if (!string.IsNullOrEmpty(val)) { string[] v = val.Split(',', ';', '|', ' '); int[] vals = new int[v.Length]; for (int i = 0; i < v.Length; ++i) { vals[i] = (v[i] == "true" || v[i] == "1") ? 1 : 0; } index = table.AddIntList(vals); } WriteIndex(record, colIndex, index); } else if (0 == type.CompareTo("string[]")) { int index = -1; if (!string.IsNullOrEmpty(val)) { string[] vals = val.Split(',', ';', '|', ' '); index = table.AddStrList(vals); } WriteIndex(record, colIndex, index); } } catch (Exception ex) { LogSystem.Error("[line:{0} col:{1}] “{2}”, exception:{3}\n{4}", rowIndex + 1, colIndex + 1, lines[rowIndex], ex.Message, ex.StackTrace); } ++colIndex; } } table.Save(outFile); } return(true); } catch (Exception ex) { LogSystem.Error("exception:{0}\n{1}", ex.Message, ex.StackTrace); return(false); } }