Ejemplo n.º 1
0
        protected override void _PreRender(CancellationTokenSource tokenSource = null)
        {
            _elementData = new EffectIntents();

            if (_data == null)
            {
                return;
            }

            ICommand command = null;

            switch (ValueType)
            {
            case CustomValueType._8Bit:
                command = new _8BitCommand(Value8Bit);
                break;

            case CustomValueType._16Bit:
                command = new _16BitCommand(Value16Bit);
                break;

            case CustomValueType._32Bit:
                command = new _32BitCommand(Value32Bit);
                break;

            case CustomValueType._64Bit:
                command = new _64BitCommand(Value64Bit);
                break;

            case CustomValueType.Color:
                command = new ColorCommand(ColorValue);
                break;

            case CustomValueType.String:
                command = new StringCommand(StringValue);
                break;
            }

            CommandValue value = new CommandValue(command);

            foreach (IElementNode node in TargetNodes)
            {
                foreach (var leafNode in node.GetLeafEnumerator())
                {
                    if (tokenSource != null && tokenSource.IsCancellationRequested)
                    {
                        return;
                    }

                    IIntent intent = new CommandIntent(value, TimeSpan);
                    _elementData.AddIntentForElement(leafNode.Element.Id, intent, TimeSpan.Zero);
                }
            }
        }
Ejemplo n.º 2
0
 public override void Handle(ColorCommand obj)
 {
     if (CombinatorValue == null)
     {
         CombinatorValue = new _8BitCommand(RGBValue.GetGrayscaleLevel(obj.CommandValue));
     }
     else
     {
         byte value1 = (CombinatorValue as _8BitCommand).CommandValue;
         byte value2 = RGBValue.GetGrayscaleLevel(obj.CommandValue);
         CombinatorValue = new _8BitCommand(Math.Max(value1, value2));
     }
 }
Ejemplo n.º 3
0
 public override void Handle(ColorCommand obj)
 {
     if (CombinatorValue == null)
     {
         CombinatorValue = new _16BitCommand(ColorValue.GetGrayscaleLevel(obj.CommandValue));
     }
     else
     {
         ushort value1 = CombinatorValue.CommandValue;
         ushort value2 = ColorValue.GetGrayscaleLevel(obj.CommandValue);
         CombinatorValue = new _16BitCommand(Math.Max(value1, value2));
     }
 }
Ejemplo n.º 4
0
 public override void Handle(ColorCommand obj)
 {
     if (CombinatorValue == null)
     {
         CombinatorValue = obj;
     }
     else
     {
         System.Drawing.Color value1 = (CombinatorValue as ColorCommand).CommandValue;
         System.Drawing.Color value2 = obj.CommandValue;
         CombinatorValue = _MergeColorNaively(value1, value2);
     }
 }
        public static ColorCommand Parse(string input, out int endPosition)
        {
            ColorCommand result    = null;
            int          cmdLength = 0;

            if (input.Length >= 1)
            {
                var cmdSymbol = input[0];

                // try to handle texU command
                if (cmdSymbol >= '0' && cmdSymbol <= '9')
                {
                    result    = SetTexUCommand.Parse(cmdSymbol);
                    cmdLength = 1;
                }
                else
                {
                    string cmdArgs = input.Substring(1);

                    int setColorLength = 0;
                    switch (cmdSymbol)
                    {
                    case 'c': result = SetColorCommand.Parse(cmdArgs, false, false, out setColorLength); break;

                    case 'C': result = SetColorCommand.Parse(cmdArgs, false, true, out setColorLength); break;

                    case 'g': result = SetColorCommand.Parse(cmdArgs, true, false, out setColorLength); break;

                    case 'G': result = SetColorCommand.Parse(cmdArgs, true, true, out setColorLength); break;
                    }

                    cmdLength = 1 + setColorLength;
                }
            }

            if (result != null)
            {
                endPosition = cmdLength;
            }
            else
            {
                endPosition = 0;
            }

            return(result);
        }
