Beispiel #1
0
 private void CheckDeath()
 {
     if (LightManager.GetClosestLightDistanceToPosition(transform.position) < deathRadius)
     {
         Destroy(gameObject);
     }
 }
 public static void CheckMonsterDestory(GameObject m)
 {
     if (LightManager.GetClosestLightDistanceToPosition(m.transform.position) < destroyDistance)
     {
         Destroy(m);
     }
 }
Beispiel #3
0
    private bool IsMovePositionValid(Vector3 targetPosition)
    {
        // Check the target vector for light
        if (LightManager.GetClosestLightDistanceToPosition(targetPosition) < fleeRadius)
        {
            return(false);
        }

        // Check for something in between
        Vector3 raySource = new Vector3(transform.position.x, 1.0f, transform.position.z);
        Vector3 rayTarget = new Vector3(targetPosition.x, 1.0f, targetPosition.z);
        Vector3 rayVector = rayTarget - raySource;

        if (Physics.Raycast(raySource, rayVector.normalized, rayVector.magnitude))
        {
            return(false);
        }

        // Check all the steps in between for light
        targetPosition.y = 0.0f;
        Vector3 moveVector    = targetPosition - transform.position;
        Vector3 moveDirection = moveVector.normalized;
        float   moveDistance  = moveVector.magnitude;

        for (float checkDistance = 2.0f; checkDistance < moveDistance; checkDistance = checkDistance + 2.0f)
        {
            Vector3 newPosition = moveDirection * checkDistance;
            if (LightManager.GetClosestLightDistanceToPosition(newPosition) < deathRadius)
            {
                return(false);
            }
        }
        return(true);
    }