private void Update() { if (m_RecordManager.IsStartRecord()) { m_TimeCount.text = ToolFunction.TranslateToMMSS(m_RecordManager.GetTimeCount()); } }
void CheckSequence() { if (currentSequence.Count >= sequenceLength && currentCooldown <= 0) { bool valid = false; for (int i = 0; i < availableFunctions.Length; i++) { if (availableFunctions[i].CheckSequenceMatch(currentSequence)) { selectedFunction = availableFunctions[i]; currentSequence = new List <Input>(); valid = true; } } if (valid) { Debug.Log("Vaild " + selectedFunction.function); ActivateTool(); } else { Debug.Log("Invalid"); GetComponent <Player>().health -= 0; currentSequence = new List <Input>(); } HudController.instance.ConfirmCharacters(valid); } }
public void SetFilterComm(Object condition) { if (condition != null) { #region var dataGridData = this; #region ItemsSourceView.Filter = new Predicate <object>((obj) => { bool isFilter = true; foreach (FilterProperty pinfo in ComparePropertyList) //循环筛选出来需要比较的属性 { string columnNameEn = pinfo.PropertyName; var filterValue = pinfo.PropertyValue;//过滤的值 string columnType = pinfo.PropertyInfo.PropertyType.ToString().Replace("System.Nullable`1[", "").Replace("]", "").Replace("System.", "").ToLower(); if (filterValue != null) { #region 重点内容 这里开始执行真正的比较 object rowValue = ToolFunction.GetPropertyValue(obj, pinfo.PropertyInfo);//数据行的值 if (rowValue == null) { if (filterValue.ToString() == "") { return(true); } else { return(false); } } else { isFilter = CompareValue(columnType, rowValue, filterValue, pinfo.ConditionStr); } #endregion } if (!isFilter) { return(isFilter); } } return(isFilter); }); #endregion #endregion } }
public static object ChangeValueForType(Type type, string text) { string typename = type.ToString().Replace("System.Nullable`1[", "").Replace("]", "").Replace("System.", "").ToLower(); switch (typename.ToLower()) { case "decimal": return(ToolFunction.ToDec(text)); case "int": case "int32": case "int64": case "long": return(ToolFunction.ToInt(text)); case "double": return(ToolFunction.ToDouble(text)); case "float": return(ToolFunction.ToFloat(text)); case "string": return(text.ToString()); case "bool": case "boolean": bool ret = false; if (text.ToString() == "是") { ret = true; } if (text.ToString() == "1") { ret = true; } if (text.ToString().ToLower() == "true") { ret = true; } if (text.ToString() == "否") { ret = false; } if (text.ToString() == "0") { ret = false; } if (text.ToString().ToLower() == "false") { ret = false; } return(ret); case "datetime": return(ToolFunction.ToDateTime(text)); default: return(text); } }
public void OnImportFile() { string filePath = ToolFunction.OpenFilePath("*.txt", "打开文件", ".txt"); ConfigCenter.Instance().AddHistoryFile(filePath); GetComponent <MovieCatalogueScript>().AddListItembByFileName(filePath); }
//实现接口的两个方法 #region IValueConverter 成员 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) { return(ToolFunction.ToMoney(value)); } return(value); }
public void LateUpdate() { if (m_MoviePlayManager.IsStart()) { m_TimeCount.text = ToolFunction.TranslateToMMSS(m_MoviePlayManager.GetCurrentTime()) + "/" + ToolFunction.TranslateToMMSS(m_MoviePlayManager.GetTotalTime()); m_TimeSlider.value = m_MoviePlayManager.GetCurrentPlayRate(); } }
public static ToolFunction Create() { ToolFunction asset = ScriptableObject.CreateInstance <ToolFunction>(); AssetDatabase.CreateAsset(asset, "Assets/NewToolFunction.asset"); AssetDatabase.SaveAssets(); return(asset); }
public void PortraitPath() { string filter = "*.jpg,*.png"; string title = "选择头像"; string extension = ".png"; string selectPortraitPath = ToolFunction.OpenFilePath(filter, title, extension); var tempSprite = ToolFunction.CreateSpriteFromImage(selectPortraitPath); m_PortraitImage.overrideSprite = tempSprite; }
void ActivateTool() { if (selectedFunction != null) { Debug.Log(selectedFunction.function); CreateObject(selectedFunction.function); maxCooldown = selectedFunction.cooldown; currentCooldown = selectedFunction.cooldown; selectedFunction = null; } }
private void AddListItembByFileName(string astrFileName) { var templist = astrFileName.Split('\\'); var tempFileName = templist[templist.Length - 1].Split('.')[0]; var tempHeadData = FileReader.GetHeadFromFile(astrFileName); var tempListItem = Instantiate(m_ListItemPrefab, m_Content.transform); tempListItem.GetComponentsInChildren <Image>()[1].overrideSprite = ToolFunction.CreateSpriteFromImage(ToolFunction.GetDefaultPortraitPathByName(tempHeadData.strPortrait, ".jpg")); tempListItem.GetComponentInChildren <Text>().text = tempHeadData.strDoctorName + "\n" + tempFileName; tempListItem.GetComponent <ClickCompairListItem>().SetFilePath(astrFileName); }
/// <summary> /// Add a pyramid (5 vertices and 5 planes) to this fragment. /// The pyramid should be given as (topVertex, bottomVertex1, bottomVertex2, bottomVertex3, bottomVertex4). /// </summary> /// <param name="pyramid">Pyramid given.</param> public void PushBackPyramid(List <Vector3> pyramid) { if (pyramid.Count != 5) { return; } Vector3 top = pyramid[0]; pyramid.RemoveAt(0); pyramid = ToolFunction.SortConvexPolygon(pyramid); PushBackTetra(new List <Vector3> { top, pyramid[0], pyramid[1], pyramid[2] }); PushBackTetra(new List <Vector3> { top, pyramid[0], pyramid[3], pyramid[2] }); }
public void BtnYes() { var filepath = m_DeleteObj.GetComponent <ClickMovieListItem>().GetFilePath(); ConfigCenter.Instance().DeleteFileByPath(filepath); var temphead = FileReader.GetHeadFromFile(filepath); var portraitpath = ToolFunction.GetDefaultPortraitPathByName(temphead.strPortrait, ".jpg"); if (File.Exists(portraitpath)) { File.Delete(portraitpath); } if (File.Exists(filepath)) { File.Delete(filepath); } Destroy(m_DeleteObj); Destroy(gameObject); }
private void ListMovieByDirectory(string strDirectoryPath) { if (string.IsNullOrEmpty(strDirectoryPath)) { return; } var dir = new DirectoryInfo(strDirectoryPath); if (dir.Exists) { var FileList = dir.GetFiles(); for (int tFileIndex = 0; tFileIndex < FileList.Length; ++tFileIndex) { if (ToolFunction.IsExtension(FileList[tFileIndex].FullName, ".txt")) { AddListItembByFileName(FileList[tFileIndex].FullName); } } } }
public void SetFileName(string strFileName) { if (bIsRef) { m_studyManager.SetRefFileName(strFileName); bIsRefFileSet = true; var tempHeadData = FileReader.GetHeadFromFile(strFileName); m_BtnRefData.image.overrideSprite = ToolFunction.CreateSpriteFromImage(ToolFunction.GetDefaultPortraitPathByName(tempHeadData.strPortrait, ".jpg")); m_BtnRefData.GetComponentInChildren <Text>().text = tempHeadData.strDoctorName; m_BtnRefData.GetComponentInChildren <Text>().alignment = TextAnchor.LowerCenter; } else { m_studyManager.SetCompairFileName(strFileName); bIsCompairFileSet = true; m_CompairData.SetActive(true); var tempHeadData = FileReader.GetHeadFromFile(strFileName); m_CompairData.GetComponentInChildren <Image>().overrideSprite = ToolFunction.CreateSpriteFromImage(ToolFunction.GetDefaultPortraitPathByName(tempHeadData.strPortrait, ".jpg")); m_CompairData.GetComponentInChildren <Text>().text = tempHeadData.strDoctorName; } }
public void Btn_Save() { if (string.IsNullOrEmpty(m_InputDoctorName.text) || string.IsNullOrEmpty(m_InputFilePath.text)) { m_InputDoctorName.placeholder.GetComponent <Text>().color = Color.red; m_InputFilePath.placeholder.GetComponent <Text>().color = Color.red; } else { //根据输入的文件名和选择的头像,将文件存储到默认存储文件夹,将头像图片复制到默认头像存储文件夹 m_FilePath = ToolFunction.GetMovieSaveFilePath(m_InputFilePath.text, ".txt"); var tempPortrait = ToolFunction.GenerateStringID(); ToolFunction.ImageSaveLocal(m_PortraitImage.mainTexture, ToolFunction.GetDefaultPortraitPathByName(tempPortrait, ".jpg")); int tempTimeCount = m_RecordManager.GetFrameCount(); int tempStartTime = (int)(tempTimeCount * m_fLeftSliderValue); int tempEndTime = (int)(tempTimeCount * m_fRightSliderValue); MovieHeadData tempData = new MovieHeadData( "MOVIE_DATA", m_InputDoctorName.text, tempPortrait, System.DateTime.Now.ToString("MM/dd/yyyy H:mm:ss"), tempEndTime - tempStartTime, 0, ConfigCenter.Instance().GetFPS() ); m_RecordManager.SaveDataToFile( tempData, m_FilePath, tempStartTime, tempEndTime ); m_SavePanel.SetActive(false); m_InfoSaved.SetActive(true); } }
public bool CompareValue(string type, object rowValue, object filterValue, string conditionStr) { bool result = false; switch (type.ToLower()) { case "decimal": case "int": case "int32": case "int64": case "long": case "double": case "float": var s_d = ToolFunction.ToDec(rowValue); var t_d = ToolFunction.ToDec(filterValue); switch (conditionStr) { case "=": result = s_d == t_d; break; case ">": result = s_d > t_d; break; case "<": result = s_d < t_d; break; case ">=": result = s_d >= t_d; break; case "<=": result = s_d <= t_d; break; case "!=": result = s_d != t_d; break; } break; case "string": var s_s = rowValue.ToString(); var t_s = filterValue.ToString(); if (string.IsNullOrWhiteSpace(conditionStr)) { conditionStr = "like"; } switch (conditionStr) { case "like": result = s_s.ToLower().Contains(t_s.ToLower()); break; case "!like": result = !s_s.ToLower().Contains(t_s.ToLower()); break; case "=": result = s_s.ToLower() == t_s.ToLower(); break; } break; case "bool": case "boolean": bool s_b = false; if (rowValue.ToString() == "是") { s_b = true; } if (rowValue.ToString() == "1") { s_b = true; } if (rowValue.ToString().ToLower() == "true") { s_b = true; } if (rowValue.ToString() == "否") { s_b = false; } if (rowValue.ToString() == "0") { s_b = false; } if (rowValue.ToString().ToLower() == "false") { s_b = false; } //================================== var t_b = false; if (filterValue.ToString() == "是") { t_b = true; } if (filterValue.ToString() == "1") { t_b = true; } if (filterValue.ToString().ToLower() == "true") { t_b = true; } if (filterValue.ToString() == "否") { t_b = false; } if (filterValue.ToString() == "0") { t_b = false; } if (filterValue.ToString().ToLower() == "false") { t_b = false; } switch (conditionStr) { case "!=": result = s_b != t_b; break; case "=": result = s_b == t_b; break; } break; case "datetime": var s_dt = ToolFunction.ToDateTime(rowValue); var t_dt = ToolFunction.ToDateTime(filterValue); switch (conditionStr) { case "=": result = s_dt == t_dt; break; case ">": result = s_dt > t_dt; break; case ">=": result = s_dt >= t_dt; break; case "<=": result = s_dt <= t_dt; break; case "<": result = s_dt < t_dt; break; case "!=": result = s_dt != t_dt; break; } break; } return(result); }
public DataGridConfig GetDataGridConfig() { string filePath = Environment.CurrentDirectory + @"\DataGridConfig.txt"; return(ToolFunction.DeSerializerFromFile <DataGridConfig>(filePath)); }
public void editWorld(Vector3 point,float editRadius,float editValue,ToolFunction tool) { regionCollisions.Clear(); getCollidingRegions(point,editRadius,ref regionCollisions); bool validEdit=true; foreach(Region r in regionCollisions){ if(r.data==null){ //Debug.Log ("Chunk not loaded, edit cancelled.."); validEdit=false; break; } } if(validEdit){ foreach(Region rgn in regionCollisions){ modifyRegion(rgn,point,editRadius,editValue,tool); generateMesh(rgn,this.gameObject,ref rgn.data); //hilightRegion(rgn,Color.blue,1.0f); } } //Region chunk=getChunk (this.gameObject, viewRX, viewRY, viewRZ); //if(chunk!=null && chunk.data!=null){ // modifyChunk(ref chunk.data,ref chunk.origin); // generateMesh(ref chunk,this.gameObject,ref chunk.data); // Debug.Log ("Rebuilt chunk:"+chunk.key); //} }
/// <summary> /// Split a tetrahedron to two tetra parts (fragments). You can invoke TetraPart.Append to merge these fragments. /// </summary> /// <param name="plane"></param> /// <param name="part1"></param> /// <param name="part2"></param> public void Split(Plane plane, out TetraPart part1, out TetraPart part2) { part1 = new TetraPart(); part2 = new TetraPart(); Vector3 P = plane.point; Vector3 normal = plane.normal; List <Vector3> intersections = new List <Vector3>(); Vector3 intersection; int[] segments = { 0, 1, 0, 2, 0, 3, 1, 2, 1, 3, 2, 3 }; for (int j = 0; j < 6; j++) { Vector3 vertex1 = tetra[segments[2 * j]]; Vector3 vertex2 = tetra[segments[2 * j + 1]]; if (ToolFunction.IntersectionForSegmentWithPlane(vertex1, vertex2, P, normal, out intersection)) { intersections.Add(intersection); } } switch (intersections.Count) { case 0: // no intersections. Ignore. part1.PushBackTetra(tetra); return; case 1: intersection = intersections[0]; // 1 intersection (not including two vertices) int pindex = 0, nindex = 0; List <int> remains = new List <int>(); for (int i = 0; i < 4; i++) { Vector3 v = tetra[i]; if (Vector3.Dot(v - intersection, normal) > 0) { pindex = i; } else if (Vector3.Dot(v - intersection, normal) < 0) { nindex = i; } else { remains.Add(i); } } part1.PushBackTetra(new List <Vector3> { tetra[pindex], tetra[remains[0]], tetra[remains[1]], intersection }); part2.PushBackTetra(new List <Vector3> { tetra[nindex], tetra[remains[0]], tetra[remains[1]], intersection }); break; case 2: intersection = intersections[0]; List <int> nindices = new List <int>(); List <int> pindices = new List <int>(); int remainIndex = 0; for (int i = 0; i < 4; i++) { Vector3 v = tetra[i]; if (Vector3.Dot(v - intersection, normal) > 0) { pindices.Add(i); } else if (Vector3.Dot(v - intersection, normal) < 0) { nindices.Add(i); } else { remainIndex = i; } } if (pindices.Count == 2) { part1.PushBackPyramid(new List <Vector3> { tetra[remainIndex], intersections[0], intersections[1], tetra[pindices[0]], tetra[pindices[1]] }); part2.PushBackTetra(new List <Vector3> { tetra[remainIndex], intersections[0], intersections[1], tetra[nindices[0]] }); } else { part2.PushBackPyramid(new List <Vector3> { tetra[remainIndex], intersections[0], intersections[1], tetra[nindices[0]], tetra[nindices[1]] }); part1.PushBackTetra(new List <Vector3> { tetra[remainIndex], intersections[0], intersections[1], tetra[pindices[0]] }); } break; case 3: intersection = intersections[0]; nindices = new List <int>(); pindices = new List <int>(); for (int i = 0; i < 4; i++) { Vector3 v = tetra[i]; if (Vector3.Dot(v - intersection, normal) > 0) { pindices.Add(i); } else if (Vector3.Dot(v - intersection, normal) < 0) { nindices.Add(i); } } if (pindices.Count == 3) { part1.PushBackTriPrism(new List <Vector3> { intersections[0], intersections[1], intersections[2], tetra[pindices[0]], tetra[pindices[1]], tetra[pindices[2]] }); part2.PushBackTetra(new List <Vector3> { intersections[0], intersections[1], intersections[2], tetra[nindices[0]] }); } else { part2.PushBackTriPrism(new List <Vector3> { intersections[0], intersections[1], intersections[2], tetra[nindices[0]], tetra[nindices[1]], tetra[nindices[2]] }); part1.PushBackTetra(new List <Vector3> { intersections[0], intersections[1], intersections[2], tetra[pindices[0]] }); } break; case 4: intersection = intersections[0]; nindices = new List <int>(); pindices = new List <int>(); for (int i = 0; i < 4; i++) { Vector3 v = tetra[i]; if (Vector3.Dot(v - intersection, normal) > 0) { pindices.Add(i); } else { nindices.Add(i); } } part1.PushBackTriPrism(new List <Vector3> { intersections[0], intersections[1], intersections[2], intersections[3], tetra[pindices[0]], tetra[pindices[1]] }); part2.PushBackTriPrism(new List <Vector3> { intersections[0], intersections[1], intersections[2], intersections[3], tetra[nindices[0]], tetra[nindices[1]] }); break; } }
/// <summary> /// Add a triangular prism (6 vertices and 5 planes) to this fragment. /// </summary> /// <param name="triPrism">Triangular prism given.</param> public void PushBackTriPrism(List <Vector3> triPrism) { if (triPrism.Count != 6) { return; } List <int> plane1 = new List <int>(), plane2 = new List <int>(); int times = 0; for (int i1 = 0; i1 < 6; i1++) { for (int i2 = i1 + 1; i2 < 6; i2++) { for (int i3 = i2 + 1; i3 < 6; i3++) { for (int i4 = i3 + 1; i4 < 6; i4++) { if (ToolFunction.IsCoplanar(triPrism[i1], triPrism[i2], triPrism[i3], triPrism[i4])) { times++; if (times == 1) { plane1.AddRange(new int[] { i1, i2, i3, i4 }); } else { plane2.AddRange(new int[] { i1, i2, i3, i4 }); goto out_loop; } } } } } } out_loop: List <int> intersect = new List <int>(); foreach (int i in plane1) { if (plane2.Contains(i)) { intersect.Add(i); plane2.Remove(i); } } foreach (int i in intersect) { plane1.Remove(i); } // For ABC-DEF // vertices1: ADEB List <Vector3> vertices1 = ToolFunction.SortConvexPolygon(new List <Vector3> { triPrism[intersect[0]], triPrism[intersect[1]], triPrism[plane1[0]], triPrism[plane1[1]] }); // vertices2: ADFC List <Vector3> vertices2 = ToolFunction.SortConvexPolygon(new List <Vector3> { triPrism[intersect[0]], triPrism[intersect[1]], triPrism[plane2[0]], triPrism[plane2[1]] }); // tetra F-ABC PushBackTetra(new List <Vector3> { vertices2[2], vertices1[0], vertices1[3], vertices2[3] }); // tetra F-ABE PushBackTetra(new List <Vector3> { vertices2[2], vertices1[0], vertices1[3], vertices1[2] }); // tetra F-ADE PushBackTetra(new List <Vector3> { vertices2[2], vertices1[0], vertices1[1], vertices1[2] }); }
void modifyRegion(Region rgn,Vector3 origin,float editRadius,float targDelta,ToolFunction tool) { int cbase=0; //ox+oy+oz; //cbase*=2; float er2 = editRadius*editRadius; for (int rx=0; rx<=chunkDim+2; rx++){ int cplane=cbase; for (int ry=0; ry<=chunkDim+2; ry++){ int cidx=cplane; for (int rz=0; rz<=chunkDim+2; rz++) { Vector3 pos=rgn.data[cidx].position+rgn.origin; Vector3 dlt=pos-origin; float d=rgn.data[cidx].density = tool(dlt,rgn.data[cidx].density,editRadius,er2,targDelta); //if(d>0.5f) // rgn.data[cidx].material.x=1.5f; cidx+=oz; } cplane+=oy; } cbase+=ox; } }