private void StMove() { // If right Click exit state if (Input.GetMouseButtonDown(1)) { EndStMove(); return; } // Draw Path Vector3 pnt = Camera.main.ScreenToWorldPoint(Input.mousePosition); pnt.z = transform.position.z; // Set Z Ray2D dir = mCmds.FinalDir(new Ray2D(transform.position, transform.up)); float timeLeft = mCmds.TimeLeft; mCursorGhost.SetActive(true); mCursorGhost.GetComponent <SpriteRenderer>().color = Color.red - new Color(0, 0, 0, .7f); Path curPath = null; // Min Move Distance or Back Half if (Trig.GetHalf(dir, pnt, 0, 0) == Trig.Half.back || Vector3.Distance(dir.origin, pnt) < GameManager.MOVE_MIN_PNT_DIST) { } // Line if within Line tolerance, or within min straight distance of start else if (Trig.DistToLine(dir, pnt) < GameManager.MOVE_LINE_TOL || Vector2.Distance(dir.origin, Trig.NearestPointOnLine(dir, pnt)) < GameManager.MOVE_MIN_ARC_DIST) { curPath = new LinePath(dir, pnt); } // Else Arc else { curPath = new ArcPath(dir, pnt); } if (curPath != null) { // Render Stretch(curPath.RenderPoints(), pnt); // Place Ghost mCursorGhost.GetComponent <SpriteRenderer>().color = Color.green - new Color(0, 0, 0, .7f); float ghRot = Vector2.SignedAngle(Vector2.up, curPath.EndDir); mCursorGhost.transform.position = curPath.End; mCursorGhost.transform.rotation = Quaternion.AngleAxis(ghRot, Vector3.forward); } else { Retract(); mCursorGhost.transform.position = pnt; mCursorGhost.transform.rotation = Quaternion.identity; } // If left Click and Path, Add Movement Segment if (curPath != null && Input.GetMouseButtonDown(0)) { if (mCmds.Last()) { mCmds.Last().Hide(false); } mCmds.Add(Draw.MakeMoveCmd(gameObject).Init(curPath, null)); mCmds.Last().Hide(true); MoveGuides(mCmds.FinalDir(new Ray2D(transform.position, transform.up))); mStartMarker.SetActive(true); if (mCmds.TimeLeft < float.Epsilon) { Fin(); EndStMove(); } } }