Esempio n. 1
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);
        }
    }