Example #1
0
 /// <summary>
 /// Player accepts whatever option they currently have selected
 /// </summary>
 /// <param name="player">Which number player is this</param>
 /// <param name="playerArea">Which player area is this</param>
 public void SelectText(int player, PlayerArea playerArea)
 {
     //If the name input is active, look at what was selected
     //If a text object was the selection, they are entering their name.  Only goes up to 8 characters
     //If an image was selected, the player chose to finish their name.
     if (playerNameInputGO.gameObject.activeInHierarchy)
     {
         if (textOptions[selectedTextOption].GetComponent <TextMeshProUGUI> () != null && playerName[player].Length < 8)
         {
             string temp = "";
             playerName[player] += textOptions[selectedTextOption].GetComponent <TextMeshProUGUI> ().text;
             for (int i = 0; i < 8; i++)
             {
                 if (i > 0)
                 {
                     temp += " ";
                 }
                 if (i < playerName[player].Length)
                 {
                     temp += playerName[player][i];
                 }
                 else
                 {
                     temp += "_";
                 }
             }
             nameInput.text = temp;
         }
         else if (textOptions[selectedTextOption].GetComponent <Image>() != null)
         {
             GameHandler.instance.players [player].playerName = playerName[player];
             playerArea.SetName(playerName [player]);
             nameInColor.text = playerName [player] + "\n" + "Choose a Color";
             playerNameInputGO.SetActive(false);
             playerColorGO.SetActive(true);
             playerArea.SetColor(colorOptions[selectedColorOption].GetComponent <TextMeshProUGUI>().color);
         }
         //If the color input is active, they are choosing a color.
         //Any input is accepted as final input
     }
     else if (playerColorGO.gameObject.activeInHierarchy)
     {
         GameHandler.instance.players [player].playerColor = colorOptions[selectedColorOption].GetComponent <TextMeshProUGUI> ().color;
         playerColorGO.SetActive(false);
     }
 }
Example #2
0
    /// <summary>
    /// Universal void used for scrolling options (left and right currently)
    /// </summary>
    /// <param name="right">If set true, scrolls to the right</param>
    /// <param name="pArea">Which player area is controlling this input</param>
    void ScrollText(bool right, PlayerArea pArea)
    {
        List <GameObject> options = textOptions;
        int selectedOb            = selectedTextOption;
        int spacing = textSpacing;

        if (playerColorGO.gameObject.activeInHierarchy)
        {
            options    = colorOptions;
            selectedOb = selectedColorOption;
            spacing    = colorSpacing;
        }
        GameObject tempOb   = options [0];
        int        obInsert = options.Count - 1;

        if (right)
        {
            tempOb   = options [options.Count - 1];
            obInsert = 0;
        }

        options.Remove(tempOb);
        options.Insert(obInsert, tempOb);
        float tempX = 0;

        for (int i = selectedOb; i >= 0; i--)
        {
            RectTransform temp = options [i].GetComponent <RectTransform>();
            if (i == selectedOb)
            {
                moveAmount            = temp.anchoredPosition.x;
                temp.anchoredPosition = new Vector2(0, temp.anchoredPosition.y);
            }
            else
            {
                temp.anchoredPosition = new Vector2(tempX - temp.rect.width / 2, temp.anchoredPosition.y);
                tempX -= (temp.rect.width / 2);
            }
            tempX -= (temp.rect.width / 2) + spacing;
            if (playerNameInputGO.gameObject.activeInHierarchy)
            {
                if (options [i].GetComponent <TextMeshProUGUI> () != null)
                {
                    options [i].GetComponent <TextMeshProUGUI> ().color = normalColor;
                }
                else
                {
                    options [i].GetComponent <Image> ().color = normalColor;
                }
            }
        }
        tempX = 0;
        for (int i = selectedOb; i < options.Count; i++)
        {
            RectTransform temp = options [i].GetComponent <RectTransform>();
            if (i == selectedOb)
            {
                temp.anchoredPosition = new Vector2(0, temp.anchoredPosition.y);
            }
            else
            {
                temp.anchoredPosition = new Vector2(tempX + temp.rect.width / 2, temp.anchoredPosition.y);
                tempX += (temp.rect.width / 2);
            }
            tempX += (temp.rect.width / 2) + spacing;
            if (playerNameInputGO.gameObject.activeInHierarchy)
            {
                if (options [i].GetComponent <TextMeshProUGUI> () != null)
                {
                    options [i].GetComponent <TextMeshProUGUI> ().color = normalColor;
                }
                else
                {
                    options [i].GetComponent <Image> ().color = normalColor;
                }
            }
        }
        if (playerNameInputGO.gameObject.activeInHierarchy)
        {
            if (options [selectedOb].GetComponent <TextMeshProUGUI> () != null)
            {
                options [selectedOb].GetComponent <TextMeshProUGUI> ().color = selectedColor;
            }
            else
            {
                options [selectedOb].GetComponent <Image> ().color = selectedColor;
            }
        }
        else if (playerColorGO.gameObject.activeInHierarchy)
        {
            pArea.SetColor(colorOptions[selectedOb].GetComponent <TextMeshProUGUI>().color);
        }
        StopCoroutine("moveItems");
        StartCoroutine("moveItems");
    }
