コード例 #1
0
ファイル: GoalerScript.cs プロジェクト: chrbor/IceCream
    IEnumerator EatIce(IceScript iceScript)
    {
        if (iceScript != null)
        {
            if (iceScript.id > 0)
            {
                iceScript.Get_rb().constraints = RigidbodyConstraints2D.FreezeAll;
                iceScript.gameObject.GetComponent <Collider2D>().enabled = false;
                cone.RemoveIce(iceScript.id);
                iceScript.RemoveFromCone();

                yield return(new WaitForSeconds(.2f));
            }

            progressDisplay.UpdateProgressDisplay(iceScript.Get_attribute());
            anim.SetTrigger("squeesh");
        }
        if (iceScript != null)
        {
            Destroy(iceScript.gameObject);
        }
        yield break;
    }
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Rigidbody2D rb_other = other.GetComponent <Rigidbody2D>();

        if (exclusions.Contains(other.gameObject) || rb_other == null)
        {
            return;
        }

        Vector2 diff       = other.transform.position - transform.position;
        float   distFactor = transform.localScale.x / (2 + diff.sqrMagnitude);

        if (other.GetComponent <IHitable>() != null)
        {
            other.GetComponent <IHitable>().StartPlayHit(other.gameObject); return;
        }

        if (other.gameObject.layer == 8)
        {
            IceScript iceScript = other.GetComponent <IceScript>();
            if (iceScript.id < 0)
            {
                iceScript.Get_attribute().life_current -= distFactor;
            }
            else
            {
                cone.RemoveIce(iceScript.id);
                iceScript.RemoveFromCone();
            }
        }
        else
        {
            distFactor *= rb_other.gravityScale / 2;
        }
        rb_other.velocity += diff * power * distFactor;
    }