Esempio n. 1
0
 private bool GetIsOnLadder()
 {
     if (surfacePoint.otherCollider != null)
     {
         if (isOnValidGround)
         {
             return(false);
         }
     }
     foreach (ContactPoint point in wallPoints)
     {
         if (TagManager.CompareTag("Ladder", point.otherCollider.gameObject))
         {
             if (point.normal.y > 0)
             {
                 ladderNormal = point.normal;
                 return(true);
             }
             else if (Vector3.Angle(point.normal, Vector3.up) < 91f)
             {
                 ladderNormal = point.normal;
                 return(true);
             }
             else
             {
                 ladderNormal = Vector3.zero;
             }
         }
     }
     return(false);
 }
Esempio n. 2
0
 private void InteractInfoManager()
 {
     interactTestTimer += Time.fixedDeltaTime;
     if (interactTestTimer >= interactTestInterval)
     {
         if (grabbedObject == null)
         {
             bool       enableDisplay = false;
             RaycastHit hit;
             if (Physics.Raycast(head.transform.position, head.transform.forward, out hit, interactRange, layermaskInteract))
             {
                 if (TagManager.CompareTag("Interactable", hit.collider.gameObject))
                 {
                     if (hit.collider.gameObject != lastInteractObject)
                     {
                         currentInteractObject = hit.collider.gameObject.GetComponent <IInteractable>();
                     }
                     if (currentInteractObject != null)
                     {
                         gui.SetInteractDisplayMessage(currentInteractObject.GetDescription());
                     }
                     else
                     {
                         gui.SetInteractDisplayMessage(null);
                     }
                     lastInteractObject = hit.collider.gameObject;
                     enableDisplay      = true;
                 }
                 else
                 {
                     if (hit.collider.attachedRigidbody != null)
                     {
                         Rigidbody otherRB = hit.collider.attachedRigidbody;
                         if ((!otherRB.isKinematic) && otherRB.mass <= maxPickupObjectMass)
                         {
                             if (!TagManager.CompareTag("NonGrabbable", hit.collider.gameObject))
                             {
                                 gui.SetInteractDisplayMessage("Pick up");
                                 enableDisplay = true;
                             }
                         }
                     }
                 }
             }
             if (enableDisplay)
             {
                 gui.EnableInteractDisplay();
             }
             else
             {
                 gui.DisableInteractDisplay();
             }
         }
         else
         {
             gui.DisableInteractDisplay();
         }
         interactTestTimer -= interactTestInterval;
     }
 }
Esempio n. 3
0
    private void TryToInteract()
    {
        RaycastHit hit;

        if (Physics.Raycast(head.transform.position, head.transform.forward, out hit, interactRange, layermaskInteract))
        {
            if (TagManager.CompareTag("Interactable", hit.collider.gameObject))
            {
                currentInteractObject = hit.collider.gameObject.GetComponent <IInteractable>();
                if (currentInteractObject != null)
                {
                    currentInteractObject.Interact(this.gameObject);
                }
                else
                {
                    Debug.LogError(hit.collider.gameObject + " has no <IInteractable> but is supposed to. Message from PlayerView > Update");
                }
            }
            else if (grabbedObject == null && hit.collider.attachedRigidbody != null)
            {
                Rigidbody otherRB = hit.collider.attachedRigidbody;
                if ((!otherRB.isKinematic) && otherRB.mass <= maxPickupObjectMass)
                {
                    if (!TagManager.CompareTag("NonGrabbable", hit.collider.gameObject))
                    {
                        GrabObject(hit.collider.gameObject);
                    }
                }
            }
        }
    }
Esempio n. 4
0
 void Start()
 {
     if (!TagManager.CompareTag("Water", this.gameObject))
     {
         throw new MissingComponentException("the gameobject <" + this.gameObject.name + "> needs to be tagged \"Water\"");
     }
     rigidbodiesInWater = new List <Rigidbody>();
 }
Esempio n. 5
0
 bool IsGrabbable(Rigidbody otherRB)
 {
     if (otherRB != null)
     {
         bool kinematic          = otherRB.isKinematic;
         bool massOK             = (otherRB.mass <= grabbedObjectMaxMass);
         bool taggedNonGrabbable = TagManager.CompareTag("NonGrabbable", otherRB.gameObject);
         return(!kinematic && massOK && !taggedNonGrabbable);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 6
0
 bool GetIsOnLadder(List <ContactPoint> wallPoints, out SurfacePoint ladderPoint)
 {
     for (int i = 0; i < wallPoints.Count; i++)
     {
         ContactPoint point = wallPoints[i];
         if (TagManager.CompareTag("Ladder", point.otherCollider.gameObject))
         {
             float ladderAngle = Vector3.Angle(point.normal, rb.transform.up);
             if (ladderAngle < 91f)
             {
                 ladderPoint = new SurfacePoint(point, rb.transform.up);
                 return(true);
             }
         }
     }
     ladderPoint = null;
     return(false);
 }