Пример #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        //Debug.Log ("position " + collision.gameObject.transform.position + " life " + life + " FocusOut " + collision.gameObject.GetComponent<Pathfinding> ().GetFocusOut ());
        Pathfinding path = collision.gameObject.GetComponent <Pathfinding>();

        if (collision.gameObject.tag == "enemy" && life > 0 && !path.GetFocusOut())
        {
            life--;
            path.SetColTrue();
            collision.gameObject.GetComponent <TouchMonster> ().DestroyMonster();
            tabEnemyBlock [indiceTab] = collision.gameObject;
            indiceTab++;

            if (life == 0 && alive)
            {
                gm.ActiveSleep(this.gameObject);
                for (int i = 0; i < indiceTab; i++)
                {
                    if (tabEnemyBlock[i])                    //Si l'objet existe encore
                    {
                        tabEnemyBlock[i].GetComponent <Pathfinding> ().SetColFalse();
                    }
                }
                alive = false;
            }
        }
    }