Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        // We are only interested in interactions between ants
        if (other.tag != Naming.Ants.Tag)
        {
            return;
        }

        otherAnt = other.gameObject.GetComponent <AntManager>();

        // Recruitment cannot take place if either ant is already part of a tandem run or social carry
        if (ant.IsTandemRunning() || ant.IsTransporting() || otherAnt.IsTandemRunning() || otherAnt.IsTransporting())
        {
            return;
        }

        // This script is from the perspective of the recruiter, so only recruiting or reversing ants continue
        if (ant.state == BehaviourState.Reversing)
        {
            ReversingSenses();
        }
        else if (ant.state == BehaviourState.Recruiting)
        {
            RecruiterSenses();
        }
    }
Example #2
0
    private void RecruitingMovement()
    {
        // If recruiter needs to wait for the follower, ant should not move (next turn time is increased so the tandem leader doesn't turn immediately after regaining contact)
        if (ant.IsTandemRunning() && ShouldTandemLeaderWait() == true)
        {
            nextTurnTime += Time.fixedDeltaTime;
            return;
        }

        // Update direction only if the required time has elapsed
        if (simulation.TotalElapsedSimulatedTime("s") >= nextTurnTime)
        {
            // Recruiters leading a tandem run or transporting (social carry) will need to return to their new nest.
            if (ant.IsTandemRunning() || ant.IsTransporting())
            {
                WalkToNest(ant.myNest);
                UpdateTandemDistance();
            }
            // Recruiters not tandem running or carrying move back and forth between the new and old nests.
            else
            {
                // The target nest is either the old or new nest, depending on the current recruiter direction
                NestManager targetNest = (ant.recruitmentStage == RecruitmentStage.GoingToOldNest) ? ant.oldNest : ant.myNest;

                // If the recruiter has reached the target nest, then walk randomly inside while waiting/searching for recruits
                if (ant.currentNest == targetNest)
                {
                    RandomWalk(maxVarBase);
                }
                else // Else walk towards the target nest
                {
                    WalkToNest(targetNest);
                }
            }

            ResetTurnParameters(false);
        }

        // Move forward at the speed based on the ant's current behaviour/activity
        if (ant.IsTandemRunning())
        {
            MoveForward(Speed.v[Speed.TandemRunLead], true);
        }
        else if (ant.IsTransporting())
        {
            MoveForward(Speed.v[Speed.Carrying], true);
        }
        else // If waiting or moving between nests then move at standard speed
        {
            MoveForward(Speed.v[Speed.Scouting], true);
        }
    }