Exemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "organism")
        {
            Cell cell   = collision.collider.GetComponentInParent <Cell>();
            int  damage = GetBluntDamage(collision);

            CellCollisionsHelper.BluntDamageCellMitigateCollision(collision, cell, damage);
        }
        if (collision.gameObject.tag == "shell")
        {
            int       damage = GetBluntDamage(collision);
            ShellFood shell  = collision.collider.GetComponent <ShellFood>();
            shell.TakeBluntDamage(damage);
        }
    }
Exemplo n.º 2
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "organism")
        {
            Cell cell = collision.collider.GetComponentInParent <Cell>();
            if (cell.GetType() != typeof(PoisonCell))
            {
                cell.TakeDamage(5);//posion and damage other cell
            }
        }
        if (collision.gameObject.tag == "shell")
        {
            ShellFood shell = collision.collider.GetComponent <ShellFood>();

            shell.TakeDamage(5);
        }
    }