예제 #1
0
    // Update is called once per frame
    IEnumerator torchLightRefill(GameObject collided)
    {
        //yield on a new YieldInstruction that waits for 5 seconds.
        yield return(new WaitForSeconds(timeBetweenRefills));

        //Code to be used to detect both playload and player
        if (false)
        {
            print("This is placeholder code");
        }

        else
        {
            string       childName     = collided.name + "Torch";
            Light2D      collidedTorch = collided.transform.Find(childName).GetComponent <Light2D>();
            GenericTorch torchInfo     = collided.transform.Find(childName).GetComponent <GenericTorch>();

            if (collidedTorch.pointLightOuterRadius < torchInfo.torchRangeMax && torchLight2D.pointLightOuterRadius - refillAmount > minimumLight)
            {
                if (collidedTorch.pointLightOuterRadius + refillAmount > 3)
                {
                    collidedTorch.pointLightOuterRadius = torchInfo.torchRangeMax;
                }
                else
                {
                    collidedTorch.pointLightOuterRadius += refillAmount;
                }
                torchLight2D.pointLightOuterRadius -= refillAmount;
                torchCircleCollider2D.radius       -= refillAmount;
            }
        }

        inumFinished = false;
    }
예제 #2
0
    IEnumerator takeDamage(GameObject collided)
    {
        //yield on a new YieldInstruction that waits for 5 seconds.

        animator.SetBool("isAttacking", true);

        string       childName     = collided.name + "Torch";
        Light2D      collidedTorch = collided.transform.Find(childName).GetComponent <Light2D>();
        GenericTorch torchInfo     = collided.transform.Find(childName).GetComponent <GenericTorch>();

        collidedTorch.pointLightOuterRadius -= enemyDamage;

        yield return(new WaitForSeconds(timeBetweenAttacks));

        inumFinished = false;

        animator.SetBool("isAttacking", false);
    }