Exemple #1
0
    IEnumerator Rebuilder()
    {
        while (true)
        {
            if (logDirty || useFades)
            {
                if (logList.Count == 0)
                {
                    yield return(waiter);                    // might hang list line
                }
                while ((logList.Count > maxLines))
                {
                    logList.RemoveAt(0);
                    times.RemoveAt(0);
                }

                //    logList2 = logList; //temp

                /*     while ((text.preferredHeight > rect.rect.height))
                 *  {
                 *      logList.RemoveAt(0);
                 *      times.RemoveAt(0);
                 *  }
                 */
                sb = new System.Text.StringBuilder();
                float currentTime = Time.time;
                for (int i = 0; i < logList.Count; i++)
                {
                    float thisLife = currentTime - times[i] - fadeDelay;
                    if (thisLife > fadeTime)
                    {
                        times.RemoveAt(0);
                        logList.RemoveAt(0);
                        //   i--;
                        continue;
                    }
                    else
                    {
                        if (useFades)
                        {
                            float thisFadeAmt = thisLife / fadeTime;
                            Color thisColor   = color;
                            thisColor.a = 1 - thisFadeAmt;
                            sb.Append("<color=#");
                            sb.Append(ColorUtility.ToHtmlStringRGBA(thisColor));
                            sb.Append(">");
                            sb.Append(logList[i]);
                            sb.Append("</color>");
                        }
                        else
                        {
                            sb.Append(logList[i]);
                        }
                    }


                    sb.Append("\n");
                }
                text.text = sb.ToString();
                logDirty  = false;
            }
            yield return(waiter);
        }
    }
Exemple #2
0
        public string GetLine(TextoLanguage language)
        {
            TextoLine line = lines.Find(x => x.language == language);

            if (line != null)
            {
                string finalText = line.text;

                finalText = finalText.Replace("<important>", string.Format("<color=#{0}>", ColorUtility.ToHtmlStringRGBA(TextoSettingsData.instance.highlightColor)));
                finalText = finalText.Replace("</important>", "</color>");

                return(finalText);
            }

            return("[No text found]");
        }
Exemple #3
0
 public static string ToRichTextHexColorCode(this Color color)
 {
     return("#" + ColorUtility.ToHtmlStringRGB(color));
 }
 public static string MakeColor(this string s, Color c)
 {
     return("<color=" + ColorUtility.ToHtmlStringRGB(c) + ">" + s + "</color>");
 }
Exemple #5
0
 //called when color is modified, to update other UI components
 private void RecalculateMenu(bool recalculateHSV)
 {
     interact = false;
     if (recalculateHSV)
     {
         modifiedHsv = new HSV(modifiedColor);
     }
     else
     {
         modifiedColor = modifiedHsv.ToColor();
     }
     rComponent.value = modifiedColor.r;
     rComponent.transform.GetChild(3).GetComponent <InputField>().text = modifiedColor.r.ToString();
     gComponent.value = modifiedColor.g;
     gComponent.transform.GetChild(3).GetComponent <InputField>().text = modifiedColor.g.ToString();
     bComponent.value = modifiedColor.b;
     bComponent.transform.GetChild(3).GetComponent <InputField>().text = modifiedColor.b.ToString();
     if (useA)
     {
         aComponent.value = modifiedColor.a;
         aComponent.transform.GetChild(3).GetComponent <InputField>().text = modifiedColor.a.ToString();
     }
     mainComponent.value = (float)modifiedHsv.H;
     rComponent.transform.GetChild(0).GetComponent <RawImage>().color             = new Color32(255, modifiedColor.g, modifiedColor.b, 255);
     rComponent.transform.GetChild(0).GetChild(0).GetComponent <RawImage>().color = new Color32(0, modifiedColor.g, modifiedColor.b, 255);
     gComponent.transform.GetChild(0).GetComponent <RawImage>().color             = new Color32(modifiedColor.r, 255, modifiedColor.b, 255);
     gComponent.transform.GetChild(0).GetChild(0).GetComponent <RawImage>().color = new Color32(modifiedColor.r, 0, modifiedColor.b, 255);
     bComponent.transform.GetChild(0).GetComponent <RawImage>().color             = new Color32(modifiedColor.r, modifiedColor.g, 255, 255);
     bComponent.transform.GetChild(0).GetChild(0).GetComponent <RawImage>().color = new Color32(modifiedColor.r, modifiedColor.g, 0, 255);
     if (useA)
     {
         aComponent.transform.GetChild(0).GetChild(0).GetComponent <RawImage>().color = new Color32(modifiedColor.r, modifiedColor.g, modifiedColor.b, 255);
     }
     positionIndicator.parent.GetChild(0).GetComponent <RawImage>().color = new HSV(modifiedHsv.H, 1d, 1d).ToColor();
     positionIndicator.anchorMin = new Vector2((float)modifiedHsv.S, (float)modifiedHsv.V);
     positionIndicator.anchorMax = positionIndicator.anchorMin;
     hexaComponent.text          = useA ? ColorUtility.ToHtmlStringRGBA(modifiedColor) : ColorUtility.ToHtmlStringRGB(modifiedColor);
     colorComponent.color        = modifiedColor;
     onCC?.Invoke(modifiedColor);
     interact = true;
 }
