public override bool perform(GameObject agent)
    {
        if (startTime == 0)
        {
            enableBubbleIcon(agent);
            startTime = Time.time;
        }

        if (targetBush.food <= 0)
        {
            disableBubbleIcon(agent);
            targetBush.turnEmptySprite();
            return(false);
        }

        if (Time.time - startTime > duration)
        {
            disableBubbleIcon(agent);
            Collector collector = (Collector)agent.GetComponent(typeof(Collector));
            collector.energy -= energyCost;
            analyzed          = true;
            if (targetBush.age < 3)
            {
                targetBush.viewed = true;
                return(false);
            }
            else
            {
                collector.actualBush = targetBush;
            }
        }
        return(true);
    }
Exemplo n.º 2
0
    public override bool perform(GameObject agent)
    {
        if (startTime == 0)
        {
            enableBubbleIcon(agent);
            startTime = Time.time;
        }

        // No more food
        if (targetBush.food <= 0)
        {
            disableBubbleIcon(agent);
            Collector collector = (Collector)agent.GetComponent(typeof(Collector));
            targetBush.turnEmptySprite();
            collector.actualBush = null;
            return(false);
        }

        if (Time.time - startTime > duration)
        {
            disableBubbleIcon(agent);
            Collector collector = (Collector)agent.GetComponent(typeof(Collector));
            int       food      = 30;
            targetBush.collected = true;
            if ((targetBush.food - food) >= 0)
            {
                collector.food  += food;
                targetBush.food -= food;
            }
            else
            {
                collector.food += targetBush.food;
                targetBush.food = 0;
            }
            collector.energy -= energyCost;
            collected         = true;
        }
        return(true);
    }