Esempio n. 1
0
    /// <summary>
    /// Called by confirmMenu when returning.
    /// If gets success value, will create save the slot at number, else will do nothing
    /// </summary>
    /// <param name="retVal"></param>
    /// <param name="retString"></param>
    public override void _RespondToConfirm(int retVal, string retString)
    {
        switch (retVal)
        {
        case 0:
            if (GameManager.settings.saveNum <= 3 && GameManager.settings.saveNum >= 1 && GameManager.saveGame != null)                         // save existing game if it exists
            {
                SaveObj.SaveGame(GameManager.settings.saveNum, GameManager.saveGame);
            }

            GameManager.saveGame         = new SaveObj(!retString.Equals("") ? retString : "Slot " + number);
            GameManager.settings.saveNum = number;
            SaveObj.SaveGame(number, GameManager.saveGame);
            SettingsObj.saveSettings(GameManager.settings);
            if (GameManager.saveGame.levelNumber >= 0 && GameManager.saveGame.levelNumber < levelSelector.levelButtons.Length)
            {
                LevelSelector.changeLevelHelper(GameManager.saveGame.levelNumber);
                GameManager.changeState(GameManager.gameplay, this);
            }
            else
            {
                onClick(levelSelector);
            }
            break;

        default:                        // canceled, do nothing
            break;
        }
    }
    public int index;           // changed this to use ints, so loading the levels from other scripts is easier
    // This is set when instatiating from prefab

    /*public void changeString(string s)
     * {
     * this.s = s;
     * }*/

    //This method is called on button pressed.
    public void doButtonThing()
    {
        //LevelSelector.changeLevel(s);
        //LevelSelector.changeLevel(index);
        if (index != GameManager.saveGame.levelNumber)                  // update and save the last level visited if it is different from the current last level visited.
        {
            GameManager.saveGame.levelNumber = index;
            SaveObj.SaveGame(GameManager.settings.saveNum, GameManager.saveGame);
        }
        LevelSelector.changeLevelHelper(index);                                // load level with given index number
        GameManager.changeState(GameManager.gameplay, LevelSelector.instance); // switch to game-mode
    }
Esempio n. 3
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);
        }
    }