Exemple #6
0
 public static string GetTextWithColor(string text, Color color)
 {
     return(string.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGB(color), text));
 }
 protected override string Serialize()
 {
     return(ColorUtility.ToHtmlStringRGBA(Value));
 }
    /// <summary>
    /// Changes currently selected asset's color.
    /// </summary>
    /// <param name="color">New color.</param>
    /// <param name="currentObject">Transform object. Uses last selected object if it is not supplied.</param>
    public void ChangeAssetColor(Color color, Transform currentObject = null)
    {
        // If transform object is not supplied, use last selected asset.
        if (currentObject == null)
        {
            currentObject = m_transforms[AvatarCreatorContext.selectedAssetType];
        }


        switch (AvatarCreatorContext.selectedAssetType)
        {
        case AssetType.HeadShape:
        case AssetType.Ears:
        case AssetType.Nose:
        {
            m_transforms[AssetType.HeadShape].GetComponent <Image>().color = color;

            m_transforms[AssetType.Ears].transform.Find("fo_ear_left").GetComponent <Image>().color  = color;
            m_transforms[AssetType.Ears].transform.Find("fo_ear_right").GetComponent <Image>().color = color;

            m_transforms[AssetType.Nose].GetComponent <Image>().color = color;

            m_transforms[AssetType.Body].transform.Find("fo_body_L2").GetComponent <Image>().color = color;

            m_transforms[AssetType.SpecialBody].transform.Find("fo_specialbody_L2").GetComponent <Image>().color = color;

            m_transforms[AssetType.Eyes].Find("fo_eye_left").Find("fo_eye_left_L0").GetComponent <Image>().color   = color;
            m_transforms[AssetType.Eyes].Find("fo_eye_right").Find("fo_eye_right_L0").GetComponent <Image>().color = color;
            break;
        }

        case AssetType.Mouth:
        {
            currentObject.Find("fo_mouth_L1").GetComponent <Image>().color = color;
            break;
        }

        case AssetType.Hair:
        {
            currentObject.GetComponent <Image>().color = color;
            currentObject.parent.Find("fo_hair_back").GetComponent <Image>().color = color;
            break;
        }

        case AssetType.Moustache:
        case AssetType.Beard:
        {
            m_transforms[AssetType.Moustache].GetComponent <Image>().color = color;
            m_transforms[AssetType.Beard].GetComponent <Image>().color     = color;
            break;
        }

        case AssetType.Eyes:
        {
            currentObject.Find("fo_eye_left").Find("fo_eye_left_L2").GetComponent <Image>().color   = color;
            currentObject.Find("fo_eye_right").Find("fo_eye_right_L2").GetComponent <Image>().color = color;
            break;
        }

        case AssetType.Eyebrows:
        {
            currentObject.Find("fo_eyebrow_left").GetComponent <Image>().color  = color;
            currentObject.Find("fo_eyebrow_right").GetComponent <Image>().color = color;
            break;
        }

        case AssetType.FaceTexture:
        {
            m_transforms[AssetType.FaceTexture].GetComponent <Image>().color = color;
            break;
        }

        case AssetType.SpecialBody:
        {
            m_transforms[AssetType.SpecialBody].transform.Find("fo_specialbody_L3").GetComponent <Image>().color = color;
            break;
        }

        case AssetType.BackgroundTexture:
        {
            m_transforms[AssetType.BackgroundTexture].GetComponent <Image>().color = color;
            AvatarCreatorContext.bgColor = color;
            break;
        }
        }

        AvatarCreatorContext.logManager.LogAction("AssetColorChanged", ColorUtility.ToHtmlStringRGB(color));
    }
    /// <summary>
    /// Deserializes given data and loads it to FaceObject.
    /// </summary>
    /// <param name="data">Serialized XML data.</param>
    public void Unserialize(string data)
    {
        Debug.Log("FaceObjectController:Unserialize()\n" + data);

        // Initialization
        AssetType  assetType  = AssetType.None;
        string     objectName = "";
        string     assetName  = "";
        Vector3    position   = new Vector3();
        Quaternion rotation   = new Quaternion();
        Vector3    scale      = new Vector3();
        Color      color      = new Color();

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(data);

        XmlNode root = doc.DocumentElement.SelectSingleNode("/SaveFile/FaceObject");

        foreach (XmlNode node in root.ChildNodes)
        {
            foreach (XmlAttribute attr in node.Attributes)
            {
                switch (attr.Name)
                {
                case "name":
                {
                    objectName = attr.Value;
                    break;
                }

                case "asset":
                {
                    assetName = attr.Value;
                    break;
                }

                case "type":
                {
                    assetType = (AssetType)System.Enum.Parse(typeof(AssetType), attr.Value);
                    break;
                }

                case "posx":
                {
                    position.x = float.Parse(attr.Value);
                    break;
                }

                case "posy":
                {
                    position.y = float.Parse(attr.Value);
                    break;
                }

                case "posz":
                {
                    position.z = float.Parse(attr.Value);
                    break;
                }

                case "rotx":
                {
                    rotation.x = float.Parse(attr.Value);
                    break;
                }

                case "roty":
                {
                    rotation.y = float.Parse(attr.Value);
                    break;
                }

                case "rotz":
                {
                    rotation.z = float.Parse(attr.Value);
                    break;
                }

                case "rotw":
                {
                    rotation.w = float.Parse(attr.Value);
                    break;
                }

                case "scalex":
                {
                    scale.x = float.Parse(attr.Value);
                    break;
                }

                case "scaley":
                {
                    scale.y = float.Parse(attr.Value);
                    break;
                }

                case "scalez":
                {
                    scale.z = float.Parse(attr.Value);
                    break;
                }

                case "color":
                {
                    ColorUtility.TryParseHtmlString("#" + attr.Value, out color);
                    break;
                }
                }
            }

            Debug.Log(objectName + " " + assetName);

            if (assetName == "")
            {
                continue;
            }

            CBaseAsset asset = AvatarCreatorContext.FindAssetByName(assetName);

            if (asset == null)
            {
                asset = new CBaseAsset(AssetGender.NoGender, assetType, 0, "");
            }

            GameObject gObject = GameObject.Find(objectName);
            if (gObject)
            {
                gObject.transform.position   = position;
                gObject.transform.rotation   = rotation;
                gObject.transform.localScale = scale;

                if (gObject.GetComponent <Image>() != null)
                {
                    gObject.GetComponent <Image>().color = color;
                }
            }

            SetFaceObjectPart(asset, false);
        }
    }
