/* * FUNCTION: Get the CP transforms of the currently active patch and store them in array. * USED BY: PatchesRandomizer.Start() */ public void SetCurrentPatchCPs() { CurrentAngle = 90.0f; tCPsGroup = goCPsGroup.transform; PathLineDrawerCS lineDrawer = ((PathLineDrawerCS)tCPsGroup.GetComponent(typeof(PathLineDrawerCS))); fPathLength = lineDrawer.fPathLength; CPPositions = new Vector3[lineDrawer.Parameterized_CPPositions.Length]; Matrix4x4 mat = new Matrix4x4(); mat.SetTRS(new Vector3(0, 0, 0), hPatchesRandomizerCS.getCurrentPatch().transform.rotation, new Vector3(1, 1, 1)); for (int i = 0; i < CPPositions.Length; i++) { //CPPositions[i] = lineDrawer.Parameterized_CPPositions[i]; CPPositions[i] = lineDrawer.Parameterized_CPPositions[i]; //CPPositions[i].x ;//+ fTotalLength;//PatchNumber * defaultPathLength; CPPositions[i] = mat.MultiplyVector(CPPositions[i]) + lineDrawer.pos; } fTotalLength += hPatchesRandomizerCS.getPatchSize(hPatchesRandomizerCS.getCurrentPatch()); PatchNumber++; }
public Vector3 getOriginCPStartPosition(GameObject obj) { PathLineDrawerCS ptr = (PathLineDrawerCS)(obj.GetComponentInChildren <PathLineDrawerCS>()); return(ptr.Parameterized_CPPositions[1]); //CPPositions = new Vector3[((PathLineDrawerCS)tCPsGroup.GetComponent(typeof(PathLineDrawerCS))).Parameterized_CPPositions.Length]; //return new Vector3(); }
public Vector3 getCPFinishPosition(GameObject obj) { Matrix4x4 mat = new Matrix4x4(); mat.SetTRS(new Vector3(0, 0, 0), obj.transform.rotation, new Vector3(1, 1, 1)); PathLineDrawerCS ptr = (PathLineDrawerCS)(obj.GetComponentInChildren <PathLineDrawerCS>()); return(mat.MultiplyVector(ptr.Parameterized_CPPositions[ptr.Parameterized_CPPositions.Length - 2]) + ptr.pos); }
/* * FUNCTION: Get the CP transforms of the next active patch and store them in array. * USED BY: PatchesRandomizer.Start() */ public void SetNextPatchCPs() { tNextCPsGroup = goNextCPsGroup.transform; PathLineDrawerCS lineDrawer = ((PathLineDrawerCS)tNextCPsGroup.GetComponent(typeof(PathLineDrawerCS))); fNextPathLength = lineDrawer.fPathLength; NextCPPositions = new Vector3[lineDrawer.Parameterized_CPPositions.Length]; Matrix4x4 mat = new Matrix4x4(); mat.SetTRS(new Vector3(0, 0, 0), hPatchesRandomizerCS.getNextPatch().transform.rotation, new Vector3(1, 1, 1)); for (int i = 0; i < NextCPPositions.Length; i++) { //NextCPPositions[i] = lineDrawer.Parameterized_CPPositions[i]; NextCPPositions[i] = lineDrawer.Parameterized_CPPositions[i]; //+ fTotalLength;//PatchNumber * defaultPathLength; NextCPPositions[i] = mat.MultiplyVector(NextCPPositions[i]) + lineDrawer.pos; } }
// Use this for initialization void Start() { bMoving = false; hCheckPointsMainCS = (CheckPointsMainCS)GameObject.Find("Player").GetComponent(typeof(CheckPointsMainCS)); hPatchesRandomizerCS = (PatchesRandomizerCS)GameObject.Find("Player").GetComponent(typeof(PatchesRandomizerCS)); if (this.transform.parent.parent == null) { hPathLineDrawerCS = (PathLineDrawerCS)this.transform.parent.GetComponentInChildren(typeof(PathLineDrawerCS)); patch = this.transform.parent.gameObject; } else { hPathLineDrawerCS = (PathLineDrawerCS)this.transform.parent.parent.GetComponentInChildren(typeof(PathLineDrawerCS)); patch = this.transform.parent.parent.gameObject; } fSpeedPercent = fSpeed / hPathLineDrawerCS.fPathLength; isNext = patch == hPatchesRandomizerCS.getNextPatch(); isFirst = patch == hPatchesRandomizerCS.getCurrentPatch(); Vector3 pos; if (isNext) { pos = hCheckPointsMainCS.getNextWSPointBasedOnPercent(fPercent); fAngle = hPatchesRandomizerCS.getNextPatch().transform.eulerAngles.y; } else { pos = hCheckPointsMainCS.getCurrentWSPointBasedOnPercent(fPercent); fAngle = hPatchesRandomizerCS.getCurrentPatch().transform.eulerAngles.y; } offset = this.transform.position - pos; }
public Vector3 getOriginCPFinishPosition(GameObject obj) { PathLineDrawerCS ptr = (PathLineDrawerCS)(obj.GetComponentInChildren <PathLineDrawerCS>()); return(ptr.Parameterized_CPPositions[ptr.Parameterized_CPPositions.Length - 2]); }