예제 #1
0
        public void ClearList()
        {
            List <int> numbers = List354();

            DataUtil.Clear(numbers);
            Assert.AreEqual(0, DataUtil.Length(numbers));
        }
예제 #2
0
 private void SetMenuName(int menuIndex)
 {
     if (menuIndex < DataUtil.Length(menuNames))
     {
         menuName = menuNames[menuIndex];
     }
 }
예제 #3
0
        public void ClearListAtEnd()
        {
            List <int> numbers = List354();

            DataUtil.Clear(numbers, 2);
            Assert.AreEqual(2, DataUtil.Length(numbers));
            Assert.AreEqual("3, 5",
                            DataUtil.Join(numbers, ", "));
        }
예제 #4
0
        public void ClearListAtMiddle()
        {
            List <int> numbers = List354();

            DataUtil.Clear(numbers, 1);
            Assert.AreEqual(1, DataUtil.Length(numbers));
            Assert.AreEqual("3",
                            DataUtil.Join(numbers, ", "));
        }
예제 #5
0
파일: Journal.cs 프로젝트: W3SS/UnityToykit
        // Example: TestAnagramJournal.cs
        public string Write()
        {
            string historyTsv = "delay\taction";

            for (int index = 0; index < DataUtil.Length(playbackDelays); index++)
            {
                historyTsv += "\n" + playbackDelays[index].ToString();
                historyTsv += "\t" + playbackActions[index];
            }
            return(historyTsv);
        }
예제 #6
0
        private int Amount(int itemIndex)
        {
            int amount;

            if (menuIndex < DataUtil.Length(menus) - 1)
            {
                amount = itemIndex * levelsPerItem[menuIndex];
            }
            else
            {
                amount = itemIndex;
            }
            return(amount);
        }
예제 #7
0
        // Not a [Test], because it requires an instance.
        public static LevelSelectView Validate()
        {
            LevelSelectView view = LevelSelectView.GetInstance();

            Assert.AreEqual(false, view == null,
                            "Expected exactly one LevelSelectView.");
            Assert.AreEqual(true, 1 <= DataUtil.Length(view.menus),
                            "Expected at least one menu defined.");
            Assert.AreEqual(true, 1 <= DataUtil.Length(view.buttons),
                            "Expected at least one button defined.");
            Assert.AreEqual(true, 1 <= DataUtil.Length(view.buttons[0]),
                            "Expected at least one button defined.");
            return(view);
        }
예제 #8
0
        public static List <SceneNodeModel> ToSceneNodeList(List <GameObject> viewObjects)
        {
            List <SceneNodeModel> nodes = new List <SceneNodeModel>();

            for (int index = 0; index < DataUtil.Length(viewObjects); index++)
            {
                SceneNodeModel node       = new SceneNodeModel();
                GameObject     viewObject = viewObjects[index];
                node.name = GetName(viewObject);
                node.x    = GetLocalX(viewObject);
                node.y    = GetLocalY(viewObject);
                nodes.Add(node);
            }
            return(nodes);
        }
예제 #9
0
 public void Setup()
 {
     for (int index = 0; index < DataUtil.Length(menus); index++)
     {
         int menu = menus[index];
         levelsPerItem.Add(1);
         for (int previous = 0; previous < index; previous++)
         {
             levelsPerItem[previous] *= menu;
         }
         menuSelected.Add(-1);
     }
     SetMenuName(menuIndex);
     inMenu = Watcher <bool> .Create(IsInMenu());
 }
예제 #10
0
 public void Setup()
 {
     for (int index = 0; index < DataUtil.Length(menus); index++)
     {
         if (DataUtil.Length(buttons) <= index)
         {
             GameObject menu = menus[index];
             buttons.Add(SceneNodeView.GetChildren(menu, true));
         }
     }
     if (null == animatorOwner)
     {
         animatorOwner = gameObject;
     }
 }
예제 #11
0
파일: Journal.cs 프로젝트: W3SS/UnityToykit
        private string UpdatePlayback()
        {
            string command = null;

            if (playbackIndex < DataUtil.Length(playbackDelays))
            {
                int delay = playbackDelays[playbackIndex];
                if (delay <= milliseconds)
                {
                    command = playbackActions[playbackIndex];
                    playbackIndex++;
                    seconds -= delay / 1000.0f;
                }
            }
            return(command);
        }
예제 #12
0
        // Pop interpolated card from 0 to 1.
        // Example:  Editor/Tests/TestProgress.cs
        public int PopIndex()
        {
            if (DataUtil.Length(indexes) <= 0)
            {
                SetupIndexes(indexesLength, indexesStart);
            }
            int length       = DataUtil.Length(indexes);
            int interpolated = (int)Mathf.Floor(normal * length);

            interpolated = Mathf.Min(length - 1, interpolated);
            int index = indexes[interpolated];

            indexes.RemoveAt(interpolated);
            level = index;
            return(index);
        }