Exemple #10
0
    public void Load(SRSTaiXiuTransactionHistoryItem data, Color cWin, Color cLose, Color cNormal)
    {
        gameObject.SetActive(true);

        txtId.text     = "#" + data.SessionID.ToString("F0");
        txtTime.text   = data.Time;
        txtGate.text   = VKCommon.FillColorString(data.BetSide == 0 ? "TÀI" : "XỈU", "#" + (data.BetSide == data.Result ? ColorUtility.ToHtmlStringRGB(cWin) : ColorUtility.ToHtmlStringRGB(cLose)));
        txtResult.text = data.ResultText + VKCommon.FillColorString(" (" + (data.Result == 0 ? "TÀI" : "XỈU") + ")", "#" + ColorUtility.ToHtmlStringRGB(cNormal));
        txtBet.text    = VKCommon.ConvertStringMoney(data.Bet);
        txtRefund.text = VKCommon.ConvertStringMoney(data.Refund);
        txtWin.text    = VKCommon.ConvertStringMoney(data.Award);
    }
Exemple #11
0
 public void SetColor(string hex)
 {
     ColorUtility.TryParseHtmlString(hex, out _color);
     _image.DOColor(_color, 0.2f);
 }
Exemple #12
0
 public static string ColoredText(string str, Color color)
 {
     return($"<color=#{ColorUtility.ToHtmlStringRGB(color)}>{str}</color>");
 }
        public byte[] Compress(Color[] colors)
        {
            Debug.Assert(colors.Length == BlockFormat.TexelCount);

            var colorTable = CreateColorTable(colors);

            var block = new BC1BlockData();

            block.Color0 = colorTable[0];
            block.Color1 = colorTable[1];

            for (int i = 0; i < colors.Length; ++i)
            {
                var color32 = colors[i];

                // If color has alpha, use a specific index
                // to identify the color when decompressed
                block.ColorIndexes[i] = color32.HasAlpha() ? AlphaColorIndex :
                                        ColorUtility.GetIndexOfClosestColor(colorTable, ColorUtility.To16Bit(color32));
            }

            return(block.ToBytes());
        }
Exemple #14
0
        internal static void IndexColor(string propertyName, Color c, ObjectIndexer indexer, int documentIndex)
        {
            var colorHex = c.a < 1f ? ColorUtility.ToHtmlStringRGBA(c) : ColorUtility.ToHtmlStringRGB(c);

            indexer.AddProperty(propertyName, "#" + colorHex.ToLowerInvariant(), documentIndex, exact: true, saveKeyword: false);
        }
