Beispiel #1
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        gameUnit victim = coll.gameObject.GetComponent <gameUnit>();

        if (victim)
        {
            victim.GetComponent <Rigidbody2D> ().drag = 2;
            victim.Death.Invoke();
            GameObject.Destroy(this.gameObject);
        }
        else
        {
            if (linger)
            {
                GetComponent <Rigidbody2D> ().mass = 0.1f;
                GetComponent <Rigidbody2D> ().drag = 2;
                Destroy(this.gameObject, timeOut);
                Destroy(this);
            }
            else
            {
                GameObject.Destroy(this.gameObject);
            }
        }
    }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     unit.GetComponent <SpriteRenderer> ().sprite = gameManager.instance.getRandomEnemySprite();
     unit.equip((Weapon)GameObject.Instantiate(gameManager.instance.getRandomWeapon(), transform.position, transform.rotation));
     gameManager.instance.enemies.Add(this);
 }