Ejemplo n.º 1
0
        /// <summary>
        /// Configures the Transition modifier for this item.
        /// </summary>
        /// <param name="next">The next position; required to have an end point for the transition.</param>
        public void InitTransition(HandData next)
        {
            if (!HasTransitionModifier)
            {
                throw new Exception("Trying to init transition, but the SequenceItem is not specified to allow a transition.");
            }
            if (transition == null)
            {
                transition = new HashSet <PositionRecord>();
            }
            else
            {
                transition.Clear();
            }

            double[] diffs      = new double[22];
            double   iterations = 10.0;
            HandData needle     = new HandData();

            for (int i = 0; i < diffs.Length; i++)
            {
                diffs[i]        = (next[i].Radians - Position[i].Radians) / iterations;
                needle[i].Value = Position[i].Radians;
            }

            for (int i = 0; i < iterations; i++)
            {
                // Prepare the needle by making its values approach two's some more.
                needle.Add(diffs);
                // Check if this matches a position.
                List <PositionRecord> list = PositionParser.GetAllMatches(needle, 1.5);
                foreach (PositionRecord pr in list)
                {
                    if (transition.Add(pr))
                    {
                        Console.WriteLine("Found a transitional item: {0}", pr.Name);
                    }
                }
            }
        }