示例#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
        {
            ToggleBeer tb = FindObjectOfType <ToggleBeer>();
            tb.DisplayBeer(true);
            // 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);
                    }
                }
            }
        }
    }
示例#2
0
    /// <summary>
    /// Performs the path discovery move along the specified path, i.e. the player moves
    /// towards the destination router and spwans puddles on the way. After the player has reached
    /// the target position, the player moves back along the path to the origin router.
    /// </summary>
    /// <param name="path">The path on which the path discovery should be performed.</param>
    private void performPathDiscoveryMove(PathScript path)
    {
        ToggleBeer tb = FindObjectOfType <ToggleBeer>();

        tb.DisplayBeer(false);
        if (isLogEnabled)
        {
            Debug.Log("DijkstraMovementManager: Perform path discovery on path " + path.name);
        }

        movementScript.ControlPuddleSpawning(true);
        performsPathDiscovery = true;

        if (path.from == dijkstraManager.GetCurrentPlayerPosition())
        {
            originRouter = path.from;
            movementScript.MovePlayer(path.to);
        }
        else
        {
            originRouter = path.to;
            movementScript.MovePlayer(path.from);
        }
    }