コード例 #1
0
 // This prevents players from being able to join the game whilst a match is underway
 // Players can only join in the main menu
 private void OnSceneChange(Scene oldScene, Scene newScene)
 {
     if (newScene.buildIndex == 0)
     {
         if (playerCount < 4)
         {
             inputManager.EnableJoining();
         }
     }
     else
     {
         inputManager.DisableJoining();
     }
 }
コード例 #2
0
    private void Start()
    {
        _inputManager = GetComponent <PlayerInputManager>();

        InputDevice[] p1Input;
        InputDevice[] p2Input;
        if (Gamepad.all.Count < 2)
        {
            ;
            p1Input = new[] { Keyboard.current };
            p2Input = new[] { Keyboard.current };
        }
        else
        {
            p1Input = new InputDevice[] { Gamepad.all[0], Keyboard.current };
            p2Input = new InputDevice[] { Gamepad.all[1], Keyboard.current };
        }

        _inputManager.playerPrefab = p1Prefab;
        _inputManager.JoinPlayer(controlScheme: "Player Controls2", pairWithDevices: p1Input);

        _inputManager.playerPrefab = p2Prefab;
        _inputManager.JoinPlayer(controlScheme: "Player Controls2", pairWithDevices: p2Input);

        _inputManager.DisableJoining();
    }
コード例 #3
0
 public void initializeGame()
 {
     if (players.Count >= 2)
     {
         iManager.DisableJoining();
         SceneManager.LoadSceneAsync(mapToLoad, LoadSceneMode.Single);
     }
 }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: Hexfall/Grand-Bout
 public void StartGame()
 {
     mainMenu     = false;
     invulnerable = false;
     pim.DisableJoining();
     LoadLevel(Random.Range(1, levels.Length));
     music.BattleMusic();
 }
コード例 #5
0
 // Start is called before the first frame update
 void Awake()
 {
     _playerInputManager = GetComponent <PlayerInputManager>();
     if (MatchController.GetInstance().SplitScreen)
     {
         _playerInputManager.EnableJoining();
         _playerInputManager.JoinPlayer();
         _playerInputManager.JoinPlayer();
         _playerInputManager.DisableJoining();
     }
     else
     {
         _playerInputManager.EnableJoining();
         _playerInputManager.JoinPlayer();
         _playerInputManager.DisableJoining();
     }
 }
コード例 #6
0
    public void EndGame(float index, Color color)
    {
        playerInputManager.DisableJoining();

        endGameUI.SetActive(true);
        Text winText = endGameUI.transform.Find("Win Text").GetComponent <Text>();

        winText.text  = "Player " + (index + 1) + " wins!";
        winText.color = color;
    }
コード例 #7
0
ファイル: MenuManager.cs プロジェクト: malikouda/thief-and-co
    //Back to the first screen from character select
    public void toMain()
    {
        joiningPlayers = false;
        manager.DisableJoining();
        inputModule.EnableAllActions();
        inputModule.UpdateModule();

        characterSelect.SetActive(false);
        mainMenu.SetActive(true);
    }
コード例 #8
0
    /// <summary>
    /// Lobby is complete, so move on
    /// </summary>
    /// <param name="allPlayers"></param>
    internal void Complete(LobbyInputHandler[] allPlayers)
    {
        LobbyComplete = true;
        Manager.DisableJoining();

        // ...store the player list in the manager
        SetPlayers(allPlayers.Select(p => p.GetComponent <PlayerControls>()).ToList());

        // move to the game central scene
        EndFader.StartFade(0, 1, CentralScene);
    }
コード例 #9
0
 public void AllowPlayerToJoin(bool isAllowed)
 {
     if (isAllowed && !playerInputManager.joiningEnabled)
     {
         playerInputManager.EnableJoining();
     }
     else if (!isAllowed && playerInputManager.joiningEnabled)
     {
         playerInputManager.DisableJoining();
     }
 }
コード例 #10
0
 private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     if (scene.name == "StartMenu")
     {
         playerInputManager.EnableJoining();
     }
     else
     {
         playerInputManager.DisableJoining();
     }
 }
