public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (script.movement != null)
        {
            GUI.enabled = false;
            EditorGUILayout.FloatField("movement.moveSpeed", script.movement.moveSpeed);

            string points = "";
            script.points.ForEach(p => {
                points += p.name + (p == script.point ? " (current)" : "") + "\n";
            });

            if (points.Length == 0)
            {
                points = "(none)";
            }

            EditorGUILayout.LabelField("points", points);


            // Find the closest one
            Closest <PushingPoint> closest = PushingPoint.GetClosest(script.points, script.controller.characterCenter, script.interaction.ignoreYAxis);

            if (closest.valid)
            {
                EditorGUILayout.LabelField("closest", closest.obj.name);
            }

            GUI.enabled = true;
        }
    }
Beispiel #2
0
 public bool IsPointInRange(PushingPoint point)
 {
     if (point == null)
     {
         return(false);
     }
     return((point.playerPos - transform.position).magnitude < breakDist);
 }
Beispiel #3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Push point")
     {
         PushingPoint point = other.GetComponent <PushingPoint>();
         if (point != null && !points.Contains(point))
         {
             points.Add(point);
         }
     }
 }
    /// <summary>
    /// Try to grab a pushing point.
    /// </summary>
    public void TryToGrab()
    {
        // Error checking
        if (hasPoint) return;
        if (!movement.grounded) return;

        // Find the closest one
        PushingPoint closest = GetClosestPoint();

        if (IsPointInRange(closest))
            point = closest;
    }
Beispiel #5
0
 void OnPointChange(PushingPoint old)
 {
     // Toggle isKinematic
     if (old)
     {
         old.body.isKinematic = true;
     }
     if (hasPoint)
     {
         point.body.isKinematic = false;
     }
 }
Beispiel #6
0
 void OnTriggerExit(Collider other)
 {
     if (other.tag == "Push point")
     {
         PushingPoint point = other.GetComponent <PushingPoint>();
         if (point != null)
         {
             int index = points.IndexOf(point);
             if (index >= 0)
             {
                 points.RemoveAt(index);
             }
         }
     }
 }
Beispiel #7
0
    /// <summary>
    /// Try to grab a pushing point.
    /// </summary>
    public void TryToGrab()
    {
        // Error checking
        if (hasPoint)
        {
            return;
        }
        if (!movement.grounded)
        {
            return;
        }

        // Find the closest one
        PushingPoint closest = GetClosestPoint();

        if (IsPointInRange(closest))
        {
            point = closest;
        }
    }
Beispiel #8
0
    PushingPoint GetClosestPoint()
    {
        if (hasPoint)
        {
            return(null);
        }
        if (inventory && inventory.equipped)
        {
            return(null);
        }
        if (interaction && interaction.hover)
        {
            return(null);
        }

        // Remove all invalid points. If for some reason they occur.
        points.RemoveAll(p => p == null);
        // Find the closest one
        Closest <PushingPoint> closest = PushingPoint.GetClosest(points, transform.position, interaction.ignoreYAxis);

        return(closest.obj);
    }
 public bool IsPointInRange(PushingPoint point)
 {
     if (point == null) return false;
     return (point.playerPos - transform.position).magnitude < breakDist;
 }
    void Update()
    {
        // Check if outside breaking distance (on the Y axis)
        if (!IsPointInRange(point)) {
            point = null;
        }

        // Visualization
        var closest = GetClosestPoint();
        PushingHighlight hover = IsPointInRange(closest) ? closest.highlight : null;

        if (hover != lastHover) {
            // Hover changed
            if (hover) hover.SetHighlightActive(true);
            if (lastHover) lastHover.SetHighlightActive(false);
        }
        lastHover = hover;
    }
 void OnPointChange(PushingPoint old)
 {
     // Toggle isKinematic
     if (old)
         old.body.isKinematic = true;
     if (hasPoint)
         point.body.isKinematic = false;
 }