Example #3
0
    private void BoderRectangleControl(GameControl.UpdateInfo updateConfig, Color32 val, bool marked = false, bool blinking = false)
    {
        if (updateConfig.CardId >= 0)
        {
            if (cards.ContainsKey(updateConfig.CardId))
            {
                // destroy previous
                RemoveSpritesFromParent(cards[updateConfig.CardId]);
                cards.Remove(updateConfig.CardId);
            }
            // get card config
            ConfigFormats.Card cardConf = gamC.gameConfig.TblSettings.GetCardConfigByID(updateConfig.CardId);
            //Debug.Log("card id:" + cardConf.Id + " size:" + cardConf.X + "|" + cardConf.Y);
            if (cardConf == null)
            {
                Debug.Log("Card config not found id: " + updateConfig.CardId);
                return;
            }
            // get card size
            ConfigFormats.CardSize cardSizeConf = gamC.gameConfig.GetCardSizeByID(cardConf.SizeId);
            if (cardSizeConf == null)
            {
                Debug.Log("Card size config not found id: " + cardConf.SizeId);
                return;
            }
            // set card area
            CardArea crArea = new CardArea();
            crArea.SetName("pl" + updateConfig.PlayerID + "_pos" + updateConfig.CardId);
            if (cardConf.turnNinety)
            {
                crArea.SetArea(RelativeToAbsolute(cardConf.X, cardConf.Y, mmToPixels(cardSizeConf.Height), mmToPixels(cardSizeConf.Width), false));
            }
            else
            {
                crArea.SetArea(RelativeToAbsolute(cardConf.X, cardConf.Y, mmToPixels(cardSizeConf.Width), mmToPixels(cardSizeConf.Height), false));
            }
            if (updateConfig.CardType == ARBangStateMachine.BangCard.NONE)
            {
                crArea.SetFilled(true);
            }
            else
            {
                crArea.SetFilled(false);
            }
            crArea.SetColor(val);
            crArea.SetBorderWidth(10);
            CreateRectangle(crArea, "Cards", true);
            crArea.SetReadyToDraw(true);
            crArea.AreaMarked   = marked;
            crArea.AreaBlinking = blinking;
            crArea.LastChanged  = Time.time;

            cards[updateConfig.CardId] = crArea;
        }
        else
        {
            //Debug.Log("Creating Border for player with color: " + val);
            // get info about player
            if (players.ContainsKey(updateConfig.PlayerID))
            {
                // only update should be performed
                RemoveSpritesFromParent(players[updateConfig.PlayerID]);
                players.Remove(updateConfig.PlayerID);
                RemoveSpritesFromParent(effectAreas[updateConfig.PlayerID]);
                effectAreas.Remove(updateConfig.PlayerID);
            }
            // create active area for player
            PlayerArea plArea = new PlayerArea();
            // get configuration params
            ConfigFormats.Player playerConf = gamC.gameConfig.TblSettings.PlayersArray.PlayerDataArray[updateConfig.PlayerID];

            plArea.SetArea(RelativeToAbsolute(playerConf.ActiveArea.X, playerConf.ActiveArea.Y, playerConf.ActiveArea.Width, playerConf.ActiveArea.Height));
            plArea.SetFilled(false);
            plArea.SetColor(PlayersColors.Universal);
            plArea.SetBorderWidth(10);
            CreateRectangle(plArea, "Players");
            plArea.SetReadyToDraw(true);
            plArea.AreaMarked   = marked;
            plArea.AreaBlinking = blinking;
            plArea.LastChanged  = Time.time;

            players[updateConfig.PlayerID] = plArea;

            // create effects area for player
            EffectArea efArea = new EffectArea();

            efArea.SetArea(RelativeToAbsolute(playerConf.EffectsArea.X, playerConf.EffectsArea.Y, playerConf.EffectsArea.Width, playerConf.EffectsArea.Height));
            efArea.SetFilled(false);
            efArea.SetColor(val);
            efArea.SetBorderWidth(10);
            CreateRectangle(efArea, "Effects");
            efArea.SetReadyToDraw(true);
            efArea.AreaMarked   = marked;
            efArea.AreaBlinking = blinking;
            efArea.LastChanged  = Time.time;

            effectAreas[updateConfig.PlayerID] = efArea;
        }
    }