Exemple #15
0
 /// <summary>
 /// 色を変更してログを出力します
 /// </summary>
 /// <param name="_message">メッセージ</param>
 /// <param name="_size">文字の大きさ</param>
 /// <param name="_color">文字の色</param>
 /// <param name="_context">メッセージが適用されるオブジェクト</param>
 public static void Log(string _message, float _size, Color _color, UnityEngine.Object _context)
 {
     UnityEngine.Debug.Log("<_color=#" + ColorUtility.ToHtmlStringRGB(_color) + "><_size=" + _size + ">" + _message + "</_size></_color>", _context);
 }
    //function used to perform the setup of the game board before every match
    public void BackgroundSetup()
    {
        setDots    = 0;
        swaps      = 0;
        dots       = new List <Dot> ();
        rectangles = new RectHolder[rows, columns];
        colors     = new List <Color>();
        finalText  = GameObject.Find("GameHolder/FinalText");

        //parses all colours expressed in hexadecimal format to obtain Color objects
        for (int i = 0; i < hexColors.Length; i++)
        {
            Color temp;
            ColorUtility.TryParseHtmlString(hexColors [i], out temp);
            colors.Add(temp);
        }

        canvasRect = GameObject.Find("Canvas").GetComponent <RectTransform> ();

        int canvasWidth  = (int)canvasRect.rect.width;
        int canvasHeight = (int)canvasRect.rect.height;

        rectColors = new Color[columns * rows];
        InitRects(canvasWidth, canvasHeight);
//		Color swapsColor = findContrastingColor (rectangles [0, 0].rec.color);
//		GameObject.Find ("Swaps").GetComponent<Text> ().color = swapsColor;
//		Color scoreColor = findContrastingColor (rectangles [0, columns - 1].rec.color);
//		GameObject.Find ("Score").GetComponent<Text> ().color = scoreColor;

        //sets up the texts for the number of swaps performed and the current score
        RectTransform swapTransform = GameObject.Find("Swaps").GetComponent <RectTransform> ();

        swapTransform.localPosition = new Vector2(-canvasWidth / 2, swapTransform.localPosition.y);
        RectTransform scoreTransform = GameObject.Find("Score").GetComponent <RectTransform> ();

        scoreTransform.localPosition = new Vector2(canvasWidth / 2, scoreTransform.localPosition.y);

        //sets up the GameObject that will contain all cats (i.e. dots)
        dotHolder = GameObject.Find("Dots").transform;
        dotHolder.DetachChildren();
        dotHolder.localPosition = new Vector3((float)-(canvasWidth / 2), (float)(canvasHeight / 2), -2f);
        dotHolder.position      = new Vector3(dotHolder.position.x, dotHolder.position.y, -2f);

        //tries to avoid overcrowded rectangles by considering the size of the screen,
        //still to improve
        if (Screen.width <= firstHorizontalBound && columns > minCols)
        {
            horDotPerRect--;
            if (Screen.width <= secondHorizontalBound && columns == maxCols)
            {
                horDotPerRect--;
                vertDotPerRect++;
            }
        }
        if (rows == minRows || (rows < maxRows && columns > minCols))
        {
            vertDotPerRect++;
        }

        dotColors = new Color[horDotPerRect * columns * vertDotPerRect * rows];

        //makes the HUD smaller when there are too many rows of cats,
        //which could overlap the text information
        if (rows == maxRows)
        {
            Transform hudTransform = GameObject.Find("HUD").transform;
            for (int i = 0; i < hudTransform.childCount; i++)
            {
                Vector3 childScale = hudTransform.GetChild(i).localScale;
                hudTransform.GetChild(i).localScale = childScale * 4 / 5;
            }
        }

        //xStep and yStep mark the distance between two cats and
        //the steps of the cycles that scan the game board
        float xStep = (canvasRect.rect.width / ((horDotPerRect + 1) * columns));

        xToAvoid = canvasRect.rect.width / columns;
        float yStep = (canvasRect.rect.height / ((vertDotPerRect + 1) * rows));

        yToAvoid = (canvasRect.rect.height / rows);

        int rectCol = 0;
        int rectRow = 0;

        totalDotCount = 0;
        int dotColIndex = 0;

        List <Dot> tempDots = new List <Dot>();

        for (float y = yStep; y < canvasHeight; y = y + yStep)
        {
            rectCol = 0;
            //if the y coordinate does NOT fall on the horizontal line between two background rectangles
            if (!Mathf.Approximately(y, (yToAvoid * (rectRow + 1))))
            {
                for (float x = xStep; x < canvasWidth; x = x + xStep)
                {
                    //if the x coordinate does NOT fall on the vertical line between two background rectangles
                    if (!Mathf.Approximately(x, (xToAvoid * (rectCol + 1))))
                    {
                        //this part helps avoiding that the last rectangle contains cats
                        //of the same colour at the beginning of the match;
                        //to do so, the colour of the last rectangle is 4 times more
                        //likely to be selected for cats
                        int dotIndex = Random.Range(0, dots.Count + 2);
                        if (dotIndex > dots.Count - 1)
                        {
                            dotIndex = dots.Count - 1;
                        }

                        bool set        = false;
                        int  checkValue = 0;
                        while (!set && checkValue < rows * columns)
                        {
                            ;
                            Dot dot = dots [dotIndex];
                            if (dot.color != rectangles [rectRow, rectCol].rec.color || dots.Count == 1)
                            {
                                InstantiateImage(dot.img, dotHolder, "Dot" + (totalDotCount + 1), new Vector3((float)x, (float)-y, 0f),
                                                 dotScaleVector, dot.color);

                                set = true;
                                dot.count++;
                                totalDotCount++;

                                dotColors [dotColIndex] = dot.color;
                                dotColIndex++;

                                //removes a color with no dots left to place in the game
                                if (dot.count == horDotPerRect * vertDotPerRect)
                                {
                                    dots.RemoveAt(dotIndex);
                                }
                                //refills original dot list
                                if (tempDots.Count != 0)
                                {
                                    foreach (Dot tempDot in tempDots)
                                    {
                                        dots.Add(tempDot);
                                    }
                                    tempDots.RemoveAll(returnTrue);
                                }
                                if (dot.color == rectangles [rectRow, rectCol].rec.color)
                                {
                                    rectangles [rectRow, rectCol].count++;
                                    setDots++;
                                }
                            }
                            else
                            {
                                tempDots.Add(dots[dotIndex]);
                                dots.RemoveAt(dotIndex);
                                dotIndex = Random.Range(0, dots.Count);
                                checkValue++;
                            }
                        }
                        //if the x coordinate DOES fall on the horizontal line between two background rectangles
                    }
                    else
                    {
                        rectCol++;
                    }
                }
                //if the y coordinate DOES fall on the horizontal line between two background rectangles
            }
            else
            {
                rectRow++;
            }
        }
        GameObject.Find("Score").GetComponent <Text> ().text = "Score: " + setDots + "/" + totalDotCount + " ";
    }
Exemple #17
0
 /// <summary>
 /// RGB转颜色字符串
 /// </summary>
 string GetColorString(Color color)
 {
     return(ColorUtility.ToHtmlStringRGBA(color));
 }
Exemple #18
0
    public void MudarOpcaoComVal(int quanto, int rowCellCount = -1)
    {
        if (quanto != 0)
        {
            UmaOpcao[] umaS = painelDeTamanhoVariavel.GetComponentsInChildren <UmaOpcao>();

            if (quanto > 0)
            {
                if (OpcaoEscolhida + quanto < umaS.Length)
                {
                    OpcaoEscolhida += quanto;
                }
                else
                {
                    OpcaoEscolhida = 0;
                }
            }
            else if (quanto < 0)
            {
                if (OpcaoEscolhida + quanto >= 0)
                {
                    OpcaoEscolhida += quanto;
                }
                else
                {
                    OpcaoEscolhida = umaS.Length - 1;
                }
            }

            for (int i = 0; i < umaS.Length; i++)
            {
                if (i == OpcaoEscolhida)
                {
                    if (GameController.g != null)
                    {
                        umaS[i].GetComponent <UmaOpcao>().SpriteDoItem.sprite = GameController.g.El.uiDestaque;
                    }
                    else
                    {
                        Color C;
                        ColorUtility.TryParseHtmlString("#B61B1BFF", out C);
                        umaS[i].GetComponent <UmaOpcao>().SpriteDoItem.color = C;
                    }
                }
                else
                {
                    if (GameController.g != null)
                    {
                        umaS[i].GetComponent <UmaOpcao>().SpriteDoItem.sprite = GameController.g.El.uiDefault;
                    }
                    else
                    {
                        Color C;
                        ColorUtility.TryParseHtmlString("#1B4AB6FF", out C);
                        umaS[i].GetComponent <UmaOpcao>().SpriteDoItem.color = C;
                    }
                }
            }

            if (sr != null)
            {
                if (sr.verticalScrollbar || sr.horizontalScrollbar)
                {
                    AjeitaScroll(umaS, rowCellCount);
                }
                else
                {
                    Debug.Log("erro scroll 2");
                }
            }

            else
            {
                Debug.Log("erro no scrool");
            }
        }
    }
