コード例 #1
0
        private bool allBoxesFacingSameDirection(SyllableBoxSet set, out Vector3 avgDirection)
        {
            if (set != null &&
                set.Count > 0)
            {
                Vector3 avgVector = set[0].gameObject.transform.forward;
                for (int i = 1; i < set.Count; i++)
                {
                    Vector3 x = set[i].gameObject.transform.forward;
                    avgVector = (x + avgVector) / (i + 1);

                    float dot = Vector3.Dot(avgVector, x);
                    if (dot <= 0)
                    {
                        avgDirection = avgVector;
                        return(false);
                    }
                }

                avgDirection = avgVector;
                return(true);
            }

            avgDirection = Vector3.zero;
            return(false);
        }
コード例 #2
0
        public bool IsCorrect(SyllableBoxSet set)
        {
            if (set != null)
            {
                Syllable[] syllablesInVisualOrder = GetSyllableOrder(set);
                if (syllablesInVisualOrder != null)
                {
                    return(set.IsCorrectOrder(syllablesInVisualOrder));
                }
            }

            return(false);
        }
コード例 #3
0
        public Syllable[] GetSyllableOrder(SyllableBoxSet set)
        {
            Vector3 avgForward;

            if (allBoxesFacingSameDirection(set, out avgForward))
            {
                return(getSyllablesInVisualOrder(set));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
        private Syllable[] getSyllablesInVisualOrder(SyllableBoxSet set)
        {
            List <SyllableBox> boxList = new List <SyllableBox>(set.Boxes);

            if (boxList.Count > 1)
            {
                VisualBoxComparator vbc = new VisualBoxComparator();
                boxList.Sort(vbc);
            }

            List <Syllable> syllablesInVisualOrderList = new List <Syllable>();

            for (int i = 0; i < boxList.Count; i++)
            {
                syllablesInVisualOrderList.Add(boxList[i].Syllable);
            }

            return(syllablesInVisualOrderList.ToArray());
        }