Esempio n. 1
0
            public IEnumerator <TaskContract> Run()
            {
                AsyncOperationHandle <TextAsset> asyncHandle = Addressables.LoadAssetAsync <TextAsset>("colours");

                yield return(asyncHandle.Continue());

                Dictionary <string, object> colourData = Json.Deserialize(asyncHandle.Result.text) as Dictionary <string, object>;

                if (colourData == null)
                {
                    yield break;
                }
                Client.EnterMenu -= LoadColorMenuEvent;
                // Logging.MetaLog((List<object>)((colourData["Colours"] as Dictionary<string, object>)["Data"] as Dictionary<string, object>)["Slots"]);
                // Generate color map
                List <object> hexColors =
                    (((colourData["Colours"] as Dictionary <string, object>)?["Data"] as Dictionary <string, object>)?
                     ["Slots"] as List <object>);
                int count = 0;

                colorMap = new Dictionary <BlockColor, float[]>();
                for (byte d = 0; d < 10; d++)
                {
                    foreach (BlockColors c in Enum.GetValues(typeof(BlockColors)))
                    {
                        if (c != BlockColors.Default)
                        {
                            BlockColor colorStruct = new BlockColor
                            {
                                Color    = c,
                                Darkness = d,
                            };
                            Color pixel = Images.PixelUtility.PixelHex((string)hexColors[count]);
                            colorMap[colorStruct] = new float[] { pixel.r, pixel.g, pixel.b };
                            count++;
                        }
                    }
                    yield return(asyncHandle.Continue());
                }
            }