コード例 #1
0
ファイル: FireCaster.cs プロジェクト: bradur/Alakajam5
    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);
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        rb = gameObject.GetComponent <Rigidbody2D>();

        audioSource       = gameObject.GetComponent <AudioSource>();
        gunfire           = gameObject.transform.Find("Gunfire").GetComponent <UnityEngine.Experimental.Rendering.Universal.Light2D>();
        torchCollider     = gameObject.transform.Find("Torch").GetComponent <TorchCollider>();
        rb.freezeRotation = true;
        startPos          = transform.position;
        playerAnimator    = gameObject.GetComponent <Animator>();

        torchInnerRadius = torch.pointLightInnerRadius;
        torchOuterRadius = torch.pointLightOuterRadius;
        torchInnerAngle  = torch.pointLightInnerAngle;
        torchOuterAngle  = torch.pointLightOuterAngle;
    }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        joint             = gameObject.GetComponent <DistanceJoint2D>();
        gm                = GameObject.Find("GameManager").GetComponent <GameManager>();
        rb                = gameObject.GetComponent <Rigidbody2D>();
        torch             = gameObject.transform.Find("Torch").GetComponent <UnityEngine.Experimental.Rendering.Universal.Light2D>();
        torchCollider     = gameObject.transform.Find("Torch").GetComponent <TorchCollider>();
        rb.freezeRotation = true;
        powerUpSpriteMask = gameObject.transform.Find("PowerUpSpriteMask");
        startPos          = transform.position;
        joint.enabled     = false;


        torchInnerRadius = torch.pointLightInnerRadius;
        torchOuterRadius = torch.pointLightOuterRadius;
        torchInnerAngle  = torch.pointLightInnerAngle;
        torchOuterAngle  = torch.pointLightOuterAngle;
    }
コード例 #4
0
ファイル: FireCaster.cs プロジェクト: bradur/Alakajam5
 void ExtinguishOrLightFire()
 {
     previouslyHitTorch = null;
     CheckFirePossibilities();
     if (targetFireSource != null)
     {
         if (targetFireSource.IsLit)
         {
             targetFireSource.Extinguish();
             AudioManager.main.PlaySound(SoundType.Extinguish);
             playerHandConfig.triggerGrab = true;
         }
         else
         {
             targetFireSource.Light();
             AudioManager.main.PlaySound(SoundType.LightFire);
             playerHandConfig.triggerThrow = true;
         }
     }
 }