예제 #1
0
    /// <summary>
    /// return true if the node and the one it is connected to in that direction have mis-matching string, that would indicate that a one-way connection would cut the string if traveled over.
    /// </summary>
    /// <param name="node"></param>
    /// <param name="dir"></param>
    /// <returns></returns>
    public bool disjoint(Node node, GameManager.Direction dir)
    {
        Node other = this[node[(int)dir]];

        GameManager.Direction opposite = dir.inverse();
        if (            // if one node has an enter/exit for the string on the connection, and the other does not have the corresponding exit/enter
            ((node.hasEnter && (node.enter == dir)) && ((other.leave != opposite) || !other.hasLeave)) ||
            ((node.hasLeave && (node.leave == dir)) && ((other.enter != opposite) || !other.hasEnter)) ||
            ((other.hasEnter && (other.enter == opposite)) && ((node.leave != dir) || !node.hasLeave)) ||
            ((other.hasLeave && (other.leave == opposite)) && ((node.enter != dir) || !node.hasEnter))
            )
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #2
0
    public void onArrive(bool canMove, Node otherNode, GameManager.Direction dir)
    {
        if (!canMove)
        {
            animLockout = false;
            return;
        }
        //Handle fake connection stacking
        {
            //If the connection from this node to the other is one-way
            if (otherNode[(int)dir.inverse()] != currentPosition.index)
            {
                // temp override connection to that node
                otherNode[(int)dir.inverse()] = currentPosition.index;
            }
        }

        if (hasBall)
        {
            //Tag the current square with line exit dir
            if (!otherNode.hasLeave)
            {
                currentPosition.leave    = dir;
                currentPosition.hasLeave = true;
                otherNode.enter          = dir.inverse();
                otherNode.hasEnter       = true;
                stringLeft--;
            }
            else
            {
                //Do a backup
                currentPosition.hasEnter = false;
                otherNode.hasLeave       = false;
                stringLeft++;
            }
        }

        currentPosition = otherNode;

#if UNITY_EDITOR    // if this is in the editor, call getCurrentNode() every time movement happens,
        // and apply copied colors and sprites to the new tile is currently drawing.
        if (editLevel != null)
        {
            editLevel.getCurrentNode();
            editLevel.drawTiles();              // only changes stuff if currently drawing
            //Debug.Log("calling getCurrentNode()...")
        }
        else
        {
            Debug.Log("Cannot call getCurrentNode(), there is no reference to editLevel script/object");
        }
#endif
        nonEuclidRenderer.HandleRender(dir, currentPosition);
        animLockout = false;
        setUItext();            // apply changes to UI text: string left, checkpoints.

        if (map.winConditions())
        {
            winTrigger = true;
            wintext.SetActive(true);                                              // make win text visible
            winSound.SetActive(true);                                             // play sound
            // play win sound here
            levelSelector.unlockLevel();                                          // unlocks next level
            GameManager.saveGame.levelNumber++;                                   // advance last level visited, so will auto-load next level
            SaveObj.SaveGame(GameManager.settings.saveNum, GameManager.saveGame); // save changes to levels accessible and last-level-visited
            //Debug.Log("You win!");
        }
        //if (currentPosition.hasSign && !signsVisited.Contains(currentPosition.index)) {
        if (currentPosition.type == Node.TileType.sign && !signsVisited.Contains(currentPosition.index))
        {
            signsVisited.Add(currentPosition.index);
            signText.text = currentPosition.signMessage;
            signImage.gameObject.SetActive(true);
        }
    }