示例#1
0
 public InputSequenceMatcher(InputSequence sequence)
 {
     this.sequence = sequence.Inputs.GetEnumerator();
     // Start by advancing the enumerator, makes match() logic simpler
     if (this.sequence.MoveNext() == false)
     {
         // Indicates empty InputSequence
         complete = true;
     }
 }
        public bool Match(InputSequence sequence)
        {
            var now = DateTime.Now;

            if (now > lastAttackTime.AddSeconds(secondsBetweenAttacks))
            {
                lastAttackTime = now;
                return(true);
            }
            return(false);
        }
示例#3
0
        public bool Match(InputSequence sequence)
        {
            // TODO: Thread safety concerns?
            int index = find(sequence);

            if (index != -1)
            {
                var newLen = buffer.Count - (index + 1);
                trimBuffer(newLen);
            }
            return(index != -1);
        }
示例#4
0
        /// <summary>
        /// Finds the index of the first (i.e oldest) InputState matching
        /// the provided sequence, or -1 if not found.
        /// </summary>
        private int find(InputSequence sequence)
        {
            var matcher = new InputSequenceMatcher(sequence);

            foreach ((InputState state, int index) in buffer.Select((x, i) => (x, i)))
            {
                if (matcher.isMatch(state))
                {
                    if (matcher.isComplete())
                    {
                        return(index);
                    }
                }
                else
                {
                    matcher = new InputSequenceMatcher(sequence);
                }
            }
            return(-1);
        }
 public bool Peek(InputSequence sequence)
 {
     return(false);
 }
示例#6
0
 public bool Peek(InputSequence sequence)
 {
     return(find(sequence) != -1);
 }
示例#7
0
 public bool Peek(InputSequence sequence)
 {
     return(buffer.Peek(sequence));
 }
示例#8
0
 public bool Match(InputSequence sequence)
 {
     return(buffer.Match(sequence));
 }