コード例 #1
0
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.collider.tag == "DynamicParticle")
        {
            DynamicParticle dynPart = other.collider.GetComponent <DynamicParticle>();

            if (dynPart.currentState == DynamicParticle.STATES.WATER && colliders.Length >= numOfWaterParticles && heatAndCool != HeatAndCool.Cold)
            {
                heatAndCool = HeatAndCool.Cooling;
            }
        }
    }
コード例 #2
0
    void MoreHot()
    {
        //color.r += heatAndCoolFraction;
        //spriteRend.material.color = color;

        color            = Color.Lerp(color, Color.red, Mathf.PingPong(Time.deltaTime * 0.5f, 1));
        spriteRend.color = color;

        if (color.b <= 0.1f && color.g <= 0.1f)
        {
            heatAndCool = HeatAndCool.Hot;
        }
    }
コード例 #3
0
    void MoreCold()
    {
//		if(color.r > 0)
//		{
//			Debug.Log ("COOOLING");
//			color.r -= heatAndCoolFraction;
//			spriteRend.material.color = color;
//		}
        color            = Color.Lerp(color, Color.white, Mathf.PingPong(Time.deltaTime * 0.5f, 1));
        spriteRend.color = color;

        if (color.b >= 0.90f && color.g >= 0.90f)
        {
            heatAndCool = HeatAndCool.Cold;
        }
    }
コード例 #4
0
    void Update()
    {
        colliders = Physics2D.OverlapAreaAll(pointA, pointB, collisionMask);

        if (colliders.Length < numOfWaterParticles && heatAndCool != HeatAndCool.Hot && heatAndCool != HeatAndCool.Cold)
        {
            heatAndCool = HeatAndCool.Heating;
        }

        switch (heatAndCool)
        {
        case HeatAndCool.Hot:
            gameObject.tag = "blackBox";
            //deadly = true;
            color            = new Color(1f, 0.4f, 0f);
            spriteRend.color = color;

            //Debug.Log("isHot");
            break;

        case HeatAndCool.Heating:
            MoreHot();
            //Debug.Log("isHeating");
            break;

        case HeatAndCool.Cooling:
            gameObject.tag = "Untagged";
            MoreCold();
            //Debug.Log("isCooling");
            break;

        case HeatAndCool.Cold:
            gameObject.tag = "Untagged";
            //deadly = false;
            tempWaitTime    -= Time.deltaTime;
            color            = new Color(0.7f, 0.9f, 1f);
            spriteRend.color = color;

            if (tempWaitTime <= 0)
            {
                heatAndCool  = HeatAndCool.Heating;
                tempWaitTime = waitTime;
            }
            //Debug.Log("isCold");
            break;
        }
    }