Exemple #19
0
 private static string GetChannelColor(ChatChannel channel)
 {
     if (channel.HasFlag(ChatChannel.OOC))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.oocColor));
     }
     if (channel.HasFlag(ChatChannel.Ghost))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.ghostColor));
     }
     if (channel.HasFlag(ChatChannel.Binary))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.binaryColor));
     }
     if (channel.HasFlag(ChatChannel.Supply))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.supplyColor));
     }
     if (channel.HasFlag(ChatChannel.CentComm))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.centComColor));
     }
     if (channel.HasFlag(ChatChannel.Command))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.commandColor));
     }
     if (channel.HasFlag(ChatChannel.Common))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.commonColor));
     }
     if (channel.HasFlag(ChatChannel.Engineering))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.engineeringColor));
     }
     if (channel.HasFlag(ChatChannel.Medical))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.medicalColor));
     }
     if (channel.HasFlag(ChatChannel.Science))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.scienceColor));
     }
     if (channel.HasFlag(ChatChannel.Security))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.securityColor));
     }
     if (channel.HasFlag(ChatChannel.Service))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.serviceColor));
     }
     if (channel.HasFlag(ChatChannel.Local))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.localColor));
     }
     if (channel.HasFlag(ChatChannel.Combat))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.combatColor));
     }
     if (channel.HasFlag(ChatChannel.Warning))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.warningColor));
     }
     if (channel.HasFlag(ChatChannel.Blob))
     {
         return(ColorUtility.ToHtmlStringRGBA(Instance.blobColor));
     }
     return(ColorUtility.ToHtmlStringRGBA(Instance.defaultColor));
 }
Exemple #20
0
    protected void IniciarHUD(int quantidade, TipoDeRedimensionamento tipo = TipoDeRedimensionamento.vertical)
    {
        OpcaoEscolhida = 0;
        painelDeTamanhoVariavel.parent.parent.gameObject.SetActive(true);

        if (GameController.g != null)
        {
            commandR = GameController.g.CommandR;
        }
        else
        {
            commandR = new CommandReader();
        }

        itemDoContainer.SetActive(true);

        if (tipo == TipoDeRedimensionamento.vertical)
        {
            RedimensionarUI.NaVertical(painelDeTamanhoVariavel, itemDoContainer, quantidade);
        }
        else if (tipo == TipoDeRedimensionamento.emGrade)
        {
            RedimensionarUI.EmGrade(painelDeTamanhoVariavel, itemDoContainer, quantidade);
        }
        else if (tipo == TipoDeRedimensionamento.horizontal)
        {
            RedimensionarUI.NaHorizontal(painelDeTamanhoVariavel, itemDoContainer, quantidade);
        }

        for (int i = 0; i < quantidade; i++)
        {
            GameObject G = ParentearNaHUD.Parentear(itemDoContainer, painelDeTamanhoVariavel);
            SetarComponenteAdaptavel(G, i);

            G.name += i.ToString();
            if (i == OpcaoEscolhida)
            {
                if (GameController.g != null)
                {
                    G.GetComponent <UmaOpcao>().SpriteDoItem.sprite = GameController.g.El.uiDestaque;
                }
                else
                {
                    Color C;
                    ColorUtility.TryParseHtmlString("#B61B1BFF", out C);
                    G.GetComponent <UmaOpcao>().SpriteDoItem.color = C;
                }
            }
        }

        itemDoContainer.SetActive(false);

        if (sr != null)
        {
            if (sr.verticalScrollbar)
            {
                sr.verticalScrollbar.value = 1;
            }
        }

        AgendaScrollPos();
    }