예제 #13
0
        public void GetChildren()
        {
            GameObject parent = new GameObject();

            SceneNodeView.SetName(parent, "parent");
            GameObject child = new GameObject();

            SceneNodeView.SetName(child, "child");
            SceneNodeView.AddChild(parent, child);
            List <GameObject> children = SceneNodeView.GetChildren(parent);

            Assert.AreEqual(1, DataUtil.Length(children));
            Assert.AreEqual("child", SceneNodeView.GetName(children[0]));
            Assert.AreEqual(child, children[0]);
            Object.DestroyImmediate(parent);
            Object.DestroyImmediate(child);
        }
예제 #14
0
파일: Journal.cs 프로젝트: W3SS/UnityToykit
 // Example: TestAnagramJournal.cs
 public void Read(string historyTsv)
 {
     string[][] table = StringUtil.ParseCsv(historyTsv, "\t");
     DataUtil.Clear(playbackDelays);
     DataUtil.Clear(playbackActions);
     if ("delay" != table[0][0] || "action" != table[0][1])
     {
         throw new System.InvalidOperationException("Expected delay and action as headers."
                                                    + " Got " + table[0][0] + ", " + table[0][1]);
     }
     for (int rowIndex = 1; rowIndex < DataUtil.Length(table); rowIndex++)
     {
         string[] row   = table[rowIndex];
         int      delay = StringUtil.ParseInt(row[0]);
         playbackDelays.Add(delay);
         string action = row[1];
         playbackActions.Add(action);
     }
 }
예제 #15
0
        public void ToSceneNodeList()
        {
            GameObject parent = new GameObject();

            SceneNodeView.SetName(parent, "parent");
            GameObject child = new GameObject();

            SceneNodeView.SetName(child, "child");
            SceneNodeView.SetLocalX(child, 2.0f);
            SceneNodeView.AddChild(parent, child);
            List <GameObject>     children = SceneNodeView.GetChildren(parent);
            List <SceneNodeModel> nodes    = SceneNodeView.ToSceneNodeList(children);

            Assert.AreEqual(1, DataUtil.Length(nodes));
            Assert.AreEqual("child", nodes[0].name);
            Assert.AreEqual(2.0f, nodes[0].x);
            Assert.AreEqual(0.0f, nodes[0].y);
            Object.DestroyImmediate(parent);
            Object.DestroyImmediate(child);
        }
예제 #16
0
파일: KeyView.cs 프로젝트: W3SS/UnityToykit
        // Represents enter key by "\n", even on Windows.
        // Represents delete key or backspace key by "\b".
        // Unity 5.6 inserts backspace character already but not delete key, except on WebGL.
        public static string InputString()
        {
            string input = Input.inputString;

            if (Input.GetKeyDown("delete"))
            {
                if (input.IndexOf(backspaceCharacter) < 0)
                {
                    input += backspaceCharacter;
                }
            }
            input = input.Replace(windowsNewlineCharacter + newlineCharacter, newlineCharacter)
                    .Replace(windowsNewlineCharacter, newlineCharacter);
            input = input.Replace(backspaceCharacter + backspaceCharacter, backspaceCharacter);
            if (isVerbose && input != null && input != "")
            {
                DebugUtil.Log("KeyView.InputString: <" + input + ">"
                              + " length " + DataUtil.Length(input));
            }
            return(input);
        }
예제 #17
0
        public void PopIndex()
        {
            List <int> cards = new List <int> {
                10, 11, 12, 13
            };
            Progress progress = new Progress();

            for (int round = 0; round < 4; round++)
            {
                progress.normal = 0.5f;
                progress.SetupIndexes(DataUtil.Length(cards), 1);
                Assert.AreEqual(2, progress.PopIndex());
                Assert.AreEqual(2, progress.level);
                Assert.AreEqual(4, progress.levelMax);
                Assert.AreEqual(3, progress.PopIndex());
                Assert.AreEqual(3, progress.level);
                Assert.AreEqual(4, progress.levelMax);
                progress.normal = 1.0f;
                Assert.AreEqual(1, progress.PopIndex());
                Assert.AreEqual(1, progress.level);
                Assert.AreEqual(4, progress.levelMax);
            }
        }
예제 #18
0
파일: Journal.cs 프로젝트: W3SS/UnityToykit
 public bool IsPlaying()
 {
     return(isPlayback && playbackIndex < DataUtil.Length(playbackDelays));
 }
예제 #19
0
 public bool IsInMenu()
 {
     return(0 <= menuIndex && menuIndex < DataUtil.Length(menus));
 }