/// <summary> /// 진행 가능 방향 추가 /// </summary> public RF_Linker_Path AddPath()//160624같은 Station에 Path만들때 새로운 Station생기는 문제 해결 { RF_Linker_Path temp_Path = (new GameObject()).AddComponent(typeof(RF_Linker_Path)) as RF_Linker_Path; temp_Path.transform.SetParent(transform); temp_Path.transform.localPosition = Vector3.zero; temp_Path.name = //160623(용준)Station이니까 마지막 글자가 n이면 1번 스테이션으로 간주한다는 거지같은 코드임 transform.name[transform.name.Length - 1] == 'n' ? "Rail_Station1Path" + (transform.childCount - 1) : "Rail_Station" + transform.name[transform.name.Length - 1] + "Path" + (transform.childCount - 1); temp_Path.transform.tag = "RAIL_Path"; return(temp_Path); }
/////////////////////////////////////////////////////////////////////// //###################################################################// //###################################################################// //###################################################################// /////////////////////////////////////////////////////////////////////// //OnSceneGUI() /////////////////////////////////////////////////////////////////////// //###################################################################// //###################################################################// //###################################################################// /////////////////////////////////////////////////////////////////////// //Static //OnSceneGUI() static public void DrawPathTangent(ref RF_Linker_Path _Path) { Handles.color = Color.gray; if (_Path.transform.localPosition != Vector3.zero) { Handles.Slider(_Path.StationPosition, _Path.transform.localPosition); Handles.DrawLine(_Path.StationPosition, _Path.transform.position); } if (_Path.Next.transform.localPosition != Vector3.zero) { Handles.Slider(_Path.Next.StationPosition, _Path.Next.transform.localPosition); Handles.DrawLine(_Path.Next.StationPosition, _Path.Next.transform.position); } }
static public void DrawPathLine(ref RF_Linker_Path _Path, DrawMode _mode) { if (DrawMode.Straight != _mode && _Path.IsCurve) { DrawBezierCurve(ref _Path, _mode); } else { if (DrawMode.Straight != _mode) { Handles.color = Color.yellow; } else { Handles.color = Color.white; } Handles.DrawDottedLine(_Path.StationPosition, _Path.Next.StationPosition, ConstValue.DotLineGap); } }
private void Action() { if (!CurrentPath) { return; } ElapsedTime += Time.deltaTime; NormalScalar = ElapsedTime * MultiplyValue * Speed; transform.position = CurrentPath.PathIntrpPoint(NormalScalar); if (NormalScalar >= 1 || MultiplyValue <= 0) { CurrentStation = CurrentPath.Next.BelongStation; CurrentPath = null; InAction = false; } }
static private void DrawBezierCurve(ref RF_Linker_Path _Path, DrawMode _mode) { Handles.color = Color.yellow; Vector3 lineStart = _Path.PathIntrpPoint(0.0f); for (int i = 1; i <= ConstValue.BezierCurvePrecisionStep; i++) { Vector3 lineEnd = _Path.PathIntrpPoint(i * ConstValue.BezierCurvePrecision); Handles.DrawDottedLine(lineStart, lineEnd, ConstValue.DotLineGap); lineStart = lineEnd; } if (DrawMode.Bezier == _mode) { Handles.DrawBezier( _Path.StationPosition , _Path.Next.StationPosition , _Path.transform.position , _Path.Next.transform.position , Color.green, null, 1 ); } }
private void SetRail(RF_Linker_Path _path) { CurrentPath = _path; Debug.Log("PathLength : " + CurrentPath.PathLength); if (CurrentPath.PathLength == 0) { MultiplyValue = 0; } else { MultiplyValue = 1 / CurrentPath.PathLength; } ElapsedTime = 0; if (Speed <= 0) { CurrentPath = null; } else { InAction = true; } }
static private void DrawPathName(ref RF_Linker_Path _Path, string _str) { Handles.Label( _Path.StationPosition + _Path.NextPathDirection * 0.5f , _str, StaticValue.LabelStyle); }