Exemple #21
0
        private void ParseControllerState(ControllerState state, JObject json, ControllerState baseState)
        {
            ParseObjectState(state, json, baseState);
            UnityEngine.Color tmp;

            state.StoryboardOpacity = (float?)json.SelectToken("storyboard_opacity") ?? state.StoryboardOpacity;
            state.UiOpacity         = (float?)json.SelectToken("ui_opacity") ?? state.UiOpacity;
            state.ScanlineOpacity   = (float?)json.SelectToken("scanline_opacity") ?? state.ScanlineOpacity;
            state.BackgroundDim     = (float?)json.SelectToken("background_dim") ?? state.BackgroundDim;

            state.Size        = (float?)json.SelectToken("size") ?? state.Size;
            state.Fov         = (float?)json.SelectToken("fov") ?? state.Fov;
            state.Perspective = (bool?)json.SelectToken("perspective") ?? state.Perspective;
            state.X           = (float?)json.SelectToken("x") ?? state.X;
            state.Y           = (float?)json.SelectToken("y") ?? state.Y;
            state.RotX        = (float?)json.SelectToken("rot_x") ?? state.RotX;
            state.RotY        = (float?)json.SelectToken("rot_y") ?? state.RotY;
            state.RotZ        = (float?)json.SelectToken("rot_z") ?? state.RotZ;

            if (ColorUtility.TryParseHtmlString((string)json.SelectToken("scanline_color"), out tmp))
            {
                state.ScanlineColor = new Color {
                    R = tmp.r, G = tmp.g, B = tmp.b, A = tmp.a
                }
            }
            ;
            state.ScanlineSmoothing     = (bool?)json.SelectToken("scanline_smoothing") ?? state.ScanlineSmoothing;
            state.OverrideScanlinePos   = (bool?)json.SelectToken("override_scanline_pos") ?? state.OverrideScanlinePos;
            state.ScanlinePos           = (float?)json.SelectToken("scanline_pos") ?? state.ScanlinePos;
            state.NoteOpacityMultiplier =
                (float?)json.SelectToken("note_opacity_multiplier") ?? state.NoteOpacityMultiplier;
            if (ColorUtility.TryParseHtmlString((string)json.SelectToken("note_ring_color"), out tmp))
            {
                state.NoteRingColor = new Color {
                    R = tmp.r, G = tmp.g, B = tmp.b, A = tmp.a
                }
            }
            ;
            var fillColors = json.SelectToken("note_fill_colors") != null &&
                             json.SelectToken("note_fill_colors").Type != JTokenType.Null
                ? json.SelectToken("note_fill_colors").Values <string>().ToList()
                : new List <string>();

            if (!fillColors.IsNullOrEmpty())
            {
                state.NoteFillColors = new List <Color>();
                for (var i = 0; i < 10; i++)
                {
                    if (i >= fillColors.Count)
                    {
                        state.NoteFillColors.Add(null);
                        continue;
                    }

                    var fillColor = fillColors[i];
                    if (ColorUtility.TryParseHtmlString(fillColor, out tmp))
                    {
                        state.NoteFillColors.Add(new Color {
                            R = tmp.r, G = tmp.g, B = tmp.b, A = tmp.a
                        });
                    }
                }
            }

            state.Bloom          = (bool?)json.SelectToken("bloom") ?? state.Bloom;
            state.BloomIntensity = (float?)json.SelectToken("bloom_intensity") ?? state.BloomIntensity;

            state.Vignette          = (bool?)json.SelectToken("vignette") ?? state.Vignette;
            state.VignetteIntensity = (float?)json.SelectToken("vignette_intensity") ?? state.VignetteIntensity;

            if (ColorUtility.TryParseHtmlString((string)json.SelectToken("vignette_color"), out tmp))
            {
                state.VignetteColor = new Color {
                    R = tmp.r, G = tmp.g, B = tmp.b, A = tmp.a
                }
            }
            ;
            state.VignetteStart = (float?)json.SelectToken("vignette_start") ?? state.VignetteStart;
            state.VignetteEnd   = (float?)json.SelectToken("vignette_end") ?? state.VignetteEnd;

            state.Chromatic          = (bool?)json.SelectToken("chromatic") ?? state.Chromatic;
            state.ChromaticIntensity = (float?)json.SelectToken("chromatic_intensity") ?? state.ChromaticIntensity;
            state.ChromaticStart     = (float?)json.SelectToken("chromatic_start") ?? state.ChromaticStart;
            state.ChromaticEnd       = (float?)json.SelectToken("chromatic_end") ?? state.ChromaticEnd;

            state.RadialBlur          = (bool?)json.SelectToken("radial_blur") ?? state.RadialBlur;
            state.RadialBlurIntensity = (float?)json.SelectToken("radial_blur_intensity") ?? state.RadialBlurIntensity;

            state.ColorAdjustment = (bool?)json.SelectToken("color_adjustment") ?? state.ColorAdjustment;
            state.Brightness      = (float?)json.SelectToken("brightness") ?? state.Brightness;
            state.Saturation      = (float?)json.SelectToken("saturation") ?? state.Saturation;
            state.Contrast        = (float?)json.SelectToken("contrast") ?? state.Contrast;

            state.ColorFilter = (bool?)json.SelectToken("color_filter") ?? state.ColorFilter;
            if (ColorUtility.TryParseHtmlString((string)json.SelectToken("color_filter_color"), out tmp))
            {
                state.ColorFilterColor = new Color {
                    R = tmp.r, G = tmp.g, B = tmp.b, A = tmp.a
                }
            }
            ;

            state.GrayScale          = (bool?)json.SelectToken("gray_scale") ?? state.GrayScale;
            state.GrayScaleIntensity = (float?)json.SelectToken("gray_scale_intensity") ?? state.GrayScaleIntensity;

            state.Noise          = (bool?)json.SelectToken("noise") ?? state.Noise;
            state.NoiseIntensity = (float?)json.SelectToken("noise_intensity") ?? state.NoiseIntensity;

            state.Sepia          = (bool?)json.SelectToken("sepia") ?? state.Sepia;
            state.SepiaIntensity = (float?)json.SelectToken("sepia_intensity") ?? state.SepiaIntensity;

            state.Dream          = (bool?)json.SelectToken("dream") ?? state.Dream;
            state.DreamIntensity = (float?)json.SelectToken("dream_intensity") ?? state.DreamIntensity;

            state.Fisheye          = (bool?)json.SelectToken("fisheye") ?? state.Fisheye;
            state.FisheyeIntensity = (float?)json.SelectToken("fisheye_intensity") ?? state.FisheyeIntensity;

            state.Shockwave      = (bool?)json.SelectToken("shockwave") ?? state.Shockwave;
            state.ShockwaveSpeed = (float?)json.SelectToken("shockwave_speed") ?? state.ShockwaveSpeed;

            state.Focus          = (bool?)json.SelectToken("focus") ?? state.Focus;
            state.FocusIntensity = (float?)json.SelectToken("focus_intensity") ?? state.FocusIntensity;
            state.FocusSize      = (float?)json.SelectToken("focus_size") ?? state.FocusSize;
            state.FocusSpeed     = (float?)json.SelectToken("focus_speed") ?? state.FocusSpeed;
            if (ColorUtility.TryParseHtmlString((string)json.SelectToken("focus_color"), out tmp))
            {
                state.FocusColor = new Color {
                    R = tmp.r, G = tmp.g, B = tmp.b, A = tmp.a
                }
            }
            ;

            state.Glitch          = (bool?)json.SelectToken("glitch") ?? state.Glitch;
            state.GlitchIntensity = (float?)json.SelectToken("glitch_intensity") ?? state.GlitchIntensity;

            state.Artifact             = (bool?)json.SelectToken("artifact") ?? state.Artifact;
            state.ArtifactIntensity    = (float?)json.SelectToken("artifact_intensity") ?? state.ArtifactIntensity;
            state.ArtifactColorisation =
                (float?)json.SelectToken("artifact_colorisation") ?? state.ArtifactColorisation;
            state.ArtifactParasite = (float?)json.SelectToken("artifact_parasite") ?? state.ArtifactParasite;
            state.ArtifactNoise    = (float?)json.SelectToken("artifact_noise") ?? state.ArtifactNoise;

            state.Arcade                 = (bool?)json.SelectToken("arcade") ?? state.Arcade;
            state.ArcadeIntensity        = (float?)json.SelectToken("arcade_intensity") ?? state.ArcadeIntensity;
            state.ArcadeInterferanceSize =
                (float?)json.SelectToken("arcade_interference_size") ?? state.ArcadeInterferanceSize;
            state.ArcadeInterferanceSpeed =
                (float?)json.SelectToken("arcade_interference_speed") ?? state.ArcadeInterferanceSpeed;
            state.ArcadeContrast = (float?)json.SelectToken("arcade_contrast") ?? state.ArcadeContrast;

            state.Chromatical          = (bool?)json.SelectToken("chromatical") ?? state.Chromatical;
            state.ChromaticalFade      = (float?)json.SelectToken("chromatical_fade") ?? state.ChromaticalFade;
            state.ChromaticalIntensity =
                (float?)json.SelectToken("chromatical_intensity") ?? state.ChromaticalIntensity;
            state.ChromaticalSpeed = (float?)json.SelectToken("chromatical_speed") ?? state.ChromaticalSpeed;

            state.Tape = (bool?)json.SelectToken("tape") ?? state.Tape;
        }
    }
}
Exemple #22
0
    private string GetMessage(string message, LogType type)
    {
        var color = ColorUtility.ToHtmlStringRGBA(logTypeColors[type]);

        return("<color=#" + color + ">" + message + "</color>" + NEWLINE);
    }
