コード例 #1
0
    public override bool Perform(GameObject agent)
    {
        if (_startTime == 0)
        {
            _startTime = Time.time;
        }

        if ((Time.time - _startTime) > workDuration)
        {
            // finished chopping
            BackpackComponent backpack = agent.GetComponent <BackpackComponent>();
            backpack.numLogs += 1;
            _chopped          = true;
            ToolComponent tool = backpack.tool.GetComponent <ToolComponent>();
            tool.Use(0.34f);
            if (tool.IsDestroyed())
            {
                Destroy(backpack.tool);
                backpack.tool = null;
            }
        }
        return(true);
    }
コード例 #2
0
    public override bool Perform(GameObject agent)
    {
        if (startTime == 0)
        {
            startTime = Time.time;
        }

        if (Time.time - startTime > workDuration)
        {
            // finished chopping
            BackpackComponent backpack = (BackpackComponent)agent.GetComponent(typeof(BackpackComponent));
            backpack.numLogs += 1;
            chopped           = true;
            ToolComponent tool = backpack.tool.GetComponent(typeof(ToolComponent)) as ToolComponent;
            tool.Use(0.34f);
            if (tool.Destroyed())
            {
                Destroy(backpack.tool);
                backpack.tool = null;
            }
        }
        return(true);
    }