private void RandomizeSwipes(VPlayer player)
    {
        // First Swipe
        int    i       = Random.Range(0, swipesAvailable.Count);
        string element = swipesAvailable[i];

        swipesUsed.Add(element);
        swipesAvailable.Remove(element);
        player.ShowElement("Bottom_Left");
        player.ChangeElementText("Bottom_Left", element);

        // Second Swipe
        i       = Random.Range(0, swipesAvailable.Count);
        element = swipesAvailable[i];
        swipesUsed.Add(element);
        swipesAvailable.Remove(element);
        player.ShowElement("Bottom_Right");
        player.ChangeElementText("Bottom_Right", element);
    }
Ejemplo n.º 2
0
    private void RandomizeSwipes(VPlayer player)
    {
        HideAll(player, swipes);
        int    i       = Random.Range(0, swipesAvailable.Count);
        string element = swipesAvailable[i];

        swipesUsed.Add(element);
        swipesAvailable.Remove(element);
        player.ShowElement(element);
    }
Ejemplo n.º 3
0
    private void RandomizeButtons(VPlayer player)
    {
        // First Button
        int    i       = Random.Range(0, buttonsAvailable.Count);
        string element = buttonsAvailable[i];

        buttonsUsed.Add(element);
        buttonsAvailable.Remove(element);
        player.ShowElement(element);
        // Move button to correct spot.

        // Second Button
        i       = Random.Range(0, buttonsAvailable.Count);
        element = buttonsAvailable[i];
        buttonsUsed.Add(element);
        buttonsAvailable.Remove(element);
        player.ShowElement(element);
        // Move button to correct spot.
    }
    private void RandomizeButtons(VPlayer player)
    {
        // First Button
        int    i       = Random.Range(0, buttonsAvailable.Count);
        string btnText = buttonsAvailable[i];

        buttonsUsed.Add(btnText);
        buttonsAvailable.Remove(btnText);
        player.ShowElement("Top_Left");
        player.ChangeElementText("Top_Left", btnText);
        // Move button to correct spot.

        // Second Button
        i       = Random.Range(0, buttonsAvailable.Count);
        btnText = buttonsAvailable[i];
        buttonsUsed.Add(btnText);
        buttonsAvailable.Remove(btnText);
        player.ShowElement("Top_Right");
        player.ChangeElementText("Top_Right", btnText);
        // Move button to correct spot.
    }
Ejemplo n.º 5
0
        /// <summary>
        /// 'MonoBehaviour.Update()' method from Unity
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        private void Update()
        {
            // Switch through the possible player colors (left)
            if (VInput.GetButtonDown(playerId, "colorChangeLeft"))
            {
                if (currentColor == PlayerColors.Red)
                {
                    currentColor = PlayerColors.Black;
                }
                else
                {
                    currentColor--;
                }

                ApplyColor(currentColor);
            }

            // Switch through the possible player colors (right)
            if (VInput.GetButtonDown(playerId, "colorChangeRight"))
            {
                if (currentColor == PlayerColors.Black)
                {
                    currentColor = PlayerColors.Red;
                }
                else
                {
                    currentColor++;
                }

                ApplyColor(currentColor);
            }

            // Toggle this players ready state
            if (VInput.GetButtonDown(playerId, "submitButton"))
            {
                // Get the Volplane player object from this player
                VPlayer thisDevice = GetPlayer(playerId);

                if (!IsReady)
                {
                    // This player is ready!

                    // Hide elements for choosing colors and indicate that the player is ready
                    thisDevice.HideElement("colorChangeLeft");
                    thisDevice.HideElement("colorChangeRight");
                    thisDevice.HideElement("colorText");
                    thisDevice.ChangeElementText("infoText", "Waiting for game to start...");
                    thisDevice.ChangeElementText("submitButton", "Cancel");

                    if (playerText != null)
                    {
                        playerText.text = GetPlayer(playerId).Nickname + "\n(Ready)";
                    }

                    IsReady = true;

                    // Try to start the game by calling the lobbys 'StartGame()' method
                    GameObject.FindWithTag("Lobby").GetComponent <Lobby>().StartGame();
                }
                else
                {
                    // This player is still not ready after all...

                    // Give the player ability to choose its color again
                    thisDevice.ShowElement("colorChangeLeft");
                    thisDevice.ShowElement("colorChangeRight");
                    thisDevice.ShowElement("colorText");
                    thisDevice.ChangeElementText("infoText", "Choose your color!");
                    thisDevice.ChangeElementText("submitButton", "Ready");

                    if (playerText != null)
                    {
                        playerText.text = GetPlayer(playerId).Nickname + "\n(Waiting)";
                    }

                    IsReady = false;
                }
            }

            // Players can move when game starts
            // -> the element 'joystick' lies on the game view
            transform.Translate(new Vector3(
                                    VInput.GetAxis(playerId, "joystick", VInput.Axis.Horizontal),
                                    0f,
                                    VInput.GetAxis(playerId, "joystick", VInput.Axis.Vertical)
                                    ).normalized * 0.1f);
        }