Ejemplo n.º 1
0
 public override void Think(StudentAIController ai)
 {
     //If ai isn't occupied check if it has reached its destination
     if (!ai.isOccupied)
     {
         if (!ai.agent.pathPending)
         {
             if (ai.agent.remainingDistance <= ai.agent.stoppingDistance)
             {
                 if (!ai.agent.hasPath || ai.agent.velocity.sqrMagnitude == 0f)
                 {
                     if (currentDay.currentPeriod == currentDay.maxPeriods)
                     {
                         runtimeList.RemoveItem(ai.gameObject);
                         Destroy(ai.gameObject);
                     }
                     else
                     {
                         EnterClass(ai);
                     }
                 }
             }
         }
     }
     else
     {
         if (ai.periodOccupied != currentDay.currentPeriod)
         {
             ExitClass(ai);
             GoToNextTarget(ai);
         }
     }
 }
Ejemplo n.º 2
0
 private void EnterClass(StudentAIController ai)
 {
     ai.periodOccupied = currentDay.currentPeriod;
     ai.isOccupied     = true;
     ai.agent.enabled  = false;
     ai.GetComponent <Renderer>().enabled = false;
 }
Ejemplo n.º 3
0
    public override void Think(StudentAIController ai)
    {
        //If ai isn't occupied check if it has reached its destination
        if (ai.isOccupied)
        {
            if (ai.periodOccupied != currentDay.currentPeriod)
            {
                ExitClass(ai);
            }

            if (ai.agent.enabled == true && HasReachedDestination(ai))
            {
                if (currentDay.currentPeriod == currentDay.maxPeriods)
                {
                    Destroy(ai.gameObject);
                }
                else
                {
                    EnterClass(ai);
                }
            }
        }
        else
        {
            if (ai.agent.enabled == true && HasReachedDestination(ai))
            {
                Destroy(ai.gameObject);
            }
        }
    }
