public bool Open(string file) { if (!string.IsNullOrEmpty(file)) { if (!File.Exists(file)) { FileStream fs = new FileStream(file, FileMode.Create); fs.Close(); } nowFile = file; string cdb = MyPath.Combine( Path.GetDirectoryName(file), "../cards.cdb"); SetCardDB(cdb);//后台加载卡片数据 fctb.OpenFile(nowFile, new UTF8Encoding(false)); oldtext = fctb.Text; SetTitle(); return(true); } return(false); }
public Card[] ReadMSE(string mseset, bool repalceOld) { //解压所有文件 using (ZipStorer zips = ZipStorer.Open(mseset, FileAccess.Read)) { zips.EncodeUTF8 = true; List <ZipStorer.ZipFileEntry> files = zips.ReadCentralDir(); int count = files.Count; int i = 0; foreach (ZipStorer.ZipFileEntry file in files) { worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count)); string savefilename = MyPath.Combine(mseHelper.ImagePath, file.FilenameInZip); zips.ExtractFile(file, savefilename); } } string setfile = MyPath.Combine(mseHelper.ImagePath, "set"); return(mseHelper.ReadCards(setfile, repalceOld)); }
protected List <Vector4D> FindRefinedPath(MyNavigationTriangle start, MyNavigationTriangle end, ref Vector3 startPoint, ref Vector3 endPoint) { MyPath <MyNavigationPrimitive> inputPath = base.FindPath(start, end, null, null); if (inputPath == null) { return(null); } List <Vector4D> refinedPath = new List <Vector4D> { new Vector4D(startPoint, 1.0) }; new Funnel().Calculate(inputPath, refinedPath, ref startPoint, ref endPoint, 0, inputPath.Count - 1); m_path.Clear(); foreach (Vector4D vectord in refinedPath) { m_path.Add((Vector3) new Vector3D(vectord)); } return(refinedPath); }
private static void exportSetThread(object obj) { string[] args = (string[])obj; if (args == null || args.Length < 3) { MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr)); return; } string mse_path = args[0]; string setfile = args[1]; string path = args[2]; if (string.IsNullOrEmpty(mse_path) || string.IsNullOrEmpty(setfile)) { MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImagesErr)); return; } else { string cmd = " --export " + setfile.Replace("\\\\", "\\").Replace("\\", "/") + " {card.gamecode}.png"; _mseProcess = new System.Diagnostics.Process(); _mseProcess.StartInfo.FileName = mse_path; _mseProcess.StartInfo.Arguments = cmd; _mseProcess.StartInfo.WorkingDirectory = path; _mseProcess.EnableRaisingEvents = true; MyPath.CreateDir(path); try { _mseProcess.Start(); //等待结束,需要把当前方法放到线程里面 _mseProcess.WaitForExit(); _mseProcess.Exited += new EventHandler(_exitHandler); _mseProcess.Close(); _mseProcess = null; MessageBox.Show(LanguageHelper.GetMsg(LMSG.exportMseImages)); } catch { } } }
protected override void DefWndProc(ref Message m) { switch (m.Msg) { case MyConfig.WM_OPEN: //处理消息 string file = MyPath.Combine(Application.StartupPath, MyConfig.FILE_TEMP); if (File.Exists(file)) { this.Activate(); string openfile = File.ReadAllText(file); //获取需要打开的文件路径 this.Open(openfile); //File.Delete(file); } break; default: base.DefWndProc(ref m); break; } }
private void ConstructFunnel(int index) { if (index >= this.m_endIndex) { this.AddPoint(this.m_apex); } else { MyPath <MyNavigationPrimitive> .PathNode node = this.m_input[index]; MyNavigationTriangle vertex = node.Vertex as MyNavigationTriangle; vertex.GetNavigationEdge(node.nextVertex); this.GetEdgeVerticesSafe(vertex, node.nextVertex, out this.m_leftPoint, out this.m_rightPoint); if (Vector3.IsZero(this.m_leftPoint - this.m_apex)) { this.m_apex = vertex.Center; } else if (Vector3.IsZero(this.m_rightPoint - this.m_apex)) { this.m_apex = vertex.Center; } else { this.m_apexNormal = vertex.Normal; float num = this.m_leftPoint.Dot(this.m_apexNormal); this.m_apex -= this.m_apexNormal * (this.m_apex.Dot(this.m_apexNormal) - num); this.m_leftIndex = this.m_rightIndex = index; this.RecalculateLeftPlane(); this.RecalculateRightPlane(); this.m_funnelConstructed = true; this.AddPoint(this.m_apex); MyNavigationMesh.FunnelState item = new MyNavigationMesh.FunnelState { Apex = this.m_apex, Left = this.m_leftPoint, Right = this.m_rightPoint }; MyNavigationMesh.m_debugFunnel.Add(item); } } }
public MyPath <MyNavigationPrimitive> FindPathLowlevel(Vector3D begin, Vector3D end) { MyPath <MyNavigationPrimitive> path = null; Debug.Assert(MyPerGameSettings.EnablePathfinding, "Pathfinding is not enabled!"); if (!MyPerGameSettings.EnablePathfinding) { return(path); } ProfilerShort.Begin("MyPathfinding.FindPathLowlevel"); var startPrim = FindClosestPrimitive(begin, highLevel: false); var endPrim = FindClosestPrimitive(end, highLevel: false); if (startPrim != null && endPrim != null) { path = FindPath(startPrim, endPrim); } ProfilerShort.End(); return(path); }
private void SetList(List <Vector3> path) { if (path == null || this.stopFinding) { return; } this.Path.Clear(); if (path.Count > 0) { for (int i = 0; i < path.Count; i++) { MyPath myPath = new MyPath(); myPath.pos = path[i]; if (i % 2 == 0) { myPath.isSend = true; } this.Path.Add(myPath); } this.Path[this.Path.Count - 1].isSend = true; } }
EditorModel LoadExistingModel(FileContainer container, FileInfo file, DirectoryInfo rawLocation) { if (rawLocation != null) { container.MontageModel.DisplayedRawLocation = MyPath.RelativeTo(rawLocation.FullName, RawFolder.FullName); } else { container.MontageModel.DisplayedRawLocation = file.Name; rawLocation = new DirectoryInfo("Z:\\"); } if (container.MontageModel.Patches == null) { container.MontageModel.Patches = new List <Patch>(); } var model = new EditorModel(file, rawLocation, this, container.MontageModel, container.WindowState); SaveEditorModel(model); return(model); }
public void CutImages(string imgpath, bool isreplace) { int count = this.cardlist.Length; int i = 0; foreach (Card c in this.cardlist) { if (this.isCancel) { break; } i++; this.worker.ReportProgress((i / count), string.Format("{0}/{1}", i, count)); string jpg = MyPath.Combine(imgpath, c.id + ".jpg"); string savejpg = MyPath.Combine(this.mseHelper.ImagePath, c.id + ".jpg"); if (File.Exists(jpg) && (isreplace || !File.Exists(savejpg))) { Bitmap bp = new Bitmap(jpg); Bitmap bmp; if (c.IsType(CardType.TYPE_XYZ))//超量 { bmp = MyBitmap.Cut(bp, this.imgSet.xyzArea); } else if (c.IsType(CardType.TYPE_PENDULUM))//P怪兽 { bmp = MyBitmap.Cut(bp, this.imgSet.pendulumArea); } else//一般 { bmp = MyBitmap.Cut(bp, this.imgSet.normalArea); } bp.Dispose(); MyBitmap.SaveAsJPEG(bmp, savejpg, this.imgSet.quilty); //bmp.Save(savejpg, ImageFormat.Png); } } }
static void SaveLanguage() { string datapath = MyPath.Combine(Application.StartupPath, MyConfig.TAG_DATA); string conflang = MyConfig.GetLanguageFile(datapath); LanguageHelper.LoadFormLabels(conflang); LanguageHelper langhelper = new LanguageHelper(); MainForm form1 = new MainForm(); LanguageHelper.SetFormLabel(form1); langhelper.GetFormLabel(form1); DataEditForm form2 = new DataEditForm(); LanguageHelper.SetFormLabel(form2); langhelper.GetFormLabel(form2); CodeEditForm form3 = new CodeEditForm(); LanguageHelper.SetFormLabel(form3); langhelper.GetFormLabel(form3); // LANG.GetFormLabel(this); //获取窗体文字 langhelper.SaveLanguage(conflang + ".bak"); }
protected List <Vector4D> FindRefinedPath(MyNavigationTriangle start, MyNavigationTriangle end, ref Vector3 startPoint, ref Vector3 endPoint) { MyPath <MyNavigationPrimitive> triPath = FindPath(start, end); if (triPath == null) { return(null); } // Path made of triangle centers //List<Vector3> path = new List<Vector3>(); //path.Add(startPoint); //for (int j = 1; j < triPath.Count - 1; ++j) //{ // path.Add((triPath[j].Vertex as MyNavigationTriangle).Center); //} //path.Add(endPoint); //m_path2 = path; //return path; // Refined path smoothed by the funnel algorithm List <Vector4D> refinedPath = new List <Vector4D>(); refinedPath.Add(new Vector4D(startPoint, 1.0f)); Funnel funnel = new Funnel(); funnel.Calculate(triPath, refinedPath, ref startPoint, ref endPoint, 0, triPath.Count - 1); m_path.Clear(); foreach (var p in refinedPath) { m_path.Add(new Vector3D(p)); } return(refinedPath); }
/// <summary> /// 语言配置文件名 /// </summary> /// <param name="path"></param> /// <returns></returns> public static string GetLanguageFile(string path) { if (readBoolean(TAG_CHECK_SYSLANG) && Directory.Exists(path)) { Save(TAG_CHECK_SYSLANG, "false"); string[] words = CultureInfo.InstalledUICulture.EnglishName.Split(' '); string syslang = words[0]; string[] files = Directory.GetFiles(path); foreach (string file in files) { string name = MyPath.getFullFileName(MyConfig.TAG_LANGUAGE, file); if (string.IsNullOrEmpty(name)) { continue; } if (syslang.Equals(name, StringComparison.OrdinalIgnoreCase)) { Save(MyConfig.TAG_LANGUAGE, syslang); break; } } } return(MyPath.Combine(path, MyPath.getFileName(MyConfig.TAG_LANGUAGE, GetAppConfig(TAG_LANGUAGE)))); }
private void GenerateHighLevelPath() { this.ClearPathNodes(); if (this.m_hlBegin != null) { MyPath <MyNavigationPrimitive> path = this.m_goal.FindHighLevelPath(this.m_pathfinding, this.m_hlBegin); if (path != null) { using (IEnumerator <MyPath <MyNavigationPrimitive> .PathNode> enumerator = path.GetEnumerator()) { while (enumerator.MoveNext()) { MyHighLevelPrimitive vertex = enumerator.Current.Vertex as MyHighLevelPrimitive; this.m_pathNodes.Add(vertex); if (!ReferenceEquals(vertex, this.m_hlBegin)) { vertex.Parent.ObservePrimitive(vertex, this); } } } this.m_pathNodePosition = 0; } } }
void OnSceneGUI() { MyPath path = (MyPath)target; Texture2D texture = new Texture2D(1, 1); texture.SetPixel(0, 0, Color.white); for (int i = 0; i < (path.nodes.Length - 1); i++) { MyNode startNode = path.nodes[i]; MyNode endNode = path.nodes[i + 1]; if (startNode != null && endNode != null) { Vector3 startPos = startNode.transform.position; Vector3 endPos = endNode.transform.position; Vector3 startTangent = startPos + startNode.transform.forward; Vector3 endTangent = endPos - endNode.transform.forward; Handles.DrawBezier(startPos, endPos, startTangent, endTangent, Color.green, texture, 3f); } } }
public Form1() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; #region MyLib初始化 m_f = new MyFile(); m_excel = new MyExcelReader(); m_db = new MyDB(); m_path = new MyPath(); m_time = new MyTime(); m_str = new MyString(); // m_workbook = new XSSFWorkbook(); m_dsHelper = new MyDataSetHelper(); #endregion }
public void SetConfig(string config, string path) { if (!File.Exists(config)) { return; } regx_monster = "(\\s\\S*?)"; regx_pendulum = "(\\s\\S*?)"; //设置文件名 configName = MyPath.getFullFileName(MSEConfig.TAG, config); replaces = new SortedList <string, string>(); typeDic = new SortedList <long, string>(); raceDic = new SortedList <long, string>(); string[] lines = File.ReadAllLines(config, Encoding.UTF8); foreach (string line in lines) { if (string.IsNullOrEmpty(line) || line.StartsWith("#")) { continue; } if (line.StartsWith(TAG_CN2TW)) { Iscn2tw = ConfHelper.getBooleanValue(line); } else if (line.StartsWith(TAG_SPELL)) { str_spell = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_HEAD)) { head = ConfHelper.getMultLineValue(line); } else if (line.StartsWith(TAG_END)) { end = ConfHelper.getMultLineValue(line); } else if (line.StartsWith(TAG_TEXT)) { temp_text = ConfHelper.getMultLineValue(line); } else if (line.StartsWith(TAG_TRAP)) { str_trap = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_REG_PENDULUM)) { regx_pendulum = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_REG_MONSTER)) { regx_monster = ConfHelper.getValue(line); } else if (line.StartsWith(TAG_MAXCOUNT)) { maxcount = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_WIDTH)) { width = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_HEIGHT)) { height = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_PEND_WIDTH)) { pwidth = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_PEND_HEIGHT)) { pheight = ConfHelper.getIntegerValue(line, 0); } else if (line.StartsWith(TAG_NO_TEN)) { no10 = ConfHelper.getBooleanValue(line); } else if (line.StartsWith(TAG_NO_START_CARDS)) { string val = ConfHelper.getValue(line); string[] cs = val.Split(','); noStartCards = new long[cs.Length]; int i = 0; foreach (string str in cs) { long l = 0; long.TryParse(str, out l); noStartCards[i++] = l; } } else if (line.StartsWith(TAG_IMAGE)) { //如果路径不合法,则为后面的路径 imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, PATH_IMAGE)); //图片缓存目录 imagecache = MyPath.Combine(imagepath, "cache"); MyPath.CreateDir(imagecache); } else if (line.StartsWith(TAG_REPALCE)) { //特数字替换 string word = ConfHelper.getValue(line); string p = ConfHelper.getRegex(ConfHelper.getValue1(word)); string r = ConfHelper.getRegex(ConfHelper.getValue2(word)); if (!string.IsNullOrEmpty(p)) { replaces.Add(p, r); } } else if (line.StartsWith(TAG_RACE)) { //种族 ConfHelper.DicAdd(raceDic, line); } else if (line.StartsWith(TAG_TYPE)) { //类型 ConfHelper.DicAdd(typeDic, line); } else if (line.StartsWith(TAG_REIMAGE)) { reimage = ConfHelper.getBooleanValue(line); } } }
/// <summary> /// 卡片信息配置文件名 /// </summary> /// <param name="path"></param> /// <returns></returns> public static string GetCardInfoFile(string path) { return(MyPath.Combine(path, MyPath.getFileName(MyConfig.TAG_CARDINFO, GetAppConfig(TAG_LANGUAGE)))); }
public AssertContext BuildChildContext(XmlNodeSimplified childNode, int childNodeIndex) { var childPath = MyPath.Append(childNode.Name, childNodeIndex); return(new AssertContext(childPath, childNode, StringComparer)); }
private void RefineFoundPath(ref Vector3D begin, ref Vector3D end, MyPath <MyNavigationPrimitive> path) { Debug.Assert(MyPerGameSettings.EnablePathfinding, "Pathfinding is not enabled!"); if (!MyPerGameSettings.EnablePathfinding) { return; } if (path == null) { Debug.Assert(false, "Path to refine was null!"); return; } m_currentPrimitive = path[path.Count - 1].Vertex as MyNavigationPrimitive; if (m_hlBegin != null && !m_pathNodes.Contains(m_hlBegin)) { m_hlBegin.Parent.StopObservingPrimitive(m_hlBegin, this); } m_hlBegin = m_currentPrimitive.GetHighLevelPrimitive(); if (m_hlBegin != null && !m_pathNodes.Contains(m_hlBegin)) { m_hlBegin.Parent.ObservePrimitive(m_hlBegin, this); } ProfilerShort.Begin("Path refining and post-processing"); IMyNavigationGroup prevGroup = null; int groupStart = 0; int groupEnd = 0; Vector3 prevBegin = default(Vector3); Vector3 prevEnd = default(Vector3); for (int i = 0; i < path.Count; ++i) { var primitive = path[i].Vertex as MyNavigationPrimitive; var group = primitive.Group; if (prevGroup == null) { prevGroup = group; prevBegin = prevGroup.GlobalToLocal(begin); } bool lastPrimitive = i == path.Count - 1; if (group != prevGroup) { groupEnd = i - 1; prevEnd = prevGroup.GlobalToLocal(primitive.WorldPosition); } else if (lastPrimitive) { groupEnd = i; prevEnd = prevGroup.GlobalToLocal(end); } else { continue; } int refinedBegin = m_expandedPath.Count; prevGroup.RefinePath(path, m_expandedPath, ref prevBegin, ref prevEnd, groupStart, groupEnd); int refinedEnd = m_expandedPath.Count; for (int j = refinedBegin; j < refinedEnd; ++j) { Vector3D position = new Vector3D(m_expandedPath[j]); position = prevGroup.LocalToGlobal(position); m_expandedPath[j] = new Vector4D(position, m_expandedPath[j].W); } if (lastPrimitive && group != prevGroup) { m_expandedPath.Add(new Vector4D(primitive.WorldPosition, m_expandedPath[refinedEnd - 1].W)); } prevGroup = group; groupStart = i; if (m_expandedPath.Count != 0) { prevBegin = group.GlobalToLocal(new Vector3D(m_expandedPath[m_expandedPath.Count - 1])); } } m_pathNodePosition++; //m_expandedPath.RemoveAt(0); m_expandedPathPosition = 0; ProfilerShort.End(); }
public DataConfig() { InitMember(MyPath.Combine(Application.StartupPath, DEXConfig.TAG_CARDINFO + ".txt")); }
public string GetScript(string id) { return(MyPath.Combine(luapath, "c" + id + ".lua")); }
//字符串id public string GetImage(string id) { return(MyPath.Combine(picpath, id + ".jpg")); }
// Output is Vector4D, because the first three coords specify path node center and the fourth defines the radius public void RefinePath(MyPath <MyNavigationPrimitive> path, List <Vector4D> output, ref Vector3 startPoint, ref Vector3 endPoint, int begin, int end) { Funnel funnel = new Funnel(); funnel.Calculate(path, output, ref startPoint, ref endPoint, begin, end); }
private void RefineFoundPath(ref Vector3D begin, ref Vector3D end, MyPath<MyNavigationPrimitive> path) { Debug.Assert(MyPerGameSettings.EnablePathfinding, "Pathfinding is not enabled!"); if (!MyPerGameSettings.EnablePathfinding) { return; } if (path == null) { Debug.Assert(false, "Path to refine was null!"); return; } m_currentPrimitive = path[path.Count - 1].Vertex as MyNavigationPrimitive; if (m_hlBegin != null && !m_pathNodes.Contains(m_hlBegin)) { m_hlBegin.Parent.StopObservingPrimitive(m_hlBegin, this); } m_hlBegin = m_currentPrimitive.GetHighLevelPrimitive(); if (m_hlBegin != null && !m_pathNodes.Contains(m_hlBegin)) { m_hlBegin.Parent.ObservePrimitive(m_hlBegin, this); } ProfilerShort.Begin("Path refining and post-processing"); IMyNavigationGroup prevGroup = null; int groupStart = 0; int groupEnd = 0; Vector3 prevBegin = default(Vector3); Vector3 prevEnd = default(Vector3); for (int i = 0; i < path.Count; ++i) { var primitive = path[i].Vertex as MyNavigationPrimitive; var group = primitive.Group; if (prevGroup == null) { prevGroup = group; prevBegin = prevGroup.GlobalToLocal(begin); } bool lastPrimitive = i == path.Count - 1; if (group != prevGroup) { groupEnd = i - 1; prevEnd = prevGroup.GlobalToLocal(primitive.WorldPosition); } else if (lastPrimitive) { groupEnd = i; prevEnd = prevGroup.GlobalToLocal(end); } else { continue; } int refinedBegin = m_expandedPath.Count; prevGroup.RefinePath(path, m_expandedPath, ref prevBegin, ref prevEnd, groupStart, groupEnd); int refinedEnd = m_expandedPath.Count; for (int j = refinedBegin; j < refinedEnd; ++j) { Vector3D position = new Vector3D(m_expandedPath[j]); position = prevGroup.LocalToGlobal(position); m_expandedPath[j] = new Vector4D(position, m_expandedPath[j].W); } if (lastPrimitive && group != prevGroup) { m_expandedPath.Add(new Vector4D(primitive.WorldPosition, m_expandedPath[refinedEnd - 1].W)); } prevGroup = group; groupStart = i; if (m_expandedPath.Count != 0) prevBegin = group.GlobalToLocal(new Vector3D(m_expandedPath[m_expandedPath.Count - 1])); } m_pathNodePosition++; //m_expandedPath.RemoveAt(0); m_expandedPathPosition = 0; ProfilerShort.End(); }
public void testZipfile() { ZipFile.CreateFromDirectory(MyPath.Combine(Env.WebRootPath, "Upload", "testZipFile"), MyPath.Combine(Env.WebRootPath, "Download", "2.zip")); }
public string GetYdk(string name) { return(MyPath.Combine(ydkpath, name + ".ydk")); }
private void ExpandPath(Vector3D currentPosition) { if (m_pathNodePosition >= m_pathNodes.Count - 1) { ProfilerShort.Begin("GenerateHighLevelPath"); GenerateHighLevelPath(); ProfilerShort.End(); } if (m_pathNodePosition >= m_pathNodes.Count) { return; } MyPath <MyNavigationPrimitive> path = null; bool isLastPath = false; m_expandedPath.Clear(); if (m_pathNodePosition + 1 < m_pathNodes.Count) { if (m_pathNodes[m_pathNodePosition].IsExpanded) { if (m_pathNodes[m_pathNodePosition + 1].IsExpanded) { IMyHighLevelComponent component = m_pathNodes[m_pathNodePosition].GetComponent(); IMyHighLevelComponent otherComponent = m_pathNodes[m_pathNodePosition + 1].GetComponent(); // CH: TODO: Preallocate the functions to avoid using lambdas. ProfilerShort.Begin("FindPath to next compo"); path = m_pathfinding.FindPath(m_currentPrimitive, m_goal.PathfindingHeuristic, (prim) => otherComponent.Contains(prim) ? 0.0f : float.PositiveInfinity, (prim) => component.Contains(prim) || otherComponent.Contains(prim)); ProfilerShort.End(); } else { Debug.Assert(!MyFakes.SHOW_PATH_EXPANSION_ASSERTS, "First hierarchy path node is expanded, but the second one is not! First two nodes should always be expanded so that pathfinding can be done."); } } else { Debug.Assert(!MyFakes.SHOW_PATH_EXPANSION_ASSERTS, "Nodes of smart path are not expanded!"); } } else { if (m_pathNodes[m_pathNodePosition].IsExpanded) { // Try to find a path to a goal primitive inside the last high level component. // If the last primitive of the found path is not in the last high level component, add that component to the goal's ignore list IMyHighLevelComponent component = m_pathNodes[m_pathNodePosition].GetComponent(); ProfilerShort.Begin("FindPath to goal in the last component"); path = m_pathfinding.FindPath(m_currentPrimitive, m_goal.PathfindingHeuristic, (prim) => component.Contains(prim) ? m_goal.TerminationCriterion(prim) : 30.0f, (prim) => component.Contains(prim)); ProfilerShort.End(); if (path != null) { // We reached goal if (path.Count != 0 && component.Contains(path[path.Count - 1].Vertex as MyNavigationPrimitive)) { isLastPath = true; } // We reached other component (goal could not be reached in this component) else { m_goal.IgnoreHighLevel(m_pathNodes[m_pathNodePosition]); } } } else { Debug.Assert(!MyFakes.SHOW_PATH_EXPANSION_ASSERTS, "Nodes of smart path are not expanded!"); } } if (path == null || path.Count == 0) { return; } Vector3D end = default(Vector3D); var lastPrimitive = path[path.Count - 1].Vertex as MyNavigationPrimitive; if (isLastPath) { Vector3 endPoint = m_goal.Destination.GetBestPoint(lastPrimitive.WorldPosition); Vector3 localEnd = lastPrimitive.Group.GlobalToLocal(endPoint); localEnd = lastPrimitive.ProjectLocalPoint(localEnd); end = lastPrimitive.Group.LocalToGlobal(localEnd); } else { end = lastPrimitive.WorldPosition; } RefineFoundPath(ref currentPosition, ref end, path); // If the path is too short, don't use it to prevent jerking in stuck situations if (m_pathNodes.Count <= 1 && isLastPath && m_expandedPath.Count > 0 && path.Count <= 2 && !m_goal.ShouldReinitPath()) { Vector4D end4D = m_expandedPath[m_expandedPath.Count - 1]; // Here, 256 is just a small enough value to catch most false-positives if (Vector3D.DistanceSquared(currentPosition, end) < end4D.W * end4D.W / 256) { m_expandedPath.Clear(); } } }
//public string GetImageThum(string id) //{ // return MyPath.Combine(picpath2, id + ".jpg"); //} public string GetImageField(string id) { return(MyPath.Combine(fieldpath, id + ".png"));//场地图 }
public void ExportData(string path, string zipname, string _cdbfile, string modulescript) { int i = 0; Card[] cards = this.cardlist; if (cards == null || cards.Length == 0) { return; } int count = cards.Length; YgoPath ygopath = new YgoPath(path); string name = Path.GetFileNameWithoutExtension(zipname); //数据库 string cdbfile = zipname + ".cdb"; //说明 string readme = MyPath.Combine(path, name + ".txt"); //新卡ydk string deckydk = ygopath.GetYdk(name); //module scripts string extra_script = ""; if (modulescript.Length > 0) { extra_script = ygopath.GetModuleScript(modulescript); } File.Delete(cdbfile); DataBase.Create(cdbfile); DataBase.CopyDB(cdbfile, false, this.cardlist); if (File.Exists(zipname)) { File.Delete(zipname); } using (ZipStorer zips = ZipStorer.Create(zipname, "")) { zips.AddFile(cdbfile, Path.GetFileNameWithoutExtension(_cdbfile) + ".cdb", ""); if (File.Exists(readme)) { zips.AddFile(readme, "readme_" + name + ".txt", ""); } if (File.Exists(deckydk)) { zips.AddFile(deckydk, "deck/" + name + ".ydk", ""); } if (modulescript.Length > 0 && File.Exists(extra_script)) { zips.AddFile(extra_script, extra_script.Replace(path, ""), ""); } foreach (Card c in cards) { i++; this.worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count)); string[] files = ygopath.GetCardfiles(c.id); foreach (string file in files) { if (!string.Equals(file, extra_script) && File.Exists(file)) { zips.AddFile(file, file.Replace(path, ""), ""); } } } } File.Delete(cdbfile); }
public string GetModuleScript(string modulescript) { return(MyPath.Combine(luapath, modulescript + ".lua")); }
//打开脚本 public bool OpenScript(bool openinthis, string addrequire) { if (!dataform.CheckOpen()) { return(false); } Card c = dataform.GetCard(); long id = c.id; string lua; if (c.id > 0) { lua = dataform.GetPath().GetScript(id); } else if (addrequire.Length > 0) { lua = dataform.GetPath().GetModuleScript(addrequire); } else { return(false); } if (!File.Exists(lua)) { MyPath.CreateDirByFile(lua); if (MyMsg.Question(LMSG.IfCreateScript)) //是否创建脚本 { using (FileStream fs = new FileStream(lua, FileMode.OpenOrCreate, FileAccess.Write)) { StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false)); if (string.IsNullOrEmpty(addrequire)) { // OCG script sw.WriteLine("--" + c.name); sw.WriteLine("function c" + id.ToString() + ".initial_effect(c)"); sw.WriteLine("\t"); sw.WriteLine("end"); } else { // DIY script sw.WriteLine("--" + c.name); sw.WriteLine("local m=" + id.ToString()); sw.WriteLine("local cm=_G[\"c\"..m]"); sw.WriteLine("xpcall(function() require(\"expansions/script/" + addrequire + "\") end,function() require(\"script/" + addrequire + "\") end)"); sw.WriteLine("function cm.initial_effect(c)"); sw.WriteLine("\t"); sw.WriteLine("end"); } /*else * { //module script * sw.WriteLine("--Module script \"" + addrequire + "\""); * }*/ sw.Close(); fs.Close(); } } } if (File.Exists(lua)) //如果存在,则打开文件 { if (openinthis) //是否用本程序打开 { MyConfig.OpenFileInThis(lua); } else { System.Diagnostics.Process.Start(lua); } return(true); } return(false); }