Ejemplo n.º 6
0
        public void TestMultipleCreateCommands()
        {
            Action  action        = Action.Parse("create name foo,   color  red;activate specular;");
            Trigger firstTrigger  = action.Triggers.First();
            Command firstCommand  = firstTrigger.Commands.First();
            Command secondCommand = firstTrigger.Commands.ElementAt(1);

            Assert.IsTrue(firstTrigger is CreateTrigger);
            Assert.IsTrue(firstCommand is NameCommand);
            Assert.IsTrue(secondCommand is ColorCommand);

            NameCommand  nameCommand  = firstCommand as NameCommand;
            ColorCommand colorCommand = secondCommand as ColorCommand;

            Assert.IsNotNull(nameCommand);
            Assert.AreEqual("foo", nameCommand.Name);
            Assert.AreEqual(Color.Red, colorCommand.Color);
            Assert.IsFalse(colorCommand.IsTint);
        }
    static string RemoveColorCommands(string formattedString, out ColorCommandSet colorCommandSet)
    {
        colorCommandSet = new ColorCommandSet();

        System.Text.StringBuilder resultBuilder = new System.Text.StringBuilder(formattedString.Length);

        for (int i = 0; i < formattedString.Length; ++i)
        {
            var charIndex = formattedString[i];
            if (charIndex == '^')
            {
                if (i + 1 < formattedString.Length)
                {
                    if (formattedString[i + 1] == '^')
                    {
                        resultBuilder.Append('^');
                        i += 1;
                    }
                    else
                    {
                        int          cmdLength  = 0;
                        ColorCommand curCommand = ColorCommand.Parse(formattedString.Substring(i + 1), out cmdLength);

                        if (curCommand != null)
                        {
                            colorCommandSet.Add(resultBuilder.Length, curCommand);
                            i += cmdLength;
                        }
                    }
                }
            }
            else
            {
                resultBuilder.Append(charIndex);
            }
        }

        return(resultBuilder.ToString());
    }
Ejemplo n.º 8
0
 public void actionPerformed(Object button)
 {
     if (button == clearButton)
     {
         Debug.Log("クリア");
         history.clear();
         Scene loadScene = SceneManager.GetActiveScene();
         SceneManager.LoadScene(loadScene.name);
     }
     else if (button == redButton)
     {
         Debug.Log("赤色");
         Command cmd = new ColorCommand(canvas, Color.red);
         history.append(cmd);
         cmd.Execute();
     }
     else if (button == greenButton)
     {
         Debug.Log("緑色");
         Command cmd = new ColorCommand(canvas, Color.green);
         history.append(cmd);
         cmd.Execute();
     }
     else if (button == blueButton)
     {
         Debug.Log("青色");
         Command cmd = new ColorCommand(canvas, Color.blue);
         history.append(cmd);
         cmd.Execute();
     }
     else if (button == undoButton)
     {
         Debug.Log("戻った");
         Destroy(history.ball_list[history.ball_list.Count - 1]);
         history.ball_list.RemoveAt(history.ball_list.Count - 1);
         history.undo();
     }
 }
Ejemplo n.º 9
0
        public async Task <MessageModel> SendArgbColorCommand(ColorRequest request)
        {
            var color = new ColorCommand(request);

            return(await comandSender.SendMessage(color.message));
        }
Ejemplo n.º 10
0
 public override void Handle(IIntentState<RGBValue> obj)
 {
     EvaluatorValue = new ColorCommand(obj.GetValue().FullColor);
 }
Ejemplo n.º 11
0
 public override void Handle(IIntentState<DiscreteValue> obj)
 {
     DiscreteValue lightingValue = obj.GetValue();
     EvaluatorValue = new ColorCommand(lightingValue.FullColor);
 }
Ejemplo n.º 12
0
 virtual public void Handle(ColorCommand obj)
 {
 }
