コード例 #1
0
 virtual protected void SendInputDown(Vector2 velocity, CommandRegion region)
 {
     primaryClient.SendMessage("OnInputDown", new DirectionalAnalogEvent()
     {
         Velocity = velocity,
         Region   = region
     }, SendMessageOptions.DontRequireReceiver);
 }
コード例 #2
0
 public void Flush()
 {
     commandString         = new char[] { 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n' };
     commandSize           = 0;
     commandDirection      = 0;
     lastDirectionalRegion = CommandRegion.None;
     LastInput             = DirectionalAnalogEvent.Empty();
 }
コード例 #3
0
 public static bool LineCast(CommandRegion start, CommandRegion middle, CommandRegion end)
 {
     if (middle != CommandRegion.Center)
     {
         return(false);
     }
     else
     {
         return(ClockwiseCast(start, end, 4));
     }
 }
コード例 #4
0
        virtual protected bool GetInput(out Vector2 vel, out CommandRegion reg)
        {
            bool state = GetInput(out vel);

            if (state)
            {
                reg = GetRegion(vel);
            }
            else
            {
                reg = CommandRegion.None;
            }
            return(state);
        }
コード例 #5
0
            private void InterpretStep(CommandRegion reg)
            {
                if (commandSize > 9)
                {
                    Flush();
                }

                if (reg == CommandRegion.Center)
                {
                    commandString [commandSize] = 'c';
                }
                else if (reg == CommandRegion.None)
                {
                    commandString [commandSize] = 'n';
                }
                else if (lastDirectionalRegion == CommandRegion.None)
                {
                    commandString [commandSize] = 'd';
                    lastDirectionalRegion       = reg;
                }
                else if (commandDirection == 0)
                {
                    int delta = (int)reg - (int)lastDirectionalRegion;
                    //commandDirection = delta > 0 || delta == -7 ? 1 : -1;
                    //delta = delta == commandDirection * -7 ? 1 : delta;
                    //commandString [commandSize] = Math.Abs (delta).ToString () [0];
                    //lastDirectionalRegion = reg;


                    lastDirectionalRegion = reg;
                }
                else
                {
                    int delta = commandDirection * ((int)reg - (int)lastDirectionalRegion);
                    //delta = delta < 0 ? delta + 8 : delta;
                    if (delta == commandDirection * -7)
                    {
                        delta = 1;
                    }
                    else if (delta < 0)
                    {
                        delta += 8;
                    }
                    commandString [commandSize] = Math.Abs(delta).ToString() [0];
                    lastDirectionalRegion       = reg;
                }
                commandSize++;
            }
コード例 #6
0
            public static bool ClockwiseCast(CommandRegion start, CommandRegion end, int count)
            {
                int dif = (int)end - (int)start;

                return(IsDirectionCommand(start) && IsDirectionCommand(end) && (Math.Abs(dif) == count || Math.Abs(dif) == 8 - count));
            }
コード例 #7
0
            //Chek if the regions are a counter-clockwise sequence
            public static bool CounterClockwiseSequence(CommandRegion start, CommandRegion end)
            {
                int dif = (int)end - (int)start;

                return(IsDirectionCommand(start) && IsDirectionCommand(end) && (dif == -1 || dif == 7));
            }
コード例 #8
0
 public static bool IsDirectionCommand(CommandRegion reg)
 {
     return(reg != CommandRegion.Center && reg != CommandRegion.None);
 }
コード例 #9
0
 public static bool IsCenterCommand(CommandRegion reg)
 {
     return(reg == CommandRegion.Center);
 }