コード例 #1
0
    override public void Execute()
    {
        // if I collided with someone, it means my other is someone
        // destroy my other
        hasCollided ch = this.gameObject.GetComponentInParent <hasCollided>();

        if (ch != null)
        {
            GameObject otherObj = ch.other;
            if (otherObj != null)
            {
                Destroy(otherObj);
            }
        }
    }
コード例 #2
0
    public void OnCollisionEnter(Collision other)
    {
        Debug.Log("collided with " + other.gameObject.name);

        // both parties' other needs to be recorded
        hasCollided hc = this.gameObject.AddComponent <hasCollided> ();

        if (hc != null)
        {
            hc.other = other.gameObject;
        }

        hasCollided hcOther = other.gameObject.AddComponent <hasCollided> ();

        if (hcOther != null)
        {
            hcOther.other = this.gameObject;
        }
    }
コード例 #3
0
    override public bool Eval()
    {
        bool rval = false;

        if (ch == null)
        {
            if (recipient != null)
            {
                ch = recipient.GetComponent <CollisionHelper> ();
            }
        }

        // check for presence of hasCollided flag
        if (ch != null)
        {
            hasCollided hc = recipient.GetComponent <hasCollided> ();
            if (hc != null)
            {
                rval = true;
            }
        }

        return(rval);
    }