public override Vector2 CheckColSquare(TwoColSquare other) { if (!CheckColBounds(other)) { return(Vector2.zero); } Vector2 lineVector = P2 - P1; lineVector.Normalize(); Vector2 toCenter = other.Center - P1; float Rad = 6.0f; float projection = Vector2.Dot(toCenter, lineVector); Vector2 dist = (P1 + projection * lineVector) - other.Center; if (projection > 0.0f && projection < (P2 - P1).magnitude && dist.magnitude < Rad) { return(dist - dist.normalized * Rad); } if ((P1 - other.Center).magnitude < Rad) { return((P1 - other.Center) - (P1 - other.Center).normalized * Rad); } if ((P2 - other.Center).magnitude < Rad) { return((P2 - other.Center) - (P2 - other.Center).normalized * Rad); } return(Vector2.zero); }
public override Vector2 CheckColSquare(TwoColSquare other) { if (!CheckColBounds(other)) { return(Vector2.zero); } float left = Mathf.Abs(other.BL.x - TR.x); float right = Mathf.Abs(other.TR.x - BL.x); float down = Mathf.Abs(other.BL.y - TR.y); float up = Mathf.Abs(other.TR.y - BL.y); if (left <= right && left <= up && left <= down) { return(new Vector2(-left, 0.0f)); } if (right <= left && right <= up && right <= down) { return(new Vector2(right, 0.0f)); } if (up <= right && up <= left && up <= down) { return(new Vector2(0.0f, up)); } if (down <= right && down <= left && down <= up) { return(new Vector2(0.0f, -down)); } return(Vector2.zero); }
// Use this for initialization void Awake() { pCommon = GetComponent <TwoCommon> (); tCol = GetComponent <TwoColSquare> (); tColPhys = GetComponent <TwoColPhysics> (); pGravity = GetComponent <PlatGravity> (); pRamp = GetComponent <PlatPhysRamp> (); pGlobal = StatMini.GetMiniContainer(transform).GetComponent <TwoGlobal> (); input = StatMini.GetMiniContainer(transform).GetComponent <MiniInput> (); }
public override Vector2 CheckColSquare(TwoColSquare other) { return(-other.CheckColCircle(this)); }
public virtual Vector2 CheckColSquare(TwoColSquare other) { return(Vector2.zero); }
// Use this for initialization void Awake() { vl = new VectorLine[2]; col = GetComponents <TwoColLine> (); colSquare = GetComponent <TwoColSquare> (); }
public void OnSceneGUI() { TwoCol myTarget = (TwoCol)target; if (myTarget.GetTypes.Length == 0) { return; } if (myTarget.GetTypes.Length > 1) { Handles.color = UnityEngine.Color.magenta; } if (myTarget.HasType(TwoCol.ColType.COMBAT_DEF)) { Handles.color = UnityEngine.Color.blue; } else if (myTarget.HasType(TwoCol.ColType.COMBAT_OFF)) { Handles.color = UnityEngine.Color.red; } else if (myTarget.HasType(TwoCol.ColType.PHYSICS_DEF)) { Handles.color = UnityEngine.Color.green; } else if (myTarget.HasType(TwoCol.ColType.PHYSICS_OFF)) { Handles.color = UnityEngine.Color.yellow; } else if (myTarget.HasType(TwoCol.ColType.T3_DEF)) { Handles.color = UnityEngine.Color.cyan; } else { Handles.color = UnityEngine.Color.grey; } if (myTarget.GetType() == typeof(TwoColCircle)) { TwoColCircle temp = (TwoColCircle)myTarget; Handles.DrawWireDisc(temp.Center, UnityEngine.Vector3.forward, temp.Rad); } else if (myTarget.GetType() == typeof(TwoColSquare)) { TwoColSquare temp = (TwoColSquare)myTarget; Handles.DrawLine(new UnityEngine.Vector3(temp.BL.x, temp.BL.y, 0.0f), new UnityEngine.Vector3(temp.BL.x, temp.TR.y, 0.0f)); Handles.DrawLine(new UnityEngine.Vector3(temp.BL.x, temp.BL.y, 0.0f), new UnityEngine.Vector3(temp.TR.x, temp.BL.y, 0.0f)); Handles.DrawLine(new UnityEngine.Vector3(temp.TR.x, temp.TR.y, 0.0f), new UnityEngine.Vector3(temp.BL.x, temp.TR.y, 0.0f)); Handles.DrawLine(new UnityEngine.Vector3(temp.TR.x, temp.TR.y, 0.0f), new UnityEngine.Vector3(temp.TR.x, temp.BL.y, 0.0f)); } if (myTarget.GetType() == typeof(TwoColLine)) { TwoColLine temp = (TwoColLine)myTarget; Handles.DrawLine(new UnityEngine.Vector3(temp.P1Draw.x, temp.P1Draw.y, 0.0f), new UnityEngine.Vector3(temp.P2Draw.x, temp.P2Draw.y, 0.0f)); } }