public void updateResultConsole(int value, PlayerControllerMap playerControllerMap)
 {
     if (hasFinished)
     {
         return;
     }
     _numberOfIteration++;
     _resultConsole.updateValue(value);
     if (_resultConsole.Result == _finalValue && numberOfSteps == _numberOfIteration)
     {
         FindObjectOfType <AudioManager>().Play("OperationRight");
         StartCoroutine(doors.OpenDoorsWithDelay(0.5f));
         confirmCounterForUser();
     }
     else if (_numberOfIteration == numberOfSteps)
     {
         FindObjectOfType <AudioManager>().Play("OperationWrong");
         playerControllerMap.IncrementTimer(-timePenalityInSeconds);
         _resultConsole.reset(_startingValue);
         foreach (ButtonConsole buttonConsole in _buttonConsoles)
         {
             buttonConsole.Button.resetPressedStatus();
         }
         StartCoroutine(resetCounterForUser());
     }
     else
     {
         FindObjectOfType <AudioManager>().Play("OperationNorm");
         updateCounterForUser(_numberOfIteration - 1);
     }
 }
Example #2
0
 private void Awake()
 {
     playerControllerMap = GetComponent <PlayerControllerMap>();
     _instantiatedText   = Instantiate(textBubble);
     _instantiatedText.SetActive(false);
     textBubbleOffset = _instantiatedText.GetComponentInChildren <SpriteRenderer>().bounds.extents / 2;
 }
Example #3
0
    public void SetPlayerInstance(PlayerControllerMap playerInstance)
    {
        _playerInstanceLocal     = playerInstance;
        _cameraInstance          = Instantiate(mainCamera);
        _cameraInstance.m_Follow = _playerInstanceLocal.transform;

        navMesh.GetComponent <NavMeshSurface2d>().BuildNavMesh();
    }
Example #4
0
 public void SetRemotePlayer()
 {
     GameObject [] players = GameObject.FindGameObjectsWithTag("Player");
     if (players[0] == _playerInstanceLocal.gameObject)
     {
         _playerInstanceRemote = players[1].GetComponent <PlayerControllerMap>();
         _playerInstanceRemote.GetComponent <Animator>().runtimeAnimatorController = _playerInstanceRemote.RuntimeAnimators[(_playerInstanceRemote.GetComponent <PhotonView>().ViewID / 1000) - 1];
     }
     else
     {
         _playerInstanceRemote = players[0].GetComponent <PlayerControllerMap>();
         _playerInstanceRemote.GetComponent <Animator>().runtimeAnimatorController = _playerInstanceRemote.RuntimeAnimators[(_playerInstanceRemote.GetComponent <PhotonView>().ViewID / 1000) - 1];
     }
     EventManager.StartListening(EventType.FinishGame, new UnityAction(FinishGame));
     SetUpAudio();
     //loadingCanvas.gameObject.SetActive(false);
 }
Example #5
0
    private void BeginGame()
    {
        if (PhotonNetwork.IsConnected)
        {
            if (PhotonNetwork.IsMasterClient)
            {
                _levelMap = PhotonNetwork.Instantiate(levelPrefab.name, Vector3.zero, Quaternion.identity).GetComponent <LevelMap>();
                _levelMap.CreateMapOverNetwork();
                _levelMap.InstantiatePlayersOverNetwork();
            }
        }
        else
        {
            _levelMap = Instantiate(levelPrefab);
            if (isDebug)
            {
                if (seed == 0)
                {
                    seed = UnityEngine.Random.Range(0, 10000);
                }
                Debug.Log("The seed is " + seed + "\n");
            }
            else
            {
                seed = UnityEngine.Random.Range(0, 10000);
            }
            _levelMap.Seed = seed;
            _levelMap.CreateMap();
            navMesh.GetComponent <NavMeshSurface2d>().BuildNavMesh();

            _playerInstanceLocal     = Instantiate(playerPrefab).GetComponent <PlayerControllerMap>();
            _cameraInstance          = Instantiate(mainCamera);
            _cameraInstance.m_Follow = _playerInstanceLocal.transform;
            _levelMap.PlacePlayer(_playerInstanceLocal, 1);
            _playerInstanceLocal.SetGameManager(this);
        }

        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;
    }
    public override void Interact(GameObject player)
    {
        if (!hasBeenSetted)
        {
            hasBeenSetted    = true;
            playerController = player.GetComponent <PlayerControllerMap>();
        }

        if (!_hasBeenActivated)
        {
            _hasBeenActivated = true;
            player.GetComponent <PlayerInput>()._canMove = false;
            canvasToReturn = panel.transform.parent.GetComponent <Canvas>();
            Canvas playerCanvas = player.GetComponentInChildren <Canvas>();
            panel.transform.SetParent(playerCanvas.transform);
            panel.transform.SetAsFirstSibling();
            foreach (var slot in slots)
            {
                slot.SlotImage.Canvas = playerCanvas;
            }
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
            panel.gameObject.SetActive(true);
            playerController.IsPanelActive = true;
            if (isTotem)
            {
                FindObjectOfType <AudioManager>().Play("TotemOn");
            }
            else
            {
                FindObjectOfType <AudioManager>().Play("RunePanelOn");
            }
        }
        else
        {
            ClosePanel(0);
        }
    }
Example #7
0
 public void updateResult(PlayerControllerMap playerControllerMap)
 {
     _operationalRoomManager.updateResultConsole(value, playerControllerMap);
 }
    public void VerifyCombination(PlayerControllerMap player)
    {
        int winCount = 0;

        if (currentPicture == 0)
        {
            for (int i = 0; i < 9; i++)
            {
                PicturePiece piece = pieces[i].GetComponent <PicturePiece>();
                if (piece.Active)
                {
                    if (firstWinnerIndexes.Contains(piece.PictureID))
                    {
                        winCount++;
                    }
                    else
                    {
                        winCount--;
                    }
                }
            }
            if (winCount == 3)
            {
                currentPicture++;
                FindObjectOfType <AudioManager>().Play("MemoryFirstRight");
                SetUpRoom();
            }
            else
            {
                FindObjectOfType <AudioManager>().Play("MemoryWrong");
                player.IncrementTimer(-20);
            }
        }
        else if (currentPicture == 1)
        {
            for (int i = 0; i < 9; i++)
            {
                PicturePiece piece = pieces[i].GetComponent <PicturePiece>();
                if (piece.Active)
                {
                    if (secondWinnerIndexes.Contains(piece.PictureID))
                    {
                        winCount++;
                    }
                    else
                    {
                        winCount--;
                    }
                }
            }
            if (winCount == 3)
            {
                FindObjectOfType <AudioManager>().Play("MemorySecondRight");
                StartCoroutine(myRoom.ExitDoor.OpenDoorsWithDelay(0.5f));
            }
            else
            {
                FindObjectOfType <AudioManager>().Play("MemoryWrong");
                player.IncrementTimer(-20);
            }
        }
    }