Example #1
0
        /// <summary>
        /// LeftMouseDownEvent on Pearl(button)
        /// </summary>
        /// <param name="button"></param>
        public void Pearl_LeftClick(System.Windows.Controls.Button button)
        {
            Int32.TryParse(button.Uid, out int id);
            var pearl = PearlGrid.Pearls.Find(x => x.Id == id);

            pearl.FillColor = ColorOne.Clone();
        }
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var textureSize = TextureSize.GetFirstValue(payload.Data);

            var entropy = Entropy.GetFirstValue(payload.Data);

            var entropySteps = (from step in EntropySteps.GetFirstValue(payload.Data).Split(',') select float.Parse(step.Trim())).ToArray();

            var minimumEntropyLevels = MinimumEntropyLevels.GetFirstValue(payload.Data);

            var colorOne = ColorOne.GetFirstValue(payload.Data);
            var colorTwo = ColorTwo.GetFirstValue(payload.Data);

            var entropyGridTexture = new Texture2D(textureSize, textureSize);

            var entropyLevel = 0;

            while (entropyLevel < entropySteps.Length && entropy > entropySteps[entropyLevel])
            {
                entropyLevel++;
            }

            entropyLevel += minimumEntropyLevels;

            var pixels = new Color[textureSize * textureSize];

            for (int x = 0; x < textureSize; x++)
            {
                for (int y = 0; y < textureSize; y++)
                {
                    var xImpact = Mathf.FloorToInt((x / (float)textureSize) * entropyLevel);
                    var yImpact = Mathf.FloorToInt((y / (float)textureSize) * entropyLevel);
                    pixels[x + y * textureSize] = ((xImpact + yImpact) % 2) == 1 ? colorOne : colorTwo;
                }
            }

            entropyGridTexture.SetPixels(pixels);

            entropyGridTexture.Apply();

            TextureTarget.SetValue(entropyGridTexture, payload.Data);

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }