/// <summary>
    /// Show the player where they should place the platform
    /// </summary>
    /// <param name="role">The players' role</param>
    /// <param name="xPos">Current x position of player object</param>
    public void ShowMoveToPlaceIndicator(Player.Role role, float xPos)
    {
        DisablePlatformInstruction();
        DisableMoveInstruction();

        if (role == Player.Role.Floater)
        {
            if (!_indicatorPlaceWater.activeSelf)
            {
                _indicatorPlaceWater.SetActive(true);
            }
        }
        else
        {
            if (xPos <= 0)
            {
                if (!_indicatorPlaceLeft.activeSelf)
                {
                    _indicatorPlaceLeft.SetActive(true);
                }
            }
            else
            {
                if (!_indicatorPlaceRight.activeSelf)
                {
                    _indicatorPlaceRight.SetActive(true);
                }
            }
        }
    }
示例#2
0
    public void UpdateGateLevel(Player.Role role)
    {
        switch (role)
        {
        case Player.Role.Insane:
            game.gateLevel += gateIncrease;
            break;

        case Player.Role.Sane:
            game.gateLevel -= gateIncrease;
            break;
        }
    }
示例#3
0
    private Player FindPlayer(Player.Role role)
    {
        Player result = null;

        for (int p = 0; result == null && p < m_players.Count; p++)
        {
            if (m_players[p].m_role == role)
            {
                result = m_players[p];
            }
        }

        return(result);
    }
示例#4
0
    public void GetSpawnData()
    {
        if (allCharacters.Length > 0 && defaultSpawn != null)
        {
            List <GameObject>     availableCharacters     = new List <GameObject>(allCharacters);
            List <SpawnLocations> availableSpawnLocations = new List <SpawnLocations>(allSpawnLocations);

            for (int i = 0; i < PlayerManager.instance.connectedToLobbyPlayers.Count; i++)
            {
                PlayerData thisPlayerData = PlayerManager.instance.connectedToLobbyPlayers[i];

                if (thisPlayerData == null)
                {
                    continue;
                }
                GameObject selectedCharacter = availableCharacters[Random.Range(0, availableCharacters.Count)];

                if (onlyUniqueCharacters && availableCharacters.Count > 1)
                {
                    availableCharacters.Remove(selectedCharacter);
                }

                Player.Role characterRole = selectedCharacter.GetComponent <Player>().role;

                foreach (SpawnLocations roleLocation in availableSpawnLocations)
                {
                    if (roleLocation.requiredRole == characterRole)
                    {
                        Transform selectedSpawn = defaultSpawn;

                        if (roleLocation.locations.Length > 0)
                        {
                            selectedSpawn = roleLocation.locations[Random.Range(0, roleLocation.locations.Length)];
                            if (roleLocation.locations.Length > 1)
                            {
                                roleLocation.RemoveLocation(selectedSpawn);
                            }
                        }

                        //HERE THE PLAYER GETS ACTUALLY SPAWNED
                        ActualSpawn(selectedSpawn, selectedCharacter, i);
                    }
                }
            }
        }

        cameraHandler.InitializeSplitscreenCameras();
    }
    /// <summary>
    /// Show players their controls for movement
    /// </summary>
    /// <param name="role">Players current role</param>
    /// <param name="xPos">Current x position of player object</param>
    public void ShowMovement(Player.Role role, float xPos)
    {
        DisablePlaceInstruction();
        DisableInteractInstruction();

        // Show the correct controls, check they are not active prior to avoid resetting animations
        if (_controls != null)
        {
            _controls.AnimateControls(true);
        }
        else
        {
            switch (role)
            {
            case Player.Role.Floater:
                if (!_bridgeControl.activeSelf)
                {
                    _bridgeControl.SetActive(true);
                }
                break;

            case Player.Role.Paddler:
                if (xPos <= 0)
                {
                    if (!_leftControl.activeSelf)
                    {
                        _leftControl.SetActive(true);
                    }
                }
                else
                {
                    if (!_rightControl.activeSelf)
                    {
                        _rightControl.SetActive(true);
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("role", role, null);
            }
        }
    }
示例#6
0
    /*check the guesser's guess against each player's target. invoke victory/loss callback on*/
    private void DoScores()
    {
        Player guesser = FindPlayer(Player.Role.GUESSER);

        bool foundScorer = false;

        for (int p = 0; !foundScorer && p < m_players.Count; p++)
        {
            Player player = m_players[p];

            if (player != guesser)
            {
                if (guesser.m_guess == player.m_targetCard)
                {
                    foundScorer = true;

                    player.m_score++;

                    if (player.m_role == Player.Role.JAMMER)
                    {
                        //bonus point!
                        player.m_score++;
                    }
                    else
                    {
                        //teamwork point!
                        guesser.m_score++;
                    }
                }
            }
        }

        //see if anyone won
        Player winner = null;

        for (int p = 0; winner == null && p < m_players.Count; p++)
        {
            if (m_players[p].m_score >= scoreToWin)
            {
                winner = m_players[p];
            }
        }

        if (winner == null)
        {
            //next round!

            Player.Role lastPlayerRole = m_players[m_players.Count - 1].m_role;

            for (int p = m_players.Count; p > 0; p--)
            {
                m_players[p].m_role = m_players[p - 1].m_role;
            }

            m_players[0].m_role = lastPlayerRole;

            //deal new round
            StartRound();
        }
        else
        {
            //victory!

            m_gameIsRunning = false;

            winner.DoVictoryState();

            foreach (Player player in m_players)
            {
                if (player != winner)
                {
                    player.DoLossState();
                }
            }
        }
    }