コード例 #1
0
    void OnTriggerEnter2D(Collider2D othercollider)
    {
        //executed when another triggercollider is touching

        myProperties otherproperties = othercollider.gameObject.GetComponent <myProperties> ();

        //if you walk into a player, it hurts
        if (otherproperties.isplayer)
        {
            otherproperties.dealdamage(damage);
        }
    }
コード例 #2
0
    void OnTriggerEnter2D(Collider2D othercollider)
    {
        myProperties otherproperties = othercollider.gameObject.GetComponent <myProperties> ();

        //when it hits, do damage

        if (otherproperties != null && !otherproperties.isplayer)
        {
            otherproperties.dealdamage(damage);
            Destroy(this.gameObject);
        }
    }
コード例 #3
0
    void OnTriggerEnter2D(Collider2D othercollider)
    {
        myProperties otherproperties = othercollider.gameObject.GetComponent <myProperties> ();

        //when it hits, do damage



        if (otherproperties.isplayer && expcollector > 0)
        {
            otherproperties.gainexp(expcollector);
            print("You gained " + expcollector + " exp!");
            expcollector = 0;
        }



        if (otherproperties != null && !otherproperties.isplayer)
        {
            //if its not the player, hit it



            otherproperties.dealdamage(damage);

            //check weapon durability
            if (hashitcount)
            {
                hitcount -= 1;


                if (hitcount <= 0)
                {
                    Destroy(this.gameObject);
                }
            }



            //if killing blow sword gains exp
            if (damage > otherproperties.hp)
            {
                expcollector += otherproperties.deathexp;
            }
        }
    }