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


C# Agent.getRadius方法代码示例

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


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

示例1: AdjacentAgents

    public AdjacentAgents(Agent me, float radius, Grid grid, Type agentType = null)
        : base(me)
    {
        this.adjAgentsRadius = radius;
        adjAgentsTotalRadius = radius + me.getRadius();

        this.grid = grid;
        adjAgentsRadiusCameraSpace = DebugRenderer.worldToCameraLength(radius);
        adjAgentsTotalRadiusCameraSpace = adjAgentsRadiusCameraSpace + me.getRadiusCameraSpace();

        this.agentType = agentType;
    }
开发者ID:jessmay,项目名称:oil-penguins,代码行数:12,代码来源:AdjacentAgents.cs

示例2: add

    //Add an agent to the grid.
    //Returns true if agent was added.
    //Returns false if location is out of bounds or agent is already within the grid.
    public bool add(Agent a, Vector2 to)
    {
        if (!inBounds(to) || grid [(int)to.y,(int)to.x].Contains(a))
            return false;

        maxAgentRadius = Mathf.Max(maxAgentRadius, a.getRadius());
        grid [(int)to.y,(int)to.x].Add (a);

        if(grid [(int)to.y, (int)to.x].Count == 1)
            map.canMove[(int)to.x,(int)to.y] = false;

        return true;
    }
开发者ID:jessmay,项目名称:oil-penguins,代码行数:16,代码来源:Grid.cs

示例3: getNear

    // This gets the adjacent agents within a given radius of Agent A
    // If looking for adjacent node sensor, it will be in Map.cs
    public List<Agent> getNear(Agent a, float radius, Type agentType = null)
    {
        List<Agent> near = new List<Agent> ();

        agentType = agentType == null? typeof(Agent): agentType;

        float myRadius = a.getRadius();
        radius += myRadius;

        Vector2 lower = getCellIndex (a.renderer.bounds.center - new Vector3 (radius+ maxAgentRadius, radius+ maxAgentRadius, 0));
        Vector2 upper = getCellIndex (a.renderer.bounds.center + new Vector3 (radius+ maxAgentRadius, radius+ maxAgentRadius, 0));

        for (int i = (int)lower.y; i <= (int)upper.y; ++i) {
            for (int j = (int)lower.x; j <= (int)upper.x; ++j) {

                if (!inBounds(j,i))
                    continue;

                for (int k = 0; k < grid[i,j].Count; ++k) {

                    Agent b = grid[i,j][k];
                    if (b.Equals(a) || !agentType.IsAssignableFrom(b.GetType())) continue;

                    float theirRadius = b.getRadius();
                    float dist = Vector3.Distance(a.renderer.bounds.center, b.renderer.bounds.center);

                    if(dist <= radius + theirRadius) {
                        near.Add(b);
                    }
                }
            }
        }

        return near;
    }
开发者ID:jessmay,项目名称:oil-penguins,代码行数:37,代码来源:Grid.cs


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