Ejemplo n.º 13
0
            public Ztunnel(int start, int stop)
            {
                this.start = start;
                this.stop  = stop;
                framedelta = 300;
                FRAMEDELTA = framedelta;

                lighttimes.Add(21000);
                lighttimes.Add(29750);
                lighttimes.Add(38350);
                lighttimes.Add(47050);

                const int ssettings =
                    Sprite.INTERPOLATE_MOVE | Sprite.EASE_FADE | Sprite.EASE_SCALE;

                points        = new vec3[CIRCLEAMOUNT * LENGTH];
                _points       = new vec3[points.Length];
                dots0         = new Odot[points.Length];
                dots          = new Odot[points.Length];
                pointfadetime = new int[points.Length];
                Random r = new Random("sunpy:3".GetHashCode());

                int[] fadeoffset = new int[CIRCLEAMOUNT];
                float y          = -FADEEND;

                for (int i = 0; i < LENGTH; i++)
                {
                    y += SPACING;
                    if (i % SEGLENGTH == 0)
                    {
                        y += (SEGSPACINGMOD - 1) * SPACING;
                        for (int j = 0; j < CIRCLEAMOUNT; j++)
                        {
                            fadeoffset[j] = -1;
                        }
                    }
                    float ang     = 0f;
                    int   k       = 0;
                    int   segment = 0;
                    for (int j = 0; j < CIRCLEAMOUNT; j++)
                    {
                        if (++k < SEGWIDTH)
                        {
                            ang += ANGINC;
                        }
                        else
                        {
                            k    = 0;
                            ang += ANGINC * (SEGWIDTH + 1);
                            segment++;
                            if (fadeoffset[segment] == -1)
                            {
                                int v = r.Next(FADEWINDOW - framedelta);
                                fadeoffset[segment] = sync(v);
                            }
                        }
                        int  idx = i * CIRCLEAMOUNT + j;
                        vec3 p   = v3(Zsc.mid);
                        p.x        += cos(ang) * Zsc.TUNNEL_RAD;
                        p.y        += y;
                        p.z        += sin(ang) * Zsc.TUNNEL_RAD;
                        points[idx] = p;
                        dots0[idx]  = new Odot(Sprite.SPRITE_DOT_6_12, ssettings);
                        dots[idx]   = new Odot(Sprite.SPRITE_DOT_6_12, ssettings | Sprite.SESDSM);
                        int ft = stop - FADEWINDOW + fadeoffset[segment];
                        pointfadetime[idx] = ft;
                        FadeCommand fc;
                        fc = new FadeCommand(ft, ft + FADETIME, 1f, 0f);
                        dots[idx].addCommandOverride(fc);
                        foreach (int lighttime in lighttimes)
                        {
                            int          lightstart = lightStartTime(p, lighttime, lighttime);
                            int          lightend   = lightstart + LIGHTFALLOFFTIME;
                            ColorCommand cc;
                            cc        = new ColorCommand(lightstart, lightend, v3(1f), color);
                            cc.easing = eq2num(eq_in_quad);
                            dots[idx].addCommandOverride(cc);
                        }
                    }
                }
                framedelta = 900;
            }
