Пример #1
0
    void CheckFirePossibilities()
    {
        RaycastHit hit;
        RaycastHit burnHit;
        Vector3    endPoint         = transform.TransformDirection(Vector3.forward);
        bool       rayHitSomething  = CastTorchCheckRay(endPoint, out hit);
        bool       rayHitBurnTarget = CastBurnCheckRay(endPoint, out burnHit);

        if (rayHitSomething && !rayHitBurnTarget)
        {
            //Vector3 point = hit.point;
            targetFireSource = GetInteractableFireSource(hit);
        }
        else if (rayHitSomething && rayHitBurnTarget && burnHit.distance > hit.distance)
        {
            targetFireSource = GetInteractableFireSource(hit);
        }
        else
        {
            if (previouslyHitTorch != null)
            {
                previouslyHitTorch.SetMaterial(fireConfig.TorchDefaultMaterial);
            }
            targetFireSource = null;

            /*Vector3 point = transform.position + transform.forward * fireConfig.MaxDistance;
             * point.y = 0f;*/
        }
        DebugRayCast(hit, rayHitSomething);
    }
Пример #2
0
    FireSource GetInteractableFireSource(RaycastHit hit)
    {
        TorchCollider torch = hit.collider.GetComponent <TorchCollider>();

        if (previouslyHitTorch != null && previouslyHitTorch != torch)
        {
            previouslyHitTorch.SetMaterial(fireConfig.TorchDefaultMaterial);
        }
        if (torch != null)
        {
            if ((!torch.FireSource.IsLit && playerHandConfig.hasFire) || (torch.FireSource.IsLit && !playerHandConfig.hasFire))
            {
                if (hit.distance < fireConfig.MinDistance || !torch.FireSource.Interactable)
                {
                    previouslyHitTorch = torch;
                    torch.SetMaterial(fireConfig.TorchDeniedMaterial);
                    return(null);
                }
                else
                {
                    previouslyHitTorch = torch;
                    torch.SetMaterial(fireConfig.TorchHighlightMaterial);
                    return(torch.FireSource);
                }
            }
        }
        return(null);
    }