コード例 #11
0
    public void DisableJoining()
    {
        playerInputManager.DisableJoining();

        // for now, just destroy all players who joined so far...
        // we don't need to remember them if we leave and enter lobby again
        // although we could, using .enabled = false then true and updating
        // the join widgets based on players who previously joined
        foreach (var player in PlayerInput.all)
        {
            Destroy(player.gameObject);
        }
    }
コード例 #12
0
    public void OnPlayerInteract(GameObject player)
    {
        Debug.Log(piManager.playerCount);
        if (playerNum == piManager.playerCount)
        {
            piManager.DisableJoining();
            tutManager.TurnOnDepartureWarning();
            tutManager.DeleteAllTut();

            //departure animation
            PlayerData.isPlayingCutscene = true;
            StartCoroutine("DepartureAnimation");
        }
    }
コード例 #13
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         if (pim.joiningEnabled)
         {
             pim.DisableJoining();
         }
         else
         {
             pim.EnableJoining();
         }
     }
 }
コード例 #14
0
    public void StartGame()
    {
        m_gameStarted = true;
        SetSplitScreen(true);
        m_inputManager.DisableJoining();

        foreach (GameObject panel in playerPanels)
        {
            panel.SetActive(false);
        }

        for (int i = 0; i < m_numPlayers; i++)
        {
            playerHUDs[i].SetActive(true);
        }

        ResumeGame();
    }
コード例 #15
0
    public void OnPlayerJoined(PlayerInput obj)
    {
        PlayerController player = obj.GetComponent <PlayerController>();

        player.selectOption = playerSelectMenu.players[players.Count];
        player.playerID     = (uint)players.Count;

        DontDestroyOnLoad(player);

        playerSelectMenu.players[players.Count].PlayerJoin();

        players.Add(player);
        InspectorName(player.gameObject, "Player" + players.Count);

        if (players.Count == playerInputManager.maxPlayerCount)
        {
            playerInputManager.DisableJoining();
        }
    }
コード例 #16
0
    //for indicating when the players press "Ready"
    public void ReadyPlayer(int index)
    {
        if (!_playerConfigs[index].IsReady)
        {
            _playerConfigs[index].IsReady = true;
        }

        for (int i = 0; i < _playerConfigs.Count; i++)
        {
            Debug.Log("Player: " + (index + 1) + " " + _playerConfigs[index].IsReady);
        }
        if (_playerConfigs.Count == _currentPlayers &&
            _currentPlayers <= _playerInputManager.maxPlayerCount &&
            _playerConfigs.All(p => p.IsReady == true))
        {
            SceneManager.LoadScene("LocalGameLevel");
            _playerInputManager.DisableJoining();       //stops people from joining after the game has been set
        }
    }
コード例 #17
0
    private void Start()
    {
        //spawn players
        var playerConfigs = PlayerConfigurationManager.Instance.GetPlayerConfigs().ToArray();

        for (int i = 0; i < playerConfigs.Length; i++)
        {
            var player = Instantiate(_PlayerPrefab, _SpawnPoints[i].position, _SpawnPoints[i].rotation);
            player.GetComponent <CharacterControl>().InitialiazePlayer(playerConfigs[i]);
            playerConfigs[i].Input.gameObject.GetComponentInChildren <CameraFollow>().Player = player.transform;
        }

        //disable joining
        PlayerInputManager InputManager = PlayerConfigurationManager.Instance.gameObject.GetComponent <PlayerInputManager>();

        if (InputManager)
        {
            InputManager.DisableJoining();
        }
    }
コード例 #18
0
 public void startIfReady()
 {
     if (players.Count >= 2)
     {
         foreach (GameObject player in players)
         {
             if (!player.GetComponent <PlayerController2>().isPlayerReady())
             {
                 return;
             }
         }
         isStarting = true;
         manager.DisableJoining();
         int i = 0;
         foreach (GameObject player in players)
         {
             player.GetComponent <PlayerController2>().disableReadyText(colors[i]);
             i += 1;
         }
     }
 }