Exemple #23
0
 //gets hexa InputField value
 public void SetHexa(string value)
 {
     if (interact)
     {
         if (ColorUtility.TryParseHtmlString("#" + value, out Color c))
         {
             if (!useA)
             {
                 c.a = 1;
             }
             modifiedColor = c;
             RecalculateMenu(true);
         }
         else
         {
             hexaComponent.text = useA ? ColorUtility.ToHtmlStringRGBA(modifiedColor) : ColorUtility.ToHtmlStringRGB(modifiedColor);
         }
     }
 }
Exemple #24
0
 // Converts Color to Hex for display - totally for debug only
 private string ConverToHexValue(Color32 Input)
 {
     return(ColorUtility.ToHtmlStringRGB(Input).ToString());
 }
    IEnumerator MovePlayer(int direction)
    {
        int landingPosition = players[currentPlayer].currentPosition + dice.dieResult * direction;

        if (direction == 1)
        {
            for (int i = players[currentPlayer].currentPosition; i < landingPosition; i++)
            {
                if (i == -1)
                {
                    i++;
                }
                if (landingPosition == 0)
                {
                    players[currentPlayer].transform.position = squares[0].transform.position + squares[0].playerPositions[currentPlayer];
                    break;
                }
                float elapsed  = 0f;
                float duration = 0.2f;

                // Animate player token movement over time, square by square
                // (in order for it to properly follow the path it should take)
                while (elapsed < duration)
                {
                    players[currentPlayer].transform.position = Vector3.Lerp(squares[i].transform.position + squares[i].playerPositions[currentPlayer],
                                                                             squares[i + 1].transform.position + squares[i + 1].playerPositions[currentPlayer],
                                                                             elapsed / duration);
                    elapsed += Time.deltaTime;
                    yield return(null);
                }
            }
        }
        else
        {
            for (int i = players[currentPlayer].currentPosition; i > landingPosition; i--)
            {
                float elapsed  = 0f;
                float duration = 0.2f;

                while (elapsed < duration)
                {
                    players[currentPlayer].transform.position = Vector3.Lerp(squares[i].transform.position + squares[i].playerPositions[currentPlayer],
                                                                             squares[i - 1].transform.position + squares[i - 1].playerPositions[currentPlayer],
                                                                             elapsed / duration);
                    elapsed += Time.deltaTime;
                    yield return(null);
                }
            }
        }

        players[currentPlayer].currentPosition += dice.dieResult * direction;

        // Check the type of the square player landed on, and act accordingly
        switch (squares[players[currentPlayer].currentPosition].squareType)
        {
        case SquareType.Normal:
            break;

        case SquareType.DoubleTurn:
            StartCoroutine(StartPlayerTurn());
            yield break;

        case SquareType.SkipTurn:
            players[currentPlayer].skipTurn = true;
            break;

        // Find the ladder/snake that starts on the current square, then animate
        // player token's movement along the spline of the SpriteShape
        case SquareType.Ladder:
            SpriteShapeController ladder = GameObject.Find("SnakeLadder_" + players[currentPlayer].currentPosition.ToString()).GetComponent <SpriteShapeController>();
            Vector3 start = board.transform.rotation * ladder.spline.GetPosition(1);
            Vector3 end   = board.transform.rotation * ladder.spline.GetPosition(0);

            float elapsed  = 0f;
            float duration = 1.5f;

            while (elapsed < duration)
            {
                players[currentPlayer].transform.position = Vector3.Lerp(start, end, elapsed / duration);
                elapsed += Time.deltaTime;
                yield return(null);
            }

            players[currentPlayer].currentPosition    = squares[players[currentPlayer].currentPosition].destinationSquare;
            players[currentPlayer].transform.position = squares[players[currentPlayer].currentPosition].transform.position + squares[players[currentPlayer].currentPosition].playerPositions[currentPlayer];
            break;

        case SquareType.Snake:
            SpriteShapeController snake = GameObject.Find("SnakeLadder_" + players[currentPlayer].currentPosition.ToString()).GetComponent <SpriteShapeController>();
            start = snake.spline.GetPosition(1);
            end   = snake.spline.GetPosition(0);

            elapsed  = 0f;
            duration = 1.5f;

            while (elapsed < duration)
            {
                players[currentPlayer].transform.position = Vector3.Lerp(start, end, elapsed / duration);
                elapsed += Time.deltaTime;
                yield return(null);
            }

            players[currentPlayer].currentPosition    = squares[players[currentPlayer].currentPosition].destinationSquare;
            players[currentPlayer].transform.position = squares[players[currentPlayer].currentPosition].transform.position + squares[players[currentPlayer].currentPosition].playerPositions[currentPlayer];
            break;
        }

        // If a player reached the end (square 100) congratulate the winner
        // and return to Main Menu after a celebratory pause
        if (IsGameOver())
        {
            textGameOver.gameObject.SetActive(true);
            textGameOver.text = "Congratulations!\n" +
                                "<color=#" + ColorUtility.ToHtmlStringRGB(playerColors[currentPlayer]) + ">" +
                                ((PlayerColorNames)currentPlayer).ToString() + " player</color> wins!";
            yield return(new WaitForSeconds(8f));

            textGameOver.gameObject.SetActive(true);
            UIButtonPress_MainMenu();
            buttonContinue.interactable = false;
            yield break;
        }

        currentPlayer = (currentPlayer + 1) % numberOfPlayers;
        StartCoroutine(StartPlayerTurn());
    }
