Example #1
0
 public Enemy()
 {
     hp          = DefaultHp();
     agentParams = new AgentParams();
     SetAgentParams();
     agentID = World.Instance.crowd.AddAgent(new Vector3(0, -4.72f, 0), agentParams);
 }
    private void GenerateCrowd()
    {
        if (!hasGenerated || navMeshQuery == null)
        {
            return;
        }

        System.Random rand = new System.Random();
        crowd = new Crowd(MAX_AGENTS, 0.6f, ref tiledNavMesh);

        SVector3 c = new SVector3(10, 0, 0);
        SVector3 e = new SVector3(5, 5, 5);

        AgentParams ap = new AgentParams();

        ap.Radius                = 0.6f;
        ap.Height                = 2.0f;
        ap.MaxAcceleration       = 8.0f;
        ap.MaxSpeed              = 3.5f;
        ap.CollisionQueryRange   = ap.Radius * 12.0f;
        ap.PathOptimizationRange = ap.Radius * 30.0f;
        ap.UpdateFlags           = new UpdateFlags();

        //initialize starting positions for each active agent
        for (int i = 0; i < numActiveAgents; i++)
        {
            //Get the polygon that the starting point is in
            NavPoint startPt;
            navMeshQuery.FindNearestPoly(ref c, ref e, out startPt);

            //Pick a new random point that is within a certain radius of the current point
            NavPoint newPt;
            navMeshQuery.FindRandomPointAroundCircle(ref startPt, 1000, out newPt);

            c = newPt.Position;

            //Save this random point as the starting position
            trails[i].Trail    = new SVector3[AGENT_MAX_TRAIL];
            trails[i].Trail[0] = newPt.Position;
            trails[i].HTrail   = 0;

            //add this agent to the crowd
            int idx = crowd.AddAgent(newPt.Position, ap);


            var targetPt = navMeshQuery.FindNearestPoly(new SVector3()
            {
                X = 0, Y = 0, Z = 0
            }, new SVector3 {
                X = 1, Y = 1, Z = 1
            });

            //Give this agent a target point
            //NavPoint targetPt;
            //navMeshQuery.FindRandomPointAroundCircle(ref newPt, 1000, out targetPt);

            crowd.GetAgent(idx).RequestMoveTarget(targetPt.Polygon, targetPt.Position);
            trails[i].Trail[AGENT_MAX_TRAIL - 1] = targetPt.Position;
        }
    }
Example #3
0
        public async Task <IActionResult> GetAllInfo([FromQuery] AgentParams parameters)
        {
            var result = await _agentService.Get(parameters);

            var agents = _mapper.Map <IEnumerable <AgentInfoDto> >(result);

            return(Ok(agents));
        }
Example #4
0
        public async Task Init()
        {
            var agentParams = new AgentParams();

            agentParams.Height      = 1.75f;
            agentParams.Radius      = 0.4f;
            agentParams.UpdateFlags = (UpdateFlags)(0);
            agentParams.MaxSpeed    = 0;
            agentID = World.Instance.crowd.AddAgent(new SharpNav.Geometry.Vector3(3.02f, -4.72f, 65.34f), agentParams);
            client.OnReliableReceived   += OnReceived;
            client.OnUnReliableReceived += OnReceived;
            client.BeginTcpReceive();
            //int artifacts = await this.inventory.getInventory(this);
        }
Example #5
0
 /// <summary>
 /// Modify the agent parameters
 /// </summary>
 /// <param name="parameters">The new parameters</param>
 public void UpdateAgentParameters(AgentParams parameters)
 {
     this.Parameters = parameters;
 }
 public async Task GetCountContracts(AgentParams agentParams)
 {
 }