예제 #1
0
    /// <summary>
    /// Handles the event which is fired if the player has reached the target point.
    /// </summary>
    private void ReachedTargetPoint()
    {
        // Special case: Path Discovery.
        if (performsPathDiscovery && originRouter != null)
        {
            if (isLogEnabled)
            {
                Debug.Log("DijkstraMovementManager: PathDiscovery: Need to move player back to origin router.");
            }

            performsPathDiscovery = false;
            movementScript.ControlPuddleSpawning(false);

            // Move player back to origin router.
            movementScript.MovePlayer(originRouter);

            originRouter = null;
        }
        else
        {
            SpriteRenderer sr = player.GetComponentInChildren <SpriteRenderer>();
            sr.color = Color.white;
            // Update the routing table.
            routingTableUI.UpdateRoutingTableUI();

            // Show the path costs.
            if (currentPath != null && currentPath.IsDiscovered() == true)
            {
                currentPath.DisplayPathCosts();

                // Display path costs also for the way back.
                dijkstraManager.GetInversePath(currentPath).DisplayPathCosts();
                //writeFileLog
            }

            // If it is a valid discovery move, check if the current working router is completely handled now.
            if (currentStatus == DijkstraStatus.VALID_HOP_DISCOVERY || currentStatus == DijkstraStatus.VALID_HOP)
            {
                bool isHandled = dijkstraManager.IsCurrentWorkingRouterHandledCompletely();
                if (isHandled)
                {
                    dijkstraManager.GetCurrentPlayerPosition().GetComponent <RouterScript>().HighlightRouter();
                    if (soundManager != null)
                    {
                        soundManager.PlaySound(SoundManager.SoundType.RunComplete);
                    }
                }
            }
        }
    }
 private void CheckValidMoves()
 {
     if (professorController.GetCurrentSequenceId() == 1 && professorController.GetCurrentStateId() == 2)
     {
         // If first path was discovered, show professor with next sequence.
         if (dijkstraManager.GetCurrentMove().Status.Equals(DijkstraStatus.VALID_HOP_DISCOVERY))
         {
             professorController.NextSequence();
             professorController.Show(true);
         }
     }
     else if (professorController.GetCurrentSequenceId() == 2 && professorController.GetCurrentStateId() == 2)
     {
         // If second path was discovered, show professor with next sequence.
         if (!dijkstraManager.IsCurrentWorkingRouterHandledCompletely())
         {
             professorController.NextSequence();
             professorController.Show(true);
         }
     }
     else if (professorController.GetCurrentSequenceId() == 3 && professorController.GetCurrentStateId() == 2)
     {
         // If first router is handled completely, show professor with next sequence.
         if (dijkstraManager.IsCurrentWorkingRouterHandledCompletely())
         {
             professorController.NextSequence();
             professorController.Show(true);
         }
     }
     else if (professorController.GetCurrentSequenceId() == 4 && professorController.GetCurrentStateId() == 3)
     {
         // If correctly moved to second hop, show professor with next sequence.
         if (dijkstraManager.GetCurrentMove().Status.Equals(DijkstraStatus.VALID_HOP))
         {
             professorController.NextSequence();
             professorController.Show(true);
         }
     }
     else if (professorController.GetCurrentSequenceId() == 5 && professorController.GetCurrentStateId() == 0)
     {
         // If second router is handled completely, show professor with next sequence.
         if (dijkstraManager.IsCurrentWorkingRouterHandledCompletely())
         {
             professorController.NextSequence();
             professorController.Show(true);
         }
     }
     else if (professorController.GetCurrentSequenceId() == 6 && professorController.GetCurrentStateId() == 4)
     {
         // If only one router is left, show professor with next sequence.
         if (dijkstraManager.GetAmountOfUndiscoveredRouters() == 1)
         {
             professorController.NextSequence();
             professorController.Show(true);
         }
     }
     else if (professorController.GetCurrentSequenceId() == 7 && professorController.GetCurrentStateId() == 1)
     {
         // If all routers are handled completely, show professor with next sequence.
         if (dijkstraManager.GetAmountOfUndiscoveredRouters() == 0)
         {
             professorController.NextSequence();
             professorController.Show(true);
         }
     }
 }