public void PointInDirection(Vector2 center, ref DashPointData data) { RotateTowards(data.NormalizedDirection); MoveToPosition(center, data.NormalizedDirection); SetDissolveValue(FindDissolveValue(ref data)); StartCoroutine(ArcRender(data)); }
public TrajectoryArcRender OnInstantiate(Vector3 pos, DashPointData data, Transform parent) { var ar = Instantiate(this, parent); ar.ResetPos(pos); return(ar); }
private void onDashCollision(GameObject collision) { currentDashObject = collision.GetComponent <BaseDashObject>(); dashData = currentDashObject.GetData(); Prepare(); ResetForce(); NullifyGravity(); }
public void OnInstantiate(Renderer parent, ref DashPointData data) { minDistance = FindMinDist(parent); arrowTipDis = FindRenderTipDistance(); //Half of the biggest side to get the tip of the arrow, then a number to how far away from the tip is the 0 point powerMinDistance = FindRenderTipDistance() + zeroPoint; Vector2 center = parent.transform.position; PointInDirection(center, ref data); }
private IEnumerator ArcRender(DashPointData data) { if (arcRender == null) { arcRender = arcRenderPrefab.OnInstantiate(FindArcRenderStartPos(data), data, transform); } arcRender.ResetPos(FindArcRenderStartPos(data)); yield return(new WaitForEndOfFrame()); arcRender.RenderArc(data); }
/// <summary> /// Uses the max and min powerdistance, and distance to mouse to take percentage of Force and find how big the arrow fill should be /// </summary> /// <param name="data"></param> /// <returns></returns> private float FindDissolveValue(ref DashPointData data) { var powerLevel = DistanceToMouse() - powerMinDistance; if (powerLevel >= powerMaxDistance) { data.Force = data.MaxForce; return(0.01f); } if (powerLevel <= 0) { data.Force = data.MinForce; return(1f); } var percentage = (powerLevel / powerMaxDistance); data.Force = data.MaxForce * percentage; return(data.Force.Remap(data.MinForce, data.MaxForce, 1, 0.01f)); }
public override void DashFromObject(DashPointData data) { base.DashFromObject(data); currentDashObject.ObjectDash(data.ReverseDirection()); }
private Vector3 FindArcRenderStartPos(DashPointData data) { return((Vector2)transform.position + (data.NormalizedDirection * arrowTipDis)); }
/// <summary> /// When the player collides with DashObject, the player gets data /// </summary> public override DashPointData GetData() { var dashData = new DashPointData(standardForce.force, Vector2.up, standardGravity.gravity); return(dashData); }
/// <summary> /// Used to dash from objects /// </summary> public override void ObjectDash(DashPointData data) { DashFromObject(data); }
public virtual void DashFromObject(DashPointData data) { SetGravity(data.GravityScale); Dash(data.Force, data.NormalizedDirection, ForceMode2D.Impulse); Unsubscribe(); }
public void RenderArc(DashPointData data) { StartRender(); DashFromObject(data); }
/// <summary> /// Used to dash from objects /// </summary> public abstract void ObjectDash(DashPointData data);