void OnTriggerEnter2D(Collider2D other)
    {
        NutrientLife nutrientLife = other.GetComponent <NutrientLife>();

        if (nutrientLife == null)
        {
            return;
        }

        if ((other.gameObject.tag == "LogFood") || (other.gameObject.tag == "OtherFood") || (other.gameObject.tag == "NotFood"))
        {
            Destroy(other.gameObject);
        }
    }
Example #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (!NutrientSpawner.inst.m_active)
        {
            return;
        }

        NutrientLife _nutrientLife = other.GetComponent <NutrientLife>();

        if (_nutrientLife == null)
        {
            return;
        }

        FOODTYPE _foodType  = other.GetComponent <NutrientLife>().m_foodType;
        int      _foodIndex = other.GetComponent <NutrientLife>().m_foodTypeIndex;

        switch (_foodType)
        {
        case FOODTYPE.LOGFOOD:
            if (_foodIndex == ND_RobotHandler.inst.m_wantedFoods[ND_RobotHandler.inst.m_wantedFoodIndex])
            {
                //Add wanted food to items collected
                LogDatabase.AddItemToCollection(other.GetComponent <Image>());

                //The wanted food was eaten.
                ND_RobotHandler.inst.NextFood();

                //Apply a robot eating animation.

                //Destroy incoming food.
                Destroy(other.gameObject);
            }
            break;

        case FOODTYPE.NOTFOOD:
            //Apply stun effect if the food acquired is not actually a food item.
            robotStunEffect.ApplyStun();
            ND_RobotHandler.inst.EatBadFood();

            Destroy(other.gameObject);
            break;

        case FOODTYPE.OTHERFOOD:
            break;

        default:
            break;
        }
    }