当前位置: 首页>>代码示例>>C#>>正文


C# Agent.getAgentNumber方法代码示例

本文整理汇总了C#中Agent.getAgentNumber方法的典型用法代码示例。如果您正苦于以下问题:C# Agent.getAgentNumber方法的具体用法?C# Agent.getAgentNumber怎么用?C# Agent.getAgentNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


在下文中一共展示了Agent.getAgentNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetActionForAgent

    //Traverse the leafs of the tree to find a suitable task for this agent
    public string GetActionForAgent(Agent agent)
    {
        //Check if the agent already has a node as its own
        foreach(TreeNode leaf in leafs)
        {
            if(leaf.GetOwner() != null && leaf.GetOwner().getAgentNumber() == agent.getAgentNumber()) //if agent already owns a node
            {
                return leaf.GetActionName();
            }
            else if(leaf.GetOwner() != null) { //if an agent already is assisting on a node

                if(OkayToAssist(agent, leaf, 2))
                {
                    //Debug.Log("AGNETSTHATDOACVTION " + agents[0] + " " + agents[1] + " for action " + leaf.GetActionName());
                    return "AssistingAction";
                }
            }
        }

        foreach(TreeNode leaf in leafs)
        {
            List<string> agents = ActionManager.Instance.AssistingAgentsToAction(agent.getAgentType(), leaf.GetActionName());

            if(agents.Count > 0 && leaf.GetOwnerNumber() == System.Guid.Empty )
            {
                leaf.SetOwner(agent);
                return leaf.GetActionName();
            }
            else if(agents.Count > 1 && leaf.GetOwnerNumber() != System.Guid.Empty && agent.getAgentType() != leaf.GetOwner().getAgentType())
            {

                if(OkayToAssist(agent, leaf, 1))
                {
                    leaf.GetAssisters().Add(agent);
                    //Debug.Log("AGNETSTHATDOACVTION " + agents[0] + " " + agents[1] + " for action " + leaf.GetActionName());
                    return "AssistingAction";
                }
            }
        }

        return "IdleAction"; //empty string means no match, agent cant to any of the leaf-node-actions
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:43,代码来源:TaskTree.cs

示例2: RemoveAgentFromOwnedNode

    public void RemoveAgentFromOwnedNode(Agent agent)
    {
        TreeNode ownedNode = GetOwnedNode(agent.getAgentNumber());
        if(ownedNode.GetPosition() != new Vector3(30, 0.5f, 30))
        {
            if(ownedNode.GetOwner().getAgentNumber() == agent.getAgentNumber())
            {
                ownedNode.SetOwner(null);
            } else {

                ownedNode.GetAssisters().Remove(agent);
            }
        }
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:14,代码来源:TaskTree.cs

示例3: RemoveNode

    //Removes a node in the leafs that this agent owns and adds its parent
    public void RemoveNode(Agent agent)
    {
        TreeNode ownedNode = GetOwnedNode(agent.getAgentNumber());
        List<Agent> assisters = ownedNode.GetAssisters();
        leafs.Remove(ownedNode);

        int level = -1;
        foreach(List<TreeNode> list in tree)
        {
            level++;
            if(list.Contains(ownedNode))
            {
                list.Remove(ownedNode);
                break;
            }
        }

        //Debug.Log (agent.getAgentType());
        //Debug.Log(ownedNode.GetParent().GetActionName());
        if(ownedNode.GetParent() != null)
        {
            List<string> agents = ActionManager.Instance.AssistingAgentsToAction(agent.getAgentType(), ownedNode.GetParent().GetActionName());
            assisters = ownedNode.GetParent().GetAssisters();

            if(HasChild(tree[level], ownedNode.GetParent()) == false )
            {

                int nrAgentToDoAction = agents.FindAll(item => item == agent.getAgentType()).Count;
                int nrSameColorAssisters = 0;

                foreach(Agent assister in assisters)
                {
                    if(assister.getAgentType() == agent.getAgentType())
                    {
                        nrSameColorAssisters++;
                    }
                }

                leafs.Add(ownedNode.GetParent());

                if(nrAgentToDoAction - nrSameColorAssisters == 1)
                {

                    ownedNode.GetParent().SetOwner(agent);

                } else {

                    foreach(Agent assister in assisters)
                    {
                        if(assister.getAgentType() == agent.getAgentType())
                        {
                            ownedNode.GetParent().SetOwner(assister);
                            assisters.Remove(assister);
                            break;
                        }
                    }
                }

                //PrintLeafs();

            } else if (HasChild(tree[level], ownedNode.GetParent()) == true)
            {
                if(agents.Contains(agent.getAgentType()))
                {
                    if(OkayToAssist(agent,  ownedNode.GetParent(), 1))
                    {
                        ownedNode.GetParent().GetAssisters().Add(agent);
                    }
                }
            }
        }

        Debug.Log ("!!!!!!!!!!!Remove node!!!!!!!!!!!!!");

        //PrintTree();
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:77,代码来源:TaskTree.cs

示例4: OkayToAssist

    public bool OkayToAssist(Agent agent, TreeNode ownedNode, int mode)
    {
        bool okToAssist;

        if(mode == 1)
        {
            okToAssist = true;
        } else {

            okToAssist = false;
        }

        List <Agent> assisters = ownedNode.GetAssisters();

            foreach(Agent assister in assisters)
            {
                if(mode == 1 && assister.getAgentType() == agent.getAgentType())
                {
                    okToAssist = false;
                } else if(mode == 2 && assister.getAgentNumber() == agent.getAgentNumber())
                {
                    okToAssist = true;
                }
            }

        return okToAssist;
    }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:27,代码来源:TaskTree.cs


注:本文中的Agent.getAgentNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。