Ejemplo n.º 14
0
            private void mkpx(int idx, int x, int j, int z, int z0, int mod)
            {
                const int xoffset = 250;
                const int YDIFF   = 50;

                vec2 mid = v2(640 / 2, 480 / 2);

                vec2 p = v2(x, j);

                p.y += z * (font.charheight + LINESPACING) * mod;

                p *= SPACING;

                p.x -= xoffset * mod;
                p   += mid;

                vec2 fromp = v2(p);

                fromp.y += YDIFF * mod;

                int starttime = SHOW_START + show_delay * z0;
                int endtime   = starttime + SHOW_TIME;

                int pulsestart = PULSETIME;

                pulsestart += (int)((p - mid).length() * 1.1f);
                pulsestart -= (int)(v2(xoffset / 2f).length());

                var s = new Sprite(Sprite.SPRITE_SQUARE_2_2, Sprite.NO_ADJUST_LAST);
                var m = new MoveCommand(starttime, endtime, fromp, p);
                //var f = new FadeCommand(starttime, endtime, 0f, 1f);
                var f = new ColorCommand(starttime, endtime, v3(0f), v3(1f));

                if (mod == 0f)
                {
                    m.end   = m.start;
                    m.to    = m.from;
                    f.start = start;
                    f.end   = start + 300;
                }
                var c = new ColorCommand(pulsestart, pulsestart + 800, Zheart.basecolor, v3(1f));

                m.easing = eq2num(eq_out_cubic);
                //f.easing = Equation.fromEquation(eq_out_expo).number;
                f.easing = eq2num(eq_out_expo);
                c.easing = eq2num(eq_in_quad);
                s.addMove(m);
                //s.addFade(f);
                s.addColor(f);
                //s.addColor(new ColorCommand(starttime, starttime, v3(1f), v3(1f))); // because yeah
                s.addColor(c);
                s.starttime = starttime;
                s.endtime   = stop;
                int fadestart = rand.Next(sync(FADE_START), FADE_END - FADE_TIME);
                int fadetime  = FADE_TIME / FADE_TIMES / 2;

                s.addRaw(string.Format("_L,{0},{1}", fadestart, FADE_TIMES));
                //s.addRaw("_" + new FadeCommand(0, 0, 0f, 0f).ToString());
                //s.addRaw("_" + new FadeCommand(fadetime, fadetime * 2, 1f, 1f).ToString());
                s.addRaw("_" + new FadeCommand(0, fadetime, 1f, 1f).ToString());
                s.addRaw("_" + new FadeCommand(fadetime, fadetime * 2, 0f, 0f).ToString());
                sprites[idx] = s;
            }
Ejemplo n.º 15
0
 override public BaseCommand Make(GameObject target)
 {
     return(ColorCommand.Make(target, this));
 }
Ejemplo n.º 16
0
        protected override void _PreRender(CancellationTokenSource tokenSource = null)
        {
            _elementData = new EffectIntents();

            if (_data == null)
                return;

            ICommand command = null;

            switch (ValueType) {
                case CustomValueType._8Bit:
                    command = new _8BitCommand(Value8Bit);
                    break;
                case CustomValueType._16Bit:
                    command = new _16BitCommand(Value16Bit);
                    break;
                case CustomValueType._32Bit:
                    command = new _32BitCommand(Value32Bit);
                    break;
                case CustomValueType._64Bit:
                    command = new _64BitCommand(Value64Bit);
                    break;
                case CustomValueType.Color:
                    command = new ColorCommand(ColorValue);
                    break;
                case CustomValueType.String:
                    command = new StringCommand(StringValue);
                    break;
            }

            CommandValue value = new CommandValue(command);

            foreach (ElementNode node in TargetNodes)
            {
                foreach (var leafNode in node.GetLeafEnumerator())
                {
                    if (tokenSource != null && tokenSource.IsCancellationRequested)
                        return;

                    IIntent intent = new CommandIntent(value, TimeSpan);
                    _elementData.AddIntentForElement(leafNode.Element.Id, intent, TimeSpan.Zero);
                }

            }
        }
Ejemplo n.º 17
0
 public override void Handle(IIntentState <ColorValue> obj)
 {
     EvaluatorValue = new ColorCommand(obj.GetValue().Color);
 }
Ejemplo n.º 18
0
 public override void Handle(ColorCommand obj)
 {
     Command = new ColorCommand(_reducer.Reduce(obj.CommandValue, ReductionPercentage));
 }
Ejemplo n.º 19
0
 public override void Handle(ColorCommand obj)
 {
     ColorValue = obj.CommandValue;
 }
Ejemplo n.º 20
0
        public override void Handle(IIntentState <LightingValue> obj)
        {
            LightingValue lightingValue = obj.GetValue();

            EvaluatorValue = new ColorCommand(lightingValue.FullColor);
        }
Ejemplo n.º 21
0
 public override void Handle(ColorCommand obj)
 {
     Command = new ColorCommand(_reducer.Reduce(obj.CommandValue, ReductionPercentage));
 }
Ejemplo n.º 22
0
 public virtual void Handle(ColorCommand obj)
 {
 }
