Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (puzzleCode.Length > 0) //handling condtion of when the player hasn't picked any puzzle
     {
         if (charCount == puzzleCode.Length)
         {
             Debug.Log("char count: " + charCount + " is puzzle selected: " + puzzle_selected);
             if (playerInput == puzzleCode)
             {
                 SafeZoneController.safeZoneState = 2; // execute the operation for expansion
                 Debug.Log("Correct answer: " + playerInput + " Right answer: " + puzzleCode + " char count: " + charCount);
                 playerInput = "";                     //player input no longer required
                 charCount   = 0;                      // input length no longer required
                 puzzleCode  = "";                     //since this puzzle has been solved, it will be removed
                 PuzzleRepo.PuzzleSolved(PuzzleID);
                 PuzzleRepo.FetchPuzzle();             //ask the inventory send out the last unsolved puzzle
             }
             else
             {
                 SafeZoneController.safeZoneState = 0;
                 Debug.Log("Wrong answer: " + playerInput + " Right answer: " + puzzleCode + " char count: " + charCount);
                 playerInput = "";
                 charCount   = 0;
             }
         }
     }
     else   //fetch a puzzle from the inventory if they exist
     {
         playerInput = "";
         charCount   = 0;
         PuzzleRepo.FetchPuzzle();
         Debug.Log("Fetching puzzle request");
     }
 }
Пример #2
0
 void SceneChanger()
 {
     if (PuzzleRepo.AllPuzzleSolved())
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene("LabRoom");
         UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync("MainMovement");
     }
 }
Пример #3
0
    public void AddItem(GameObject item)
    {
        bool itemAdded = false;

        for (int i = 0; i < inventory.Length; i++)
        {
            if (inventory [i] == null)
            {
                inventory[i] = item;
                //InventoryButtons[i].name = item.name;
                InventoryButtons[i].image.overrideSprite = item.GetComponent <SpriteRenderer>().sprite;
                //InventoryButtons[i].GetComponent<PanelOpener>.GetType();
                //NOTE: dynamically change the panel name
                itemAdded = true;
                item.SendMessage("DoInteraction");
                PuzzleRepo.AddPuzzle(int.Parse(item.name));
                break;
            }
        }
        if (!itemAdded)
        {
            Debug.Log("Inventory is full");
        }
    }