public void ClearList() { List <int> numbers = List354(); DataUtil.Clear(numbers); Assert.AreEqual(0, DataUtil.Length(numbers)); }
private void SetMenuName(int menuIndex) { if (menuIndex < DataUtil.Length(menuNames)) { menuName = menuNames[menuIndex]; } }
public void ClearListAtEnd() { List <int> numbers = List354(); DataUtil.Clear(numbers, 2); Assert.AreEqual(2, DataUtil.Length(numbers)); Assert.AreEqual("3, 5", DataUtil.Join(numbers, ", ")); }
public void ClearListAtMiddle() { List <int> numbers = List354(); DataUtil.Clear(numbers, 1); Assert.AreEqual(1, DataUtil.Length(numbers)); Assert.AreEqual("3", DataUtil.Join(numbers, ", ")); }
// 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); }
private int Amount(int itemIndex) { int amount; if (menuIndex < DataUtil.Length(menus) - 1) { amount = itemIndex * levelsPerItem[menuIndex]; } else { amount = itemIndex; } return(amount); }
// 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); }
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); }
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()); }
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; } }
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); }
// 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); }
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); }
// 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); } }
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); }
// 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); }
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); } }
public bool IsPlaying() { return(isPlayback && playbackIndex < DataUtil.Length(playbackDelays)); }
public bool IsInMenu() { return(0 <= menuIndex && menuIndex < DataUtil.Length(menus)); }