示例#1
0
    private void Start()
    {
        attachedController = GetComponent <AgentSteering>();
        attachedBase       = GetComponent <AgentBase>();

        attachedController.SetTargetTile(attachedBase.currentTileIndex);

        currentTask = new AgentTask(Tasks.Null, attachedBase);
        PrepTaskList();

        UpdateAgent();
    }
示例#2
0
    // Drunk gestion
    private void updateDrunk()
    {
        foreach (Agent drunk in m_drunkList)
        {
            Vector2 drunkSteer = AgentSteering.leader(drunk._velocity, 20, 0.5f, ref drunk._wanderPoint);
            Vector2 avoidSteer = AgentSteering.avoid(drunk._position, drunk._velocity, ref drunk._wanderPoint) * _coefAvoidObs;

            Vector2 force = drunkSteer + avoidSteer;

            drunk._steeringForce += force;
        }
    }
示例#3
0
    // Leader gestion
    private void updateLeaders()
    {
        foreach (Agent leader in m_leaderList)
        {
            Vector2 leadSteer  = AgentSteering.leader(leader._velocity, _leaderRadius, _leaderVariation, ref leader._wanderPoint) * _coefLeader;
            Vector2 avoidSteer = AgentSteering.avoid(leader._position, leader._velocity, ref leader._wanderPoint) * _coefAvoidObs;

            Vector2 force = leadSteer + avoidSteer;

            leader._steeringForce += force;
        }
    }
示例#4
0
    // Follower gestion
    private void updateFollowers()
    {
        foreach (Agent follower in m_followerList)
        {
            Agent nearestLeader = findNearest(follower, m_leaderList);

            Vector2 followSteer  = AgentSteering.follow(follower._position, nearestLeader._position, nearestLeader._velocity);
            Vector2 stayOutSteer = AgentSteering.stayOut(follower._position, nearestLeader._position, nearestLeader._velocity) * _coefStayOut;

            Vector2 force = followSteer + stayOutSteer;

            follower._steeringForce += force;
        }
    }
示例#5
0
    // Separation gestion
    private void updateSeparation(Agent [] separationList, float coefSeparation)
    {
        foreach (Agent separation in separationList)
        {
            Agent[]   neighbours         = findNeighbours(separation, 20.0f);
            Vector2[] positionNeighbours = new Vector2[neighbours.Length];

            for (int i = 0; i < neighbours.Length; i++)
            {
                positionNeighbours.SetValue(neighbours[i]._position, i);
            }

            Vector2 steer = AgentSteering.separation(separation._position, positionNeighbours) * coefSeparation;
            separation._steeringForce += steer;
        }
    }