Exemple #26
0
    // Converts RGB to Hex for display - totally for debug only
    private string ConverToHexValue(byte r, byte g, byte b)
    {
        Color32 NewCol = new Color32(r, g, b, 255);

        return(ColorUtility.ToHtmlStringRGB(NewCol).ToString());
    }
Exemple #27
0
 /// <summary> Specify a color for this node type </summary>
 /// <param name="hex"> HEX color value </param>
 public NodeTintAttribute(string hex)
 {
     ColorUtility.TryParseHtmlString(hex, out color);
 }
Exemple #28
0
 /// <summary>
 /// 色を変更してログを出力します
 /// </summary>
 /// <param name="_message">メッセージ</param>
 /// <param name="_color">文字の色</param>
 public static void Log(string _message, Color _color)
 {
     UnityEngine.Debug.Log("<_color=#" + ColorUtility.ToHtmlStringRGB(_color) + "> " + _message + "</_color>");
 }
Exemple #29
0
        public static string WrapTextWithColorTag(string input, Color color)
        {
            var colorString = "#" + ColorUtility.ToHtmlStringRGBA(color);

            return(WrapTextWithColorTag(input, colorString));
        }
Exemple #30
0
    public void SetupSprites()
    {
        CustomisationStorage customisationStorage = null;

        if (ThisCharacter.SerialisedBodyPartCustom == null)
        {
            //TODO : (Max) - Fix SerialisedBodyPartCustom being null on Dummy players
            Logger.LogError($"{gameObject} has spawned with null bodyPart customizations. This error should only appear for Dummy players only.");
            return;
        }

        foreach (var Custom in ThisCharacter.SerialisedBodyPartCustom)
        {
            if (livingHealthMasterBase.name == Custom.path)
            {
                customisationStorage = Custom;
                break;
            }
        }

        if (customisationStorage != null)
        {
            BodyPartDropDownOrgans.OnPlayerBodyDeserialise(null, customisationStorage.Data, livingHealthMasterBase);
        }


        foreach (var bodyPart in livingHealthMasterBase.BodyPartList)
        {
            SubSetBodyPart(bodyPart, "");

            //TODO: horrible, remove -- organ prefabs have bodyparts
            foreach (var organ in bodyPart.OrganList)
            {
                var bodyPartOrgan = organ.GetComponent <BodyPart>();
                SubSetBodyPart(bodyPartOrgan, $"/{bodyPart.name}");
            }
        }

        PlayerHealthData SetRace = null;

        foreach (var Race in RaceSOSingleton.Instance.Races)
        {
            if (Race.name == ThisCharacter.Species)
            {
                SetRace = Race;
            }
        }

        List <IntName> ToClient = new List <IntName>();

        foreach (var Customisation in SetRace.Base.CustomisationSettings)
        {
            ExternalCustomisation externalCustomisation = null;
            foreach (var EC in ThisCharacter.SerialisedExternalCustom)
            {
                if (EC.Key == Customisation.CustomisationGroup.name)
                {
                    externalCustomisation = EC;
                }
            }

            if (externalCustomisation == null)
            {
                continue;
            }

            var SpriteHandlerNorder = Spawn.ServerPrefab(ToInstantiateSpriteCustomisation.gameObject, null, CustomisationSprites.transform)
                                      .GameObject.GetComponent <SpriteHandlerNorder>();
            SpriteHandlerNorder.transform.localPosition = Vector3.zero;
            SpriteHandlerNorder.name = Customisation.CustomisationGroup.ThisType.ToString();

            var newone = new IntName();
            newone.Int =
                CustomNetworkManager.Instance.IndexLookupSpawnablePrefabs[ToInstantiateSpriteCustomisation.gameObject];

            newone.Name = Customisation.CustomisationGroup.ThisType.ToString();
            ToClient.Add(newone);

            OpenSprites.Add(SpriteHandlerNorder);
            //SubSetBodyPart
            foreach (var Sprite_s in Customisation.CustomisationGroup.PlayerCustomisations)
            {
                if (Sprite_s.Name == externalCustomisation.SerialisedValue.SelectedName)
                {
                    SpriteHandlerNorder.SpriteHandler.SetSpriteSO(Sprite_s.SpriteEquipped);
                    SpriteHandlerNorder.SetSpriteOrder(new SpriteOrder(Customisation.CustomisationGroup.SpriteOrder));
                    newone.Data = JsonConvert.SerializeObject(new SpriteOrder(SpriteHandlerNorder.SpriteOrder));
                    Color setColor = Color.black;
                    ColorUtility.TryParseHtmlString(externalCustomisation.SerialisedValue.Colour, out setColor);
                    setColor.a = 1;
                    SpriteHandlerNorder.SpriteHandler.SetColor(setColor);
                }
            }
        }
        GetComponent <RootBodyPartController>().PlayerSpritesData = JsonConvert.SerializeObject(ToClient);

        SetSurfaceColour();
        OnDirectionChange(directional.CurrentDirection);
    }