Ejemplo n.º 23
0
        public ICommand BuildCommand(string command, IUser author, IMessageChannel channel, IGuild guild, params string[] parameters)
        {
            ICommand _command = null;

            switch (command)
            {
            case CommandNames.exit:
                _command = new ExitCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.update:
                _command = new UpdateCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.restart:
                _command = new RestartCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.help:
                _command = new HelpCommand(author, _config, channel, _messageWriter, _commandsInfo, _validationHandler, parameters);
                break;

            case CommandNames.version:
                _command = new VersionCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.random:
                _command = new RandomCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.github:
                _command = new GithubCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.uptime:
                _command = new UptimeCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.color:
                _command = new ColorCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.flipcoin:
                _command = new FlipcoinCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.roll:
                _command = new RollCommand(author, _config, channel, _messageWriter, _validationHandler, parameters);
                break;

            case CommandNames.purge:
                _command = new PurgeCommand(author, _config, channel, _messageWriter, _connectionHandler, _validationHandler, parameters);
                break;

            case CommandNames.summon:
                _command = new SummonCommand(author, _config, channel, _messageWriter, _audioService, guild, _validationHandler, parameters);
                break;

            case CommandNames.dismiss:
                _command = new DismissCommand(author, _config, channel, _messageWriter, _audioService, guild, _validationHandler, parameters);
                break;

            case CommandNames.play:
                _command = new PlayCommand(author, _config, channel, _messageWriter, _audioService, guild, _validationHandler, parameters);
                break;

            default:
                break;
            }
            return(_command);
        }
Ejemplo n.º 24
0
            private void processOverrides()
            {
                // TODO complete this when actually needed
                int actualendtime = endtime;

                if ((settings & INTERPOLATE_MOVE) == 0 && (settings & NO_ADJUST_LAST) == 0)
                {
                    actualendtime += framedelta;
                }
                foreach (ICommand o in overrides)
                {
                    if (o is ColorCommand)
                    {
                        ColorCommand c = (ColorCommand)o;
                        if (c.end <= starttime || c.start >= actualendtime)
                        {
                            continue;
                        }
                        if (c.start < starttime)
                        {
                            Eq    e = num2eq(c.easing);
                            float x = e(progress(c.start, c.end, starttime));
                            c.start = starttime;
                            c.from  = lerp(c.from, c.to, x);
                        }
                        if (c.end > actualendtime)
                        {
                            Eq    e = num2eq(c.easing);
                            float x = e(progress(c.start, c.end, actualendtime));
                            c.end = actualendtime;
                            c.to  = lerp(c.from, c.to, x);
                        }
                        colorcmds.AddLast(c);
                        addOrdened(c);
                    }
                    if (o is FadeCommand)
                    {
                        FadeCommand f = (FadeCommand)o;
                        if (f.end <= starttime || f.start >= actualendtime)
                        {
                            continue;
                        }
                        if (f.start < starttime)
                        {
                            Eq    e = num2eq(f.easing);
                            float x = e(progress(f.start, f.end, starttime));
                            f.start = starttime;
                            f.from  = lerp(f.from, f.to, x);
                        }
                        if (f.end > actualendtime)
                        {
                            Eq    e = num2eq(f.easing);
                            float x = e(progress(f.start, f.end, actualendtime));
                            f.end = actualendtime;
                            f.to  = lerp(f.from, f.to, x);
                        }
                        fadecmds.AddLast(f);
                        addOrdened(f);
                    }
                }
            }
Ejemplo n.º 25
0
 public void Handle(ColorCommand obj)
 {
     EvaluatorValue = new _8BitCommand(ColorValue.GetGrayscaleLevel(obj.CommandValue));
 }
Ejemplo n.º 26
0
 public void addColor(ColorCommand cmd)
 {
     colorcmds.AddLast(cmd);
     allcmds.AddLast(cmd);
 }
Ejemplo n.º 27
0
 public override void Handle(ColorCommand obj)
 {
     ColorValue = obj.CommandValue;
 }
 public void Add(int index, ColorCommand command)
 {
     ColorCommands.Remove(index);
     ColorCommands.Add(index, command);
 }