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


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


        if (otherproperties != null)
        {
            if (otherproperties.isplayer)
            {
                playermovement othermovement = othercollider.gameObject.GetComponent <playermovement> ();

                Rigidbody2D otherbody = othercollider.gameObject.GetComponent <Rigidbody2D> ();
                touchingbody = otherbody;

                othermovement.canmove = false;

                Vector3 stop = new Vector3(0, 0, 0);



                otherbody.velocity       = stop;
                othermovement.directionx = othermovement.directionx * (-1);
                othermovement.directiony = othermovement.directiony * (-1);
            }
        }
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        healthBar   = GameObject.Find("healthbar_0").GetComponent <SpriteRenderer>();
        healthScale = healthBar.transform.localScale;


        thisproperties = gameObject.GetComponent <myProperties>();

        myhealth = thisproperties.hp;
    }
コード例 #3
0
    void OnTriggerEnter2D(Collider2D othercollider)
    {
        //executed when another triggercollider is touching
        myProperties otherproperties = othercollider.gameObject.GetComponent <myProperties>();



        if (otherproperties != null)
        {
        }
    }
コード例 #4
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);
        }
    }
コード例 #5
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);
        }
    }
コード例 #6
0
    void OnTriggerExit2D(Collider2D othercollider)
    {
        //executed when another triggercollider is no longertouching
        touching = false;
        myProperties otherproperties = othercollider.gameObject.GetComponent <myProperties>();

        if (otherproperties != null && otherproperties.isplayer)
        {
            playermovement othermovement = othercollider.gameObject.GetComponent <playermovement>();


            othermovement.canmove = true;
        }
    }
コード例 #7
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;
            }
        }
    }
コード例 #8
0
    void OnTriggerEnter2D(Collider2D othercollider)
    {
        //executed when another triggercollider is touching
        myProperties otherproperties = othercollider.gameObject.GetComponent <myProperties>();

        if (otherproperties != null)
        {
            Rigidbody2D otherbody = othercollider.GetComponent <Rigidbody2D>();



            if (otherproperties.isplayer)
            {
                otherbody.AddForce(bump);
                print("bumping player");
                ;
            }
        }
    }