コード例 #19
0
    // Start is called before the first frame update
    void Start()
    {
        _playerInputManager = GetComponent <PlayerInputManager>();
        _playerInputManager.onPlayerJoined += _playerInputManager_onPlayerJoined;
        var pp = InputDevice.all.Where(x => x.layout == "XInputControllerWindows" || x.layout == "Gamepad").ToArray();

        if (pp.Count() >= 1)
        {
            _playerInputManager.JoinPlayer(0, -1, "Xbox", pp[0]);
        }
        if (pp.Count() >= 2)
        {
            _playerInputManager.JoinPlayer(1, -1, "Xbox", pp[1]);
        }

        _playerInputManager.DisableJoining();
        var machines = GameObject.FindGameObjectsWithTag("Machine");

        _machines = machines.Select(x => x.GetComponent <Machine>()).ToArray();
        StartCoroutine(StartDestruction());
        StartCoroutine(StartDestructionb());
    }
コード例 #20
0
 public void OnGameStart()
 {
     PIM.DisableJoining();
 }
コード例 #21
0
    // Update is called once per frame
    void Update()
    {
        if (!changed && Instance.playerCount >= 1)      // Active timer if at least 1 player has joined // currently disabled for better way
        {
            //timer += Time.deltaTime;
            //TitleScreen.text = "GAME STARTS IN: " + (timeLimit - ((int)timer));
        }

        if (Instance.playerCount >= 1 && !changed && startGame) // load game scene
        {
            SceneManager.LoadScene(1);
            changed = true;
            GetComponent <RankingSystem>().StartRanking();
            Instance.DisableJoining();  // no more players can join
        }

        // This is if the game was in the game scene and has re-entered the main menu. This will reset all variables so that the previous code
        // will work like the first time. It will also re-find all the game objects in the scene that this script needs to run
        if (Instance.playerCount == 0 && changed && SceneManager.GetActiveScene().buildIndex == 0)
        {
            changed = false;
            //timer = 0f;
            Instance.EnableJoining();
            PlayerWin   = false;
            startGame   = false;
            gotRankings = false;

            for (int i = 0; i < planes.Length; i++)
            {
                planes[i] = GameObject.Find("P" + (i + 1));               // This is UI stuff, find all the panels so when goat selected, a white square will form
            }
            TitleScreen = GameObject.Find("Timer").GetComponent <Text>(); // find reference to text obj that is the countdown timer
        }

        if (!gotRankings && SceneManager.GetActiveScene().buildIndex == 1)
        {
            goatNameGraphics[0]  = GameObject.Find("RedGoatRanking");
            goatNameGraphics[1]  = GameObject.Find("RedGoatDeadRanking");
            goatNameGraphics[2]  = GameObject.Find("BlueGoatRanking");
            goatNameGraphics[3]  = GameObject.Find("BlueGoatDeadRanking");
            goatNameGraphics[4]  = GameObject.Find("YellowGoatRanking");
            goatNameGraphics[5]  = GameObject.Find("YellowGoatDeadRanking");
            goatNameGraphics[6]  = GameObject.Find("GreenGoatRanking");
            goatNameGraphics[7]  = GameObject.Find("GreenGoatDeadRanking");
            goatNameGraphics[8]  = GameObject.Find("PurpleGoatRanking");
            goatNameGraphics[9]  = GameObject.Find("PurpleGoatDeadRanking");
            goatNameGraphics[10] = GameObject.Find("OrangeGoatRanking");
            goatNameGraphics[11] = GameObject.Find("OrangeGoatDeadRanking");
            goatNameGraphics[12] = GameObject.Find("PinkGoatRanking");
            goatNameGraphics[13] = GameObject.Find("PinkGoatDeadRanking");
            goatNameGraphics[14] = GameObject.Find("AquaGoatRanking");
            goatNameGraphics[15] = GameObject.Find("AquaGoatDeadRanking");

            bool isAnyNull = false;
            for (int i = 0; i < goatNameGraphics.Length; i++)
            {
                if (goatNameGraphics[i] == null)
                {
                    isAnyNull = true;
                }
                if (i + 1 > Instance.playerCount * 2)
                {
                    goatNameGraphics[i].GetComponent <RawImage>().enabled = false;
                }
            }

            if (!isAnyNull)
            {
                gotRankings = true;
            }
        }
    }