Exemplo n.º 1
0
    IEnumerator MoveToPoint(Transform currentPoint, PuzzlePathComponent destination, List <PuzzlePathComponent> completePath)
    {
        AC.KickStarter.player.Halt();
        isFuckingMoving = true;
        for (int i = completePath.Count - 1; i > 0; i--)
        {
            if (OnLightpointMove != null)
            {
                OnLightpointMove(completePath[i]);
            }

            yield return(MoveToPoint(currentPoint, completePath[i]));

            currentLocation = completePath[i];
            //Debug.Log("moved to " + completePath[i].transform.position);
        }

        //	Completed the puzzle
        if (destination.xpos == 1 && destination.ypos == 7)
        {
            //  Win scenario
            //moveAwayInteraction.Interact();
            if (winInteraction != null)
            {
                winInteraction.Interact();
            }
        }

//		if(OnLightpointMove != null)
//			OnLightpointMove(destination);

        isFuckingMoving = false;
    }
Exemplo n.º 2
0
    bool ScanForPath(PuzzlePathComponent currentLocation, PuzzlePathComponent pathPoint, List <PuzzlePathComponent> completePath, List <PuzzlePathComponent> totalScanned)
    {
        if (totalScanned.Contains(currentLocation))
        {
            return(false);
        }

        totalScanned.Add(currentLocation);

        if (currentLocation == pathPoint)
        {
            completePath.Add(currentLocation);

            return(true);
        }

        foreach (var path in currentLocation.connectedTo)
        {
            if (ScanForPath(path, pathPoint, completePath, totalScanned))
            {
                completePath.Add(path);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 3
0
    IEnumerator MoveToPoint(Transform currentPoint, PuzzlePathComponent endPoint)
    {
        moveSoundSource.Play();
        Transform dest = endPoint.transform;
        Vector3   step = (dest.position - currentPoint.position) / framesPerStep;

        while (Vector3.Magnitude(currentPoint.position - dest.position) > marginOfError)
        {
            currentPoint.position = currentPoint.position + step;
            yield return(new WaitForSeconds(0.02f));
        }

        currentPoint.position = dest.position;
    }
Exemplo n.º 4
0
    void TryMoveToPos(PuzzlePathComponent pathPoint)
    {
        if (StaffHeadColor.CurrentColorIndex != staffColorIndex || isFuckingMoving)
        {
            return;
        }

        List <PuzzlePathComponent> completePath = new List <PuzzlePathComponent>();
        List <PuzzlePathComponent> totalScanned = new List <PuzzlePathComponent>();

        if (ScanForPath(currentLocation, pathPoint, completePath, totalScanned))
        {
            MoveLightPointToEnd(pathPoint, completePath);
        }
    }
Exemplo n.º 5
0
    //	Called by an event. When one moves, all of them move.
    private void MoveLightPoint(PuzzlePathComponent destination)
    {
        if (isFuckingMoving)
        {
            return;
        }

        var path = paths.FirstOrDefault(t => t.xpos == destination.xpos && t.ypos == destination.ypos);

        if (path != null)
        {
            StartCoroutine(MoveToPoint(LightPoint.transform, path));
            currentLocation = path;
        }
    }
Exemplo n.º 6
0
 private void MoveLightPointToEnd(PuzzlePathComponent destination, List <PuzzlePathComponent> completePath)
 {
     StartCoroutine(MoveToPoint(LightPoint.transform, destination, completePath));
 }