private void PullBack() { //_floaterLine.Release(); _switch.TurnOnWalkCamera(); _currentFloater.ReleaseFish(); if (_currentFloater != null) { //_floaterLine.PullLine(5); LeanTween.move(_currentFloater.gameObject, _floaterLine.transform, 0.2f). setOnStart(OnStart). setOnComplete(x => { GameObject.Destroy(_currentFloater.gameObject); _currentFloater = Instantiate(_floaterPrefab, _floaterLine.transform.position, _floaterLine.transform.rotation); _floaterLine.NewTarget(_currentFloater.transform); }); } void OnStart() { _floaterLine.NewLine(_currentFloater.transform, 0.9f, true); } }
/// <summary> /// Validates the current point and casts the line if possible. /// </summary> /// <returns> True if the line was cast, false otherwise</returns> private bool ValidatePoint() { var result = Physics.OverlapSphere(_point, .5f, _checkMask); FishingArea area; foreach (Collider col in result) { if (col.TryGetComponent <FishingArea>(out area)) { if (_currentFloater) { Destroy(_currentFloater.gameObject); } // Create and throw a new floater. _currentFloater = Instantiate(_floaterPrefab, _floaterLine.transform.position, _floaterLine.transform.rotation); Debug.Log(_point); _currentFloater.Cast(area, _point, OnFail); _floaterLine.NewLine(_currentFloater.transform, 0.9f); _switch.TurnOnFishingCamera(_currentFloater.transform); Casted = true; return(true); } } _throwStrength = 0; return(false); }
public void NewLine(Transform target, float customDampening = 0.0f, bool hang = false) { _hang = hang; _floaterPos = target; EndPoint = target; Floater tempF = _floaterPos.GetComponent <Floater>(); // Calculate line distance via hypotenuse with player height if (hang) { _resolution = _retractedResolution; } else { Vector3 groundPos = transform.position; groundPos.y = tempF.Point.y; float a = Vector3.Distance(tempF.Point, groundPos); float b = transform.position.y; _resolution = Mathf.FloorToInt(Mathf.Sqrt((a * a) + (b * b))); _resolution *= 2; _resolution += 2; } Debug.Log(_resolution); _points = new VerletLinePoint[_resolution]; if (!_line) { gameObject.AddComponent <LineRenderer>(); _line = GetComponent <LineRenderer>(); } _line.material = _lineMaterial; _line.startWidth = .02f; _line.endWidth = .02f; _line.SetPosition(0, transform.position); _line.positionCount = _resolution; InitRope(); if (customDampening != 0.0f) { StartCoroutine(LerpDampening(customDampening)); } else { StartCoroutine(LerpDampening(_dampeningAmount)); } }