Ejemplo n.º 1
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.numFirewood += 5;
            backpack.numLogs      = 0;
            backpack.numFood--;
            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);
    }
Ejemplo n.º 2
0
    public override bool Perform(GameObject agent, BlackBoard bb)
    {
        if (startTime == 0)
        {
            startTime = Time.time;
        }

        if (Time.time - startTime > miningDuration)
        {
            targetWolf.WolfNum--;
            // finished hunt
            BackpackComponent backpack = (BackpackComponent)agent.GetComponent(typeof(BackpackComponent));
            backpack.numMeat += 3;
            finishHunt        = true;

            if (backpack.tool == null)
            {
                ToolComponent tool = backpack.tool.GetComponent(typeof(ToolComponent)) as ToolComponent;
                tool.use(0.5f);
                if (tool.destroyed())
                {
                    Destroy(backpack.tool);
                    backpack.tool = null;
                }
            }
        }
        return(true);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 执行
    /// 如果操作成功执行则返回True,否则返回false,
    /// 如果发生了什么事,它就再也无法执行了。 在这种情况下
    /// 行动队列应清除,无法达到目标。</summary>
    /// <param name="agent"></param>
    /// <param name="bb"></param>
    /// <returns></returns>
    /// <exception cref="System.NotImplementedException"></exception>
    public override bool Perform(GameObject agent, BlackBoard bb)
    {
        if (startTime == 0)
        {
            startTime = Time.time;
        }

        if (Time.time - startTime > workDuration)
        {
            //
            Backpack backpack = (Backpack)bb.GetData("backpack");
            //增加背包中的数量
            backpack.stoneNum += 5;
            //完成
            isComplete = true;
            ToolComponent tool = backpack.tool.GetComponent <ToolComponent>();
            //减少工具耐久度
            tool.use(0.34f);
            //耐久度小于等于0销毁当前工具
            if (tool.destroyed())
            {
                Destroy(backpack.tool);
                backpack.tool = null;
            }
        }
        return(true);
    }
Ejemplo n.º 4
0
 public void DegradeTool(ToolComponent tool)
 {
     tool.use(toolDegrade);
     if (tool.destroyed())
     {
         Destroy(inventory.tool);
         inventory.tool = null;
     }
 }
Ejemplo n.º 5
0
    public override bool perform(GameObject agent)
    {
        if (startTime == 0)
        {
            startTime = Time.time;
        }

        if (Time.time - startTime > miningDuration)
        {
            // finished mining
            BackpackComponent backpack = (BackpackComponent)agent.GetComponent(typeof(BackpackComponent));
            backpack.numOre += 2;
            mined            = true;
            ToolComponent tool = backpack.tool.GetComponent(typeof(ToolComponent)) as ToolComponent;
            tool.use(0.5f);
            if (tool.destroyed())
            {
                Destroy(backpack.tool);
                backpack.tool = null;
            }
        }
        return(true);
    }
Ejemplo n.º 6
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.destroyed())
            {
                Destroy(backpack.tool);
                backpack.tool = null;
            }
        }
        return(true);
    }