Ejemplo n.º 4
0
 public bool IsEventOver(StudentAIController ai)
 {
     if (campusEvent.startPeriod + campusEvent.numOfPeriods == currentDay.currentPeriod || currentDay.currentPeriod == currentDay.maxPeriods)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 public void CheckIfEventOver(StudentAIController ai)
 {
     if (campusEvent.startPeriod + campusEvent.numOfPeriods == currentDay.currentPeriod || currentDay.currentPeriod == currentDay.maxPeriods)
     {
         ai.isOccupied        = false;
         ai.agent.destination = ai.homePosition;
     }
 }
Ejemplo n.º 6
0
 private void MoveLineUp(StudentAIController ai)
 {
     studentAIs.RemoveAt(0);
     //campusEvent.currentNumOfStudents--;
     GoHome(ai);
     foreach (StudentAIController i in studentAIs)
     {
         i.agent.destination = campusEvent.eventPositions[studentAIs.IndexOf(i)].position;
     }
 }
Ejemplo n.º 7
0
    public override void Init(StudentAIController ai)
    {
        ai.isOccupied = true;
        //Used to init queue
        if (studentAIs.Count <= campusEvent.maxNumOfStudents)
        {
            studentAIs.Add(ai);
        }

        ai.agent.destination = campusEvent.eventPositions[studentAIs.IndexOf(ai)].position;
    }
Ejemplo n.º 8
0
 private void GoToNextTarget(StudentAIController ai)
 {
     //If its the end of the day, leave campus
     if (currentDay.currentPeriod == currentDay.maxPeriods)
     {
         ai.agent.destination = ai.homePosition;
     }
     else
     {
         ai.agent.destination = BuildingManager.instance.GetRandomBuilding().GetComponent <Building>().GetNavPos();
     }
 }
Ejemplo n.º 9
0
 private void GoToNextClass(StudentAIController ai)
 {
     if (currentDay.currentPeriod == currentDay.maxPeriods || currentDay.currentPeriod + 1 > selectedBuildings.list.Count)
     {
         ai.agent.destination = ai.homePosition;
         ai.isOccupied        = false;
     }
     else
     {
         ai.agent.SetDestination(selectedBuildings.list[currentDay.currentPeriod].GetNavPos());
     }
 }
Ejemplo n.º 10
0
 public bool HasReachedDestination(StudentAIController ai)
 {
     if (!ai.agent.pathPending)
     {
         if (ai.agent.remainingDistance <= ai.agent.stoppingDistance)
         {
             if (!ai.agent.hasPath || ai.agent.velocity.sqrMagnitude == 0f)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
    public override void Think(StudentAIController ai)
    {
        CheckIfEventOver(ai);

        if (ai.isOccupied)
        {
            ai.agent.destination = campusEvent.eventPositions[0].position;
        }
        else
        {
            if (HasReachedDestination(ai))
            {
                campusEvent.currentNumOfStudents--;
                Destroy(ai.gameObject);
            }
        }
    }
Ejemplo n.º 12
0
 public override void Think(StudentAIController ai)
 {
     //If ai isn't occupied check if it has reached its destination
     if (!ai.isOccupied)
     {
         if (!ai.agent.pathPending)
         {
             if (ai.agent.remainingDistance <= ai.agent.stoppingDistance)
             {
                 if (!ai.agent.hasPath || ai.agent.velocity.sqrMagnitude == 0f)
                 {
                     runtimeList.RemoveItem(ai.gameObject);
                     Destroy(ai.gameObject);
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
    public override void Think(StudentAIController ai)
    {
        //Student is occupied if currently attending an event
        if (ai.isOccupied)
        {
            //If event is over, student is no longer occupied and goes home
            if (IsEventOver(ai))
            {
                GoHome(ai);
            }

            //If student has reached the front of line, leave in x seconds
            if (HasReachedDestination(ai) && studentAIs.IndexOf(ai) == 0)
            {
                ai.ToggleOccupied(3f);
            }
        }
        else
        {
            //Student leaves and rest of the line moves up
            if (!IsEventOver(ai) && studentAIs.IndexOf(ai) == 0)
            {
                MoveLineUp(ai);
            }


            //TEMP CHANGE
            if (isDestoyedOnDequeue && !eventOverFlag)
            {
                campusEvent.currentNumOfStudents--;
                Destroy(ai.gameObject);
            }
            else if (HasReachedDestination(ai))
            {
                campusEvent.currentNumOfStudents--;
                Destroy(ai.gameObject);
            }
        }
    }
Ejemplo n.º 14
0
    public void SpawnPlayer(CoreAI ai)
    {
        Vector3 playerSpawnPosition = new Vector3(playerData.playerPointer.transform.position.x, 0.1f, playerData.playerPointer.transform.position.z);

        //Instantiate gameobject
        GameObject player = Instantiate(student, playerSpawnPosition, Quaternion.identity);

        //Setup line renderer reference
        DrawSchedulePath pathDrawer = transform.parent.GetComponentInChildren <DrawSchedulePath>();

        pathDrawer.isPlayerActive = true;
        //Set scriptable object play data
        playerData.playerPointer.transform.SetParent(player.transform);
        playerData.playerAgent = player.GetComponent <NavMeshAgent>();
        //Initalize AI component of prefab
        StudentAIController playerAIControl = player.GetComponent <StudentAIController>();

        playerAIControl.ai           = ai;
        playerAIControl.homePosition = spawnLocations.list[Random.Range(0, spawnLocations.list.Count)].position;
        //Position and enable player
        player.GetComponent <NavMeshAgent>().Warp(playerSpawnPosition);
        playerAIControl.enabled = true;
    }
Ejemplo n.º 15
0
    public override void Think(StudentAIController ai)
    {
        if (IsEventOver(ai))
        {
            GoHome(ai);
        }

        //Student is occupied if currently attending an event
        if (ai.isOccupied)
        {
            if (HasReachedDestination(ai))
            {
                GoToRandomEventPos(ai);
            }
        }
        else
        {
            if (HasReachedDestination(ai))
            {
                campusEvent.currentNumOfStudents--;
                Destroy(ai.gameObject);
            }
        }
    }
Ejemplo n.º 16
0
 public override void Init(StudentAIController ai)
 {
     ai.isOccupied = true;
     GoToNextClass(ai);
 }
Ejemplo n.º 17
0
 public virtual void Init(StudentAIController ai)
 {
 }
Ejemplo n.º 18
0
 public void GoHome(StudentAIController ai)
 {
     ai.isOccupied        = false;
     ai.agent.destination = ai.homePosition;
 }
Ejemplo n.º 19
0
 public override void Init(StudentAIController ai)
 {
     SetList(ai);
     GoToNextTarget(ai);
 }
Ejemplo n.º 20
0
 public abstract void Think(StudentAIController ai);
Ejemplo n.º 21
0
 void SetList(StudentAIController ai)
 {
     runtimeList.AddItem(ai.gameObject);
 }
Ejemplo n.º 22
0
 public override void Init(StudentAIController ai)
 {
     SetList(ai);
     ai.isOccupied = false;
     GoToHome(ai);
 }
Ejemplo n.º 23
0
 void GoToHome(StudentAIController ai)
 {
     ai.agent.destination = ai.homePosition;
 }
Ejemplo n.º 24
0
 public void ExitClass(StudentAIController ai)
 {
     ai.isOccupied    = false;
     ai.agent.enabled = true;
     ai.GetComponent <Renderer>().enabled = true;
 }
Ejemplo n.º 25
0
 public override void Init(StudentAIController ai)
 {
     ai.isOccupied        = true;
     ai.agent.destination = campusEvent.eventPositions[Random.Range(0, campusEvent.eventPositions.Length)].position;
 }
Ejemplo n.º 26
0
    IEnumerator FollowLeader(StudentAIController ai)
    {
        yield return(new WaitForSeconds(1f));

        ai.agent.destination = ai.homePosition;
    }
Ejemplo n.º 27
0
 public override void Init(StudentAIController ai)
 {
     ai.isOccupied = true;
 }
Ejemplo n.º 28
0
 public void ExitClass(StudentAIController ai)
 {
     ai.agent.enabled = true;
     ai.GetComponent <Renderer>().enabled = true;
     GoToNextClass(ai);
 }
Ejemplo n.º 29
0
 public void GoToRandomEventPos(StudentAIController ai)
 {
     ai.agent.destination = campusEvent.eventPositions[Random.Range(0, campusEvent.eventPositions.Length)].position;
 }