示例#1
0
        public void RenderDebug(IGameContext gameContext, IRenderContext renderContext, Agent agent, I2DRenderUtilities twoDRenderUtilities)
        {
            var wndPos = new Vector2(this.WanderDistance, 0);
            var wldPos = agent.Project(wndPos);

            for (var i = 0; i < 10; i++)
            {
                var r = MathHelper.ToRadians(36 * i);
                var r2 = MathHelper.ToRadians(36 * (i + 1));
                twoDRenderUtilities.RenderLine(
                    renderContext,
                    wldPos + (new Vector2((float)Math.Sin(r), (float)Math.Cos(r)) * this.WanderRadius),
                    wldPos + (new Vector2((float)Math.Sin(r2), (float)Math.Cos(r2)) * this.WanderRadius),
                    Color.Green);
            }

            wndPos = this.m_WanderTarget + new Vector2(this.WanderDistance, 0);
            wldPos = agent.Project(wndPos);

            for (var i = 0; i < 10; i++)
            {
                var r = MathHelper.ToRadians(36 * i);
                var r2 = MathHelper.ToRadians(36 * (i + 1));
                twoDRenderUtilities.RenderLine(
                    renderContext,
                    wldPos + (new Vector2((float)Math.Sin(r), (float)Math.Cos(r)) * 3),
                    wldPos + (new Vector2((float)Math.Sin(r2), (float)Math.Cos(r2)) * 3),
                    Color.Red);
            }
        }
示例#2
0
        public void RenderDebug(IGameContext gameContext, IRenderContext renderContext, Agent agent, I2DRenderUtilities twoDRenderUtilities)
        {
            var wndPos = new Vector2(this.WanderDistance, 0);
            var wldPos = agent.Project(wndPos);

            for (var i = 0; i < 10; i++)
            {
                var r  = MathHelper.ToRadians(36 * i);
                var r2 = MathHelper.ToRadians(36 * (i + 1));
                twoDRenderUtilities.RenderLine(
                    renderContext,
                    wldPos + (new Vector2((float)Math.Sin(r), (float)Math.Cos(r)) * this.WanderRadius),
                    wldPos + (new Vector2((float)Math.Sin(r2), (float)Math.Cos(r2)) * this.WanderRadius),
                    Color.Green);
            }

            wndPos = this.m_WanderTarget + new Vector2(this.WanderDistance, 0);
            wldPos = agent.Project(wndPos);

            for (var i = 0; i < 10; i++)
            {
                var r  = MathHelper.ToRadians(36 * i);
                var r2 = MathHelper.ToRadians(36 * (i + 1));
                twoDRenderUtilities.RenderLine(
                    renderContext,
                    wldPos + (new Vector2((float)Math.Sin(r), (float)Math.Cos(r)) * 3),
                    wldPos + (new Vector2((float)Math.Sin(r2), (float)Math.Cos(r2)) * 3),
                    Color.Red);
            }
        }
示例#3
0
        public Vector2 Update(IGameContext gameContext, IUpdateContext updateContext, Agent agent)
        {
            var wt = this.m_WanderTarget;

            wt += new Vector2(((float)m_Random.NextDouble() * 2f) - 1f, ((float)m_Random.NextDouble() * 2f) - 1f) * this.WanderJitter;

            wt = Vector2.Normalize(wt) * this.WanderRadius;

            this.m_WanderTarget = wt;

            var target = wt + new Vector2(this.WanderDistance, 0);

            var wldTarget = agent.Project(target);

            return((wldTarget - agent.Position) * this.WanderWeight);
        }
示例#4
0
        public Vector2 Update(IGameContext gameContext, IUpdateContext updateContext, Agent agent)
        {
            var wt = this.m_WanderTarget;

            wt += new Vector2(((float)m_Random.NextDouble() * 2f) - 1f, ((float)m_Random.NextDouble() * 2f) - 1f) * this.WanderJitter;

            wt = Vector2.Normalize(wt) * this.WanderRadius;

            this.m_WanderTarget = wt;

            var target = wt + new Vector2(this.WanderDistance, 0);

            var wldTarget = agent.Project(target);

            return (wldTarget - agent.Position) * this.WanderWeight;
        }