public void Fold() { Debug.Assert(Folds.Count > 0); Fold f = Folds.Dequeue(); if (f is XFold) { int index = f.Index; int[,] newGrid = new int[Grid.GetLength(0), index]; for (int y = 0; y < Grid.GetLength(0); y++) { for (int x = 0; x < index; x++) { newGrid[y, x] = Grid[y, x] | Grid[y, Grid.GetLength(1) - x - 1]; } } Grid = newGrid; } else if (f is YFold) { int index = f.Index; int[,] newGrid = new int[index, Grid.GetLength(1)]; for (int y = 0; y < index; y++) { for (int x = 0; x < Grid.GetLength(1); x++) { newGrid[y, x] = Grid[y, x] | Grid[Grid.GetLength(0) - y - 1, x]; } } Grid = newGrid; } }
//---------------------------------------------- protected void Play(BeloteCard card, Fold fold) { if (CanPlay(card)) { DoPlay(card, fold); } }
/// <summary> /// Executes the action on a certain <see cref="TextArea"/>. /// </summary> /// <param name="textArea">The text area on which to execute the action.</param> public override void Execute(TextArea textArea) { List <Fold> folds = textArea.Document.FoldingManager.GetFoldsWithStartAt(textArea.Caret.Line); if (folds.Count != 0) { foreach (Fold fm in folds) { fm.IsFolded = !fm.IsFolded; } } else { folds = textArea.Document.FoldingManager.GetFoldsContainingLine(textArea.Caret.Line); if (folds.Count != 0) { Fold innerMost = folds[0]; for (int i = 1; i < folds.Count; i++) { if (new TextLocation(folds[i].StartColumn, folds[i].StartLine) > new TextLocation(innerMost.StartColumn, innerMost.StartLine)) { innerMost = folds[i]; } } innerMost.IsFolded = !innerMost.IsFolded; } } textArea.Document.FoldingManager.NotifyFoldingChanged(EventArgs.Empty); }
public void Test_1() { Assert.AreEqual(6, (Fold.FoldFunc(new List <int>() { 1, 2, 3 }, 1, (acc, elem) => acc * elem))); }
public void Test_2() { Assert.AreEqual(10, (Fold.FoldFunc(new List <int>() { 1, 2, 3, 4 }, 0, (acc, elem) => acc + elem))); }
private HashSet <Point> FoldPaper(HashSet <Point> dots, Fold fold) { return((fold.axis switch { 'x' => dots.Select(dot => dot.x < fold.index ? dot : dot with { x = fold.index - (dot.x - fold.index) }),
protected void OnAfterPlayTimerDone() { // One Fold is done, select new player. if (CurrentFold.Deck.Size == Players.Count) { CurrentFold.Finalize(Trump); Player winner = CurrentFold.Winner; LastFoldingTeam = winner.Team; Fold newFold = new Fold(); CurrentFold.MoveTo(newFold); PastFolds[(int)winner.Team].Add(newFold); // New player has no cards in hand, we end the round if (winner.Hand.Empty) { // Next Round; EndRound(); // TODO : Win condition StartRound(); } else { StartTurn(winner); } } else { StartTurn(GetLeftPlayer(CurrentPlayer)); } }
public void Random_Test() { Stopwatch sw = new Stopwatch(); const int tests = 1000; for (int i = 0; i < tests; ++i) { double distance, random = rnd.NextDouble(); if (random < 0.1) { distance = 0; } else { distance = 0.0001 * Math.Pow(2, rnd.NextDouble() * (128 + 22) - 22); } if (random > 0.9) { distance *= -1; } Console.WriteLine("Distance: {0}m", distance); int?expected = solution(distance); sw.Start(); int?actual = Fold.FoldTo(distance); sw.Stop(); Assert.AreEqual(expected, actual); } Console.WriteLine("\nRandom tests passed!\nUser code execution time was {0} milliseconds over {1} assertions.", sw.Elapsed.TotalMilliseconds, tests); }
public Fold Add(int order, string name, Func <bool> checkEnableFunc, Action drawFunc, bool enableFirst = false) { Fold ret; FoldData foldData; if (_dic.TryGetValue(name, out foldData)) { foldData._order = order; foldData._fold.Add(checkEnableFunc, drawFunc); ret = foldData._fold; } else { ret = new Fold(name, checkEnableFunc, drawFunc, enableFirst); _dic.Add(name, new FoldData { _order = order, _fold = ret, }); } _needUpdate = true; return(ret); }
private void ShowButtons() { RaiseBar.Show(); Call.Show(); Raise.Show(); Fold.Show(); RaiseAmount.Show(); }
public void MoveTo(Fold fold) { Deck.MoveAllCardsTo(fold.Deck); fold.Winner = Winner; fold.Points = Points; Winner = null; Points = 0; }
private void HideButtons() { RaiseBar.Hide(); Call.Hide(); Raise.Hide(); Fold.Hide(); RaiseAmount.Hide(); }
void OnToolTipRequest(object sender, ToolTipRequestEventArgs e) { if (e.ToolTipShown) { return; } Point mousepos = e.MousePosition; Fold fold = _textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - _textArea.TextView.DrawingPosition.X, mousepos.Y - _textArea.TextView.DrawingPosition.Y); if (fold != null && fold.IsFolded) { StringBuilder sb = new StringBuilder(fold.InnerText); // Skip leading newlines int i = 0; while (sb[i] == '\r' || sb[i] == '\n') { i++; } if (i > 0) { sb.Remove(0, i); } // max 10 lines int endLines = 0; for (i = 0; i < sb.Length; ++i) { if (sb[i] == '\n') { ++endLines; if (endLines >= 10) { sb.Remove(i + 1, sb.Length - i - 1); sb.Append(Environment.NewLine); sb.Append("..."); break; } } } sb.Replace("\t", " "); e.ShowToolTip(sb.ToString()); return; } List <Marker> markers = _textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition); foreach (Marker marker in markers) { if (marker.ToolTip != null) { e.ShowToolTip(marker.ToolTip.Replace("\t", " ")); return; } } }
public void FoldTest() { List <int> list = new List <int> { 1, 2, 3 }; int newValue = Fold.FoldFunction(list, 1, (acc, elem) => acc * elem); int expectedValue = 6; Assert.AreEqual(newValue, expectedValue); }
void DoFold(Fold f) { if (f.Dir == 'y') { DoFoldY(f.Line); } else if (f.Dir == 'x') { DoFoldX(f.Line); } }
//---------------------------------------------- public GameScreen() { m_players = new List <Player>(); m_actionQueue = new ActionQueue(); m_endState = EndState.None; m_deck = new BeloteDeck(this); m_currentFold = new Fold(); m_pastFolds = new List <Fold> [Enum.GetValues(typeof(PlayerTeam)).Length]; for (int i = 0; i < m_pastFolds.Length; ++i) { m_pastFolds[i] = new List <Fold>(); } Score = new Score(); }
void RemovePastFolds() { Fold lastFold = Screen.LastFold; if (lastFold != null) { foreach (Card card in lastFold.Deck) { CardComponent cardComp = GetCardComponent(card); if (cardComp != null) { UnSpawnCard(cardComp); } } } }
public void Init() { Utils.Load($"{TestName}.input", (string l, int n) => { var coords = l.Split(','); Page.Add(new Point(Int32.Parse(coords[0]), Int32.Parse(coords[1]))); }); Utils.Load($"{TestName}.folds", (string l, int n) => { Fold f = new Fold(); f.Dir = l[11]; f.Line = Int32.Parse(l.Split('=')[1]); Folds.Add(f); }); }
// Use this for initialization void Start() { Debug.Log("starting model creation"); // DirectoryInfo levelDirectoryPath = new DirectoryInfo(Application.dataPath); // FileInfo[] fileInfo = levelDirectoryPath.GetFiles("*.*", SearchOption.AllDirectories); // foreach (FileInfo file in fileInfo) { // // file extension check // if (file.Extension == ".fold") { // foldFiles.Add(file.Name); // } // // etc. // } // file_name = //currently selected option from foldFiles // string path = Application.dataPath + "/Resources/"+foldFilePath; // string[] filePaths = Directory.GetFiles(@path, "*.fold"); // List<string> dropOptions = new List<string>(); // foreach(string fileName in filePaths){ // dropOptions.Add(fileName); // } // dropdown.ClearOptions(); // dropdown.AddOptions(dropOptions); fold = new Fold(file_name); pointQueue = new Queue <Point>(); lineQueue = new Queue <Line>(); createMesh(); vectorPoints = new List <Vector3>(); points = new List <Point>(); highlightAllPoints(); positionChange = new Stack <List <Vector3> >(); positionChange.Push(vectorPoints); edgeLines = new List <GameObject>(); highlightAllEdges(); gameObject.tag = "fold"; Debug.Log("finished model creation"); }
private SparseGrid <bool> DoFold(SparseGrid <bool> grid, Fold fold) { var nextGrid = new SparseGrid <bool>(); foreach (var(point, _) in grid.AllDefinedCells) { if (fold.Axis == Axis.X) { if (point.X < fold.Coordinate) { nextGrid.Set(point, true); } else if (point.X == fold.Coordinate) { // Do nothing } else { var gridPoint = new GridPoint(fold.Coordinate - Math.Abs(fold.Coordinate - point.X), point.Y); nextGrid.Set(gridPoint, true); } } else { if (point.Y < fold.Coordinate) { nextGrid.Set(point, true); } else if (point.Y == fold.Coordinate) { // Do nothing } else { var gridPoint = new GridPoint(point.X, fold.Coordinate - Math.Abs(fold.Coordinate - point.Y)); nextGrid.Set(gridPoint, true); } } } return(nextGrid); }
void InitFold() { fold = new Fold("Fold"); // add funcion fold.Add(() => GUILayout.Label("Added function")); // add function with checkEnableFunc // Called only when checkEnableFunc returns true. fold.Add( () => isEnable, () => GUILayout.Label("With checkEnableFunc.") ); // add title label action fold.SetTitleAction(() => GUILayout.Label("Title Action")); // set open first fold.Open(); }
static HashSet <Point> ExecuteFold(ICollection <Point> image, Fold fold) { var result = new List <Point>(); var isX = fold.Coordinate == Coordinate.X; result.AddRange(image.Where(p => (isX ? p.X : p.Y) <= fold.At)); var max = 2 * fold.At; if (isX) { // from right to left (last row -> to first row) result.AddRange(image.Where(p => p.X > fold.At).Select(_ => new Point(max - _.X, _.Y))); } else { // from down to up (last line -> to first line) result.AddRange(image.Where(p => p.Y > fold.At).Select(_ => new Point(_.X, max - _.Y))); } return(result.ToHashSet()); }
// Use this for initialization void Start() { collisionReference = GameObject.Find ("Collision").GetComponent<BoxCollider>(); originalRotation = this.transform.rotation; //originalPosition = new Vector3(0,0,-1); originalPosition = this.transform.position; touchController = GameObject.FindGameObjectWithTag("MainObject").GetComponent<TouchController>(); foldReference = GameObject.Find("backsidepivot").GetComponent<Fold>(); fingerList = new List<Vector2>(); tearPoints = new List<Vector3>(); prefab = this.transform; zLayerTmp = GVariables.zFoldLayer; prevMousestate = false; currMouseState = false; firstTouch = false; isFolded = false; }
// Use this for initialization void Start() { // the following is now needed // due to the prefab of 'MainObject' GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject GameStateManager gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); gameStateManagerRef.EnsureScriptAdded("TouchController"); collisionReference = GameObject.Find ("Collision").GetComponent<BoxCollider>(); originalRotation = this.transform.rotation; //originalPosition = new Vector3(0,0,-1); originalPosition = this.transform.position; touchController = mainObject.GetComponent<TouchController>(); foldReference = GameObject.Find("backsidepivot").GetComponent<Fold>(); fingerList = new List<Vector2>(); tearPoints = new List<Vector3>(); prefab = this.transform; zLayerTmp = GVariables.zFoldLayer; prevMousestate = false; currMouseState = false; firstTouch = false; isFolded = false; }
static OrigamiGrid ParseInput(List <string> data) { var maxX = -1; var maxY = -1; var coords = new List <(int x, int y)>(); var folds = new List <Fold>(); var isData = true; foreach (var line in data) { if (line.Length == 0) { isData = false; continue; } if (isData) { var p = line.Split(",").Select(int.Parse).ToList(); maxX = (p[0] > maxX) ? p[0] : maxX; maxY = (p[1] > maxY) ? p[1] : maxY; coords.Add((p[0], p[1])); continue; } // Read fold instructions var detail = line.Split(INSTURCTION_SPLIT, StringSplitOptions.RemoveEmptyEntries).ToList(); var fold = new Fold(); fold.Direction = (detail[0] == "x" || detail[0] == "X") ? FoldDirection.X : FoldDirection.Y; fold.Target = int.Parse(detail[1]); folds.Add(fold); } var result = new OrigamiGrid(maxX + 1, maxY + 1); result.Plot(coords); result.Instuctions = folds; return(result); }
// Use this for initialization void Start() { // NOTICE : DOM originalPosition = new Vector3(0,0,-3); originalRotation = this.transform.rotation; touchController = GameObject.FindGameObjectWithTag("MainObject").GetComponent<TouchController>(); foldCollide = GameObject.Find("Collision").GetComponent<FoldCollision>(); foldReference = GameObject.Find("backsidepivot").GetComponent<Fold>(); fingerList = new List<Vector2>(); prefab = this.transform; zLayerTmp = GVariables.zCoverLayer; reference3 = this.transform.FindChild("coverup").gameObject; script = gameObject.GetComponent<ChangeMeshScript>(); prevMouseState = false; currMouseState = false; firstTouch = false; isFolded = false; }
/// <summary> /// Executes the action on a certain <see cref="TextArea"/>. /// </summary> /// <param name="textArea">The text area on which to execute the action.</param> public override void Execute(TextArea textArea) { TextLocation position = textArea.Caret.Position; List <Fold> foldings = textArea.Document.FoldingManager.GetFoldedFoldsWithEndAt(position.Y); Fold justBeforeCaret = null; foreach (Fold fold in foldings) { if (fold.EndColumn == position.X) { justBeforeCaret = fold; break; // the first folding found is the folding with the smallest start position } } if (justBeforeCaret != null) { position.Y = justBeforeCaret.StartLine; position.X = justBeforeCaret.StartColumn; } else { if (position.X > 0) { --position.X; } else if (position.Y > 0) { LineSegment lineAbove = textArea.Document.GetLineSegment(position.Y - 1); position = new TextLocation(lineAbove.Length, position.Y - 1); } } textArea.Caret.Position = position; textArea.SetDesiredColumn(); }
/// <summary> /// Executes the action on a certain <see cref="TextArea"/>. /// </summary> /// <param name="textArea">The text area on which to execute the action.</param> public override void Execute(TextArea textArea) { LineSegment curLine = textArea.Document.GetLineSegment(textArea.Caret.Line); TextLocation position = textArea.Caret.Position; List <Fold> foldings = textArea.Document.FoldingManager.GetFoldedFoldsWithStartAt(position.Y); Fold justBehindCaret = null; foreach (Fold fold in foldings) { if (fold.StartColumn == position.X) { justBehindCaret = fold; break; } } if (justBehindCaret != null) { position.Y = justBehindCaret.EndLine; position.X = justBehindCaret.EndColumn; } else { // no folding is interesting if (position.X < curLine.Length || textArea.TextEditorProperties.AllowCaretBeyondEOL) { ++position.X; } else if (position.Y + 1 < textArea.Document.TotalNumberOfLines) { ++position.Y; position.X = 0; } } textArea.Caret.Position = position; textArea.SetDesiredColumn(); }
// Initializes any references that were not set in Start(). private void InitRemainingRefs() { //if(!allLoaded){ if(!paperObject){ paperObject = GameObject.FindGameObjectWithTag("background"); } if(!tearBorder){ tearBorder = GameObject.FindGameObjectWithTag("DeadSpace"); foldBorder = GameObject.FindGameObjectWithTag("foldborder"); unfoldBorder = GameObject.FindGameObjectWithTag("unfoldborder"); unfoldBlocker = GameObject.FindGameObjectWithTag("RayTraceBlocker"); moveBorder = GameObject.FindGameObjectWithTag("insideBorder"); menuButton = GameObject.Find("MenuButton_Prefab"); restartButton = GameObject.Find("RestartButton_Prefab"); } if(GameObject.FindGameObjectWithTag("TearManager")){ tearManagerRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); } if(GameObject.FindGameObjectWithTag("Player")){ playerObject = GameObject.FindGameObjectWithTag("Player"); unfoldCollisionRef = playerObject.GetComponent<UnfoldCollision>(); // JUSTIN, CHAR CONTR IS ATTACHED TO THE PLAYER, NOT MAIN OBJECT - D.A. controllerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>(); } if(GameObject.FindGameObjectWithTag("FoldObject")){ foldRef = GameObject.FindGameObjectWithTag("FoldObject").GetComponent<Fold>(); } if(paperObject && tearManagerRef && playerObject && foldRef){ allLoaded = true; } //} }
private bool TryGetFold(string name, out Fold fold) { fold = null; if (m_AssetBundleItems == null) { return false; } for (int i=0; i<m_AssetBundleItems.Count; i++) { if (!(m_AssetBundleItems[i] is Fold)) { continue; } if (m_AssetBundleItems[i].name == name) { fold = (Fold)m_AssetBundleItems[i]; return true; } } return false; }
public override RemoteFork.Plugins.BaseItem[] GetList(string path) { switch (path) { case "acetorrentplay": return(GetTopList()); case "acetorrentplay;torrenttv": return(GetTorrentTV()); } var items = new System.Collections.Generic.List <RemoteFork.Plugins.BaseItem>(); string[] PathSpliter = path.Split(';'); switch (PathSpliter[PathSpliter.Length - 1]) { case "ent": return(LastModifiedPlayList("ent")); case "child": return(LastModifiedPlayList("child")); case "common": return(LastModifiedPlayList("common")); case "discover": return(LastModifiedPlayList("discover")); case "HD": return(LastModifiedPlayList("HD")); case "film": return(LastModifiedPlayList("film")); case "man": return(LastModifiedPlayList("man")); case "music": return(LastModifiedPlayList("music")); case "news": return(LastModifiedPlayList("news")); case "region": return(LastModifiedPlayList("region")); case "relig": return(LastModifiedPlayList("relig")); case "sport": return(LastModifiedPlayList("sport")); } string PathFiles = ((string)(PathSpliter[PathSpliter.Length - 1])).Replace("|", "\\"); switch (System.IO.Path.GetExtension(PathFiles)) { case ".torrent": PlayList[] PlayListtoTorrent = GetFileListJSON(PathFiles, IPAdress); string Description = SearchDescriptions(System.IO.Path.GetFileNameWithoutExtension(PathFiles.Split('(', '.', '[', '|')[0])); foreach (PlayList PlayList in PlayListtoTorrent) { RemoteFork.Plugins.BaseItem Item = new RemoteFork.Plugins.BaseItem(); Item.Name = PlayList.Name; Item.ImageLink = "http://s1.iconbird.com/ico/1012/AmpolaIcons/w256h2561350597291videofile.png"; Item.Link = PlayList.Link; Item.Type = ItemType.FILE; Item.Description = Description; items.Add(Item); } //Информация о запущенном файле //Dim WC As New System.Net.WebClient //WC.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0") //WC.Encoding = System.Text.Encoding.UTF8 //Dim AceMadiaInfo As String //AceMadiaInfo = WC.DownloadString("http://127.0.0.1:6878/ace/manifest.m3u8?id=" & GetID(PathFiles, IPAdress) & "&format=json&use_api_events=1&use_stop_notifications=1") //System.IO.File.WriteAllText("d:\My Desktop\инфо.txt", AceMadiaInfo) return(items.ToArray()); case ".m3u": return(GetM3uList(PathFiles)); } string[] ListFolders = System.IO.Directory.GetDirectories(PathFiles); foreach (string Fold in ListFolders) { RemoteFork.Plugins.BaseItem Item = new RemoteFork.Plugins.BaseItem(); Item.Name = System.IO.Path.GetFileName(Fold); Item.Link = Fold.Replace("\\", "|"); Item.ImageLink = "http://s1.iconbird.com/ico/1012/AmpolaIcons/w256h2561350597246folder.png"; Item.Type = ItemType.DIRECTORY; items.Add(Item); } if (AceProxEnabl == true) { foreach (string File in System.IO.Directory.EnumerateFiles(PathFiles, "*.*", System.IO.SearchOption.TopDirectoryOnly).Where((s) => s.EndsWith(".torrent"))) { RemoteFork.Plugins.BaseItem Item = new RemoteFork.Plugins.BaseItem(); Item.ImageLink = "http://s1.iconbird.com/ico/1012/AmpolaIcons/w256h2561350597291utorrent2.png"; Item.Name = System.IO.Path.GetFileNameWithoutExtension(File); Item.Link = File.Replace("\\", "|"); Item.Description = Item.Name; Item.Type = ItemType.DIRECTORY; items.Add(Item); } } foreach (string File in System.IO.Directory.EnumerateFiles(PathFiles, "*.*", System.IO.SearchOption.TopDirectoryOnly).Where((s) => s.EndsWith(".mkv") || s.EndsWith(".avi") || s.EndsWith(".mp4"))) { RemoteFork.Plugins.BaseItem Item = new RemoteFork.Plugins.BaseItem(); Item.ImageLink = "http://s1.iconbird.com/ico/1012/AmpolaIcons/w256h2561350597291videofile.png"; Item.Name = System.IO.Path.GetFileNameWithoutExtension(File); Item.Link = ((string)("http://" + IPAdress + ":" + PortRemoteFork + "/" + File)).Replace("\\", "/"); Item.Description = Item.Link; Item.Type = ItemType.FILE; items.Add(Item); } foreach (string File in System.IO.Directory.EnumerateFiles(PathFiles, "*.*", System.IO.SearchOption.TopDirectoryOnly).Where((s) => s.EndsWith(".mp3"))) { RemoteFork.Plugins.BaseItem Item = new RemoteFork.Plugins.BaseItem(); Item.ImageLink = "http://s1.iconbird.com/ico/1012/AmpolaIcons/w256h2561350597240aimp.png"; Item.Name = System.IO.Path.GetFileNameWithoutExtension(File); Item.Link = ((string)("http://" + IPAdress + ":" + PortRemoteFork + "/" + File)).Replace("\\", "/"); Item.Description = Item.Link; Item.Type = ItemType.FILE; items.Add(Item); } foreach (string File in System.IO.Directory.EnumerateFiles(PathFiles, "*.*", System.IO.SearchOption.TopDirectoryOnly).Where((s) => s.EndsWith(".jpg") || s.EndsWith(".png") || s.EndsWith(".gif") || s.EndsWith(".bmp"))) { RemoteFork.Plugins.BaseItem Item = new RemoteFork.Plugins.BaseItem(); Item.ImageLink = "http://s1.iconbird.com/ico/1012/AmpolaIcons/w256h2561350597278imagefile.png"; Item.Name = System.IO.Path.GetFileNameWithoutExtension(File); Item.Link = ((string)("http://" + IPAdress + ":" + PortRemoteFork + "/" + File)).Replace("\\", "/"); Item.Description = Item.Link; Item.Type = ItemType.FILE; items.Add(Item); } foreach (string File in System.IO.Directory.EnumerateFiles(PathFiles, "*.*", System.IO.SearchOption.TopDirectoryOnly).Where((s) => s.EndsWith(".m3u"))) { RemoteFork.Plugins.BaseItem Item = new RemoteFork.Plugins.BaseItem(); Item.ImageLink = "http://s1.iconbird.com/ico/0912/VannillACreamIconSet/w128h1281348320736M3U.png"; Item.Name = System.IO.Path.GetFileNameWithoutExtension(File); Item.Link = ((string)("http://" + IPAdress + ":" + PortRemoteFork + "/" + File)).Replace("\\", "/"); Item.Description = Item.Link; Item.Type = ItemType.DIRECTORY; items.Add(Item); } return(items.ToArray()); }
public bool ContainsFold(Fold fold) { for (int i=0; i<this.children.Count; i++) { if ((this.children[i] is Fold) && this.children[i].name == fold.name) { return true; } } return false; }
void Start() { // get a reference to the tear manager tearManager = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); // get a reference to fold fold = GameObject.FindGameObjectWithTag("FoldObject").GetComponent<Fold>(); }
void Start() { // the following is now needed due to the prefab of 'MainObject' GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); screenManagerRef = mainObject.GetComponent<ScreenManager>(); soundManagerRef = mainObject.GetComponent<SoundManager>(); characterControllerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>(); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); // get a reference to the tear manager tearManager = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); // get a reference to fold fold = GameObject.FindGameObjectWithTag("FoldObject").GetComponent<Fold>(); LvlGoalCoreRef = GameObject.FindGameObjectWithTag("GoalCore").GetComponent<LvlGoalCore>(); // Get the global variables reference. GameObject gVar = GameObject.FindGameObjectsWithTag("globalVariables")[0]; globalVariables = gVar.GetComponent<GVariables>(); // if the goal is on the backside move necessary components by offset to be at correct location. if(goalOnBackSide){ // change the box collider on the goal core Vector3 GoalCollider = this.gameObject.GetComponent<BoxCollider>().center; GoalCollider = new Vector3(GoalCollider.x, GoalCollider.y, GoalCollider.z + (offset*2f)); this.gameObject.GetComponent<BoxCollider>().center = GoalCollider; // change the graphics child object position Vector3 GraphicTrans = transform.FindChild("Graphics").transform.position; GraphicTrans = new Vector3(GraphicTrans.x, GraphicTrans.y, GraphicTrans.z + offset); transform.FindChild("Graphics").transform.position = GraphicTrans; // change the goal core child object. Vector3 GoalCoreTrans = transform.FindChild("GoalCore").transform.position; GoalCoreTrans = new Vector3(GoalCoreTrans.x, GoalCoreTrans.y, GoalCoreTrans.z + offset); transform.FindChild("GoalCore").transform.position = GoalCoreTrans; } buttonCamera = GameObject.FindGameObjectWithTag("button"); }
public void FoldFunctionTest() { Fold fold = new Fold(); int value = fold.FoldFunction(new List<int>() { 1, 2, 3, 4, 5 }, 2, (acc, elem) => acc * elem); Assert.AreEqual(value, 240); }
/// <summary> /// Creates a comment fold if the comment spans more than one line. /// </summary> /// <remarks>The text displayed when the comment is folded is the first /// line of the comment.</remarks> private static void CreateCommentFold(IDocument document, List<Fold> foldMarkers, XmlTextReader reader) { if (reader.Value != null) { string comment = reader.Value.Replace("\r\n", "\n"); string[] lines = comment.Split('\n'); if (lines.Length > 1) { // Take off 5 chars to get the actual comment start (takes // into account the <!-- chars. int startCol = reader.LinePosition - 5; int startLine = reader.LineNumber - 1; // Add 3 to the end col value to take into account the '-->' int endCol = lines[lines.Length - 1].Length + startCol + 3; int endLine = startLine + lines.Length - 1; string foldText = String.Concat("<!--", lines[0], "-->"); Fold fold = new Fold(document, startLine, startCol, endLine, endCol, foldText); foldMarkers.Add(fold); } } }
public void Fold_FoldTo_Basic_Test0() { Assert.AreEqual(null, Fold.FoldTo(0)); }
/// <summary> /// Create an element fold if the start and end tag are on /// different lines. /// </summary> private static void CreateElementFold(IDocument document, List<Fold> foldMarkers, XmlTextReader reader, XmlFoldStart foldStart) { int endLine = reader.LineNumber - 1; if (endLine > foldStart.Line) { int endCol = reader.LinePosition + foldStart.Name.Length; Fold fold = new Fold(document, foldStart.Line, foldStart.Column, endLine, endCol, foldStart.FoldText); foldMarkers.Add(fold); } }
/// <summary> /// Gets the logical column. /// </summary> /// <param name="lineNumber">The line number.</param> /// <param name="visualPosX">The visual pos X.</param> /// <param name="inFold">The fold marker that contains the columns (or <c>null</c>).</param> /// <returns>The logical column.</returns> internal TextLocation GetLogicalColumn(int lineNumber, int visualPosX, out Fold inFold) { visualPosX += TextArea.VirtualTop.X; inFold = null; if (lineNumber >= Document.TotalNumberOfLines) { return new TextLocation(visualPosX / ColumnWidth, lineNumber); } if (visualPosX <= 0) { return new TextLocation(0, lineNumber); } int start = 0; // column int posX = 0; // visual position int result; using (Graphics g = TextArea.CreateGraphics()) { // call GetLogicalColumnInternal to skip over text, // then skip over fold markers // and repeat as necessary. // The loop terminates once the correct logical column is reached in // GetLogicalColumnInternal or inside a fold marker. while (true) { LineSegment line = Document.GetLineSegment(lineNumber); Fold nextFolding = FindNextFoldedFoldOnLineAfterColumn(lineNumber, start - 1); int end = nextFolding != null ? nextFolding.StartColumn : int.MaxValue; result = GetLogicalColumnInternal(g, line, start, end, ref posX, visualPosX); // break when GetLogicalColumnInternal found the result column if (result < end) break; // reached fold marker lineNumber = nextFolding.EndLine; start = nextFolding.EndColumn; int newPosX = posX + 1 + MeasureStringWidth(g, nextFolding.FoldText, TextEditorProperties.FontContainer.RegularFont); if (newPosX >= visualPosX) { inFold = nextFolding; if (IsNearerToAThanB(visualPosX, posX, newPosX)) return new TextLocation(nextFolding.StartColumn, nextFolding.StartLine); else return new TextLocation(nextFolding.EndColumn, nextFolding.EndLine); } posX = newPosX; } } return new TextLocation(result, lineNumber); }
public void SetParent(Fold parent) { this.parent = parent; }
public void Fold_FoldTo_Basic_Test() { Assert.AreEqual(42, Fold.FoldTo(384000000)); }
private void ListUpFoldInItems(Fold fold) { bool isOpen; bool isChecked; string itemName; string foldName = fold.name.Remove (0, fold.name.LastIndexOf (SLASH)+1); List<Item> itemList = new List<Item>(); GUI.backgroundColor = GetBackColor (); if (fold.name == ROOT) { GUILayout.BeginHorizontal (GUI.skin.box); } else { GUILayout.BeginHorizontal (m_DefaultStyle); } { isOpen = EditorGUI.Foldout (EditorGUILayout.GetControlRect(), fold.isOpen, foldName); GUI.backgroundColor = m_DefaultColor; isChecked = GUILayout.Toggle (fold.isChecked, "", m_ToggleStyle, GUILayout.ExpandWidth (false)); } GUILayout.EndHorizontal (); if (fold.isChecked != isChecked) { fold.Check (isChecked); } if (isOpen) { fold.Open (); EditorGUI.indentLevel++; itemList.Clear (); for (int i=0; i<fold.children.Count; i++) { if (fold.children[i] is Fold) { ListUpFoldInItems ((Fold)fold.children[i]); } else { itemList.Add (fold.children[i]); } } for (int i=0; i<itemList.Count; i++) { itemName = "- "+itemList[i].name.Remove (0, itemList[i].name.LastIndexOf (SLASH)+1); GUI.backgroundColor = GetBackColor (); GUILayout.BeginHorizontal (m_DefaultStyle); { EditorGUI.LabelField (EditorGUILayout.GetControlRect(), itemName, m_ItemStyle); GUI.backgroundColor = m_DefaultColor; isChecked = GUILayout.Toggle (itemList[i].isChecked, "", m_ToggleStyle, GUILayout.ExpandWidth (false)); if (itemList[i].isChecked != isChecked) { itemList[i].Check (isChecked); } } GUILayout.EndHorizontal (); } EditorGUI.indentLevel--; } else { fold.Close (); } }
private void LoadAssetBundleItems() { string[] assetBundleNames = AssetDatabase.GetAllAssetBundleNames (); string str; Item temp; Fold fold; Item item; m_AssetBundleItems = new List<Item> (); m_AssetFold = new Fold (ROOT); if (EditorPrefs.GetBool (m_SaveKey+ROOT+m_SaveIsOpen, false)) { m_AssetFold.Open (); } if (EditorPrefs.GetBool (m_SaveKey+ROOT+m_SaveIsChecked, false)) { m_AssetFold.CheckOn (); } for (int i=0; i<assetBundleNames.Length; i++) { str = assetBundleNames[i]; if (!TryGetItem (str, out item)) { item = new Item (str); m_AssetBundleItems.Add (item); } if (EditorPrefs.GetBool (m_SaveKey+item.name+m_SaveIsChecked, false)) { item.CheckOn (); } temp = item; while (str.Contains (SLASH)) { str = str.Substring (0, str.LastIndexOf (SLASH)); if (!TryGetFold (str, out fold)) { fold = new Fold (str); m_AssetBundleItems.Add (fold); } if (EditorPrefs.GetBool (m_SaveKey+str+m_SaveIsOpen, false)) { fold.Open (); } if (EditorPrefs.GetBool (m_SaveKey+str+m_SaveIsChecked, false)) { fold.CheckOn (); } if (!fold.ContainsItem (temp)) { if ( (temp is Fold && !fold.ContainsFold ((Fold)temp)) || (!(temp is Fold) && !fold.ContainsItem (temp))) { fold.AddItem (temp); temp.SetParent (fold); } } temp = fold; } if ( (temp is Fold && !m_AssetFold.ContainsFold ((Fold)temp)) || (!(temp is Fold) && !m_AssetFold.ContainsItem (temp))) { m_AssetFold.AddItem (temp); temp.SetParent (m_AssetFold); } } m_AssetBundleItems.Add (m_AssetFold); }
/// <summary> /// Doubles the click selection extend. /// </summary> void DoubleClickSelectionExtend() { Point mousepos = _textArea.MousePositionInternal; _textArea.SelectionManager.ClearSelection(); if (_textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) { Fold marker = _textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - _textArea.TextView.DrawingPosition.X, mousepos.Y - _textArea.TextView.DrawingPosition.Y); if (marker != null && marker.IsFolded) { marker.IsFolded = false; _textArea.MotherTextAreaControl.AdjustScrollBars(); } if (_textArea.Caret.Offset < _textArea.Document.TextLength) { switch (_textArea.Document.GetCharAt(_textArea.Caret.Offset)) { case '"': if (_textArea.Caret.Offset < _textArea.Document.TextLength) { int next = FindNext(_textArea.Document, _textArea.Caret.Offset + 1, '"'); _minSelection = _textArea.Caret.Position; if (next > _textArea.Caret.Offset && next < _textArea.Document.TextLength) { next += 1; } _maxSelection = _textArea.Document.OffsetToPosition(next); } break; default: _minSelection = _textArea.Document.OffsetToPosition(FindWordStart(_textArea.Document, _textArea.Caret.Offset)); _maxSelection = _textArea.Document.OffsetToPosition(FindWordEnd(_textArea.Document, _textArea.Caret.Offset)); break; } _textArea.Caret.Position = _maxSelection; _textArea.SelectionManager.ExtendSelection(_minSelection, _maxSelection); } if (_textArea.SelectionManager.Selections.Count > 0) { ISelection selection = _textArea.SelectionManager.Selections[0]; selection.StartPosition = _minSelection; selection.EndPosition = _maxSelection; _textArea.SelectionManager.SelectionStart = _minSelection; } // after a double-click selection, the caret is placed correctly, // but it is not positioned internally. The effect is when the cursor // is moved up or down a line, the caret will take on the column first // clicked on for the double-click _textArea.SetDesiredColumn(); // HACK WARNING !!! // must refresh here, because when a error tooltip is showed and the underlined // code is double clicked the textArea don't update correctly, updateline doesn't // work ... but the refresh does. // Mike _textArea.Refresh(); } }
/// <summary> /// The entry point of the program /// </summary> /// <param name="args"></param> public static void Main(string[] args) { Fold fold = new Fold(); Console.WriteLine(fold.FoldFunction(new List<int>() { 1, 2, 3 }, 1, (acc, elem) => acc * elem)); }
void OnMouseDown(object sender, MouseEventArgs e) { _textArea.MousePositionInternal = e.Location; Point mousepos = e.Location; if (_doDragDrop) { return; } if (_doubleClick) { _doubleClick = false; return; } if (_textArea.TextView.DrawingPosition.Contains(mousepos.X, mousepos.Y)) { _gotMouseDown = true; _textArea.SelectionManager.SelectFrom.Where = WhereFrom.TextArea; _button = e.Button; // double-click if (_button == MouseButtons.Left && e.Clicks == 2) { int deltaX = Math.Abs(_lastMouseDownPosition.X - e.X); int deltaY = Math.Abs(_lastMouseDownPosition.Y - e.Y); if (deltaX <= SystemInformation.DoubleClickSize.Width && deltaY <= SystemInformation.DoubleClickSize.Height) { DoubleClickSelectionExtend(); _lastMouseDownPosition = new Point(e.X, e.Y); if (_textArea.SelectionManager.SelectFrom.Where == WhereFrom.Gutter) { if (!_minSelection.IsEmpty && !_maxSelection.IsEmpty && _textArea.SelectionManager.Selections.Count > 0) { _textArea.SelectionManager.Selections[0].StartPosition = _minSelection; _textArea.SelectionManager.Selections[0].EndPosition = _maxSelection; _textArea.SelectionManager.SelectionStart = _minSelection; _minSelection = TextLocation.Empty; _maxSelection = TextLocation.Empty; } } return; } } _minSelection = TextLocation.Empty; _maxSelection = TextLocation.Empty; _lastMouseDownPosition = _mouseDownPosition = new Point(e.X, e.Y); if (_button == MouseButtons.Left) { Fold marker = _textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - _textArea.TextView.DrawingPosition.X, mousepos.Y - _textArea.TextView.DrawingPosition.Y); if (marker != null && marker.IsFolded) { if (_textArea.SelectionManager.HasSomethingSelected) { _clickedOnSelectedText = true; } TextLocation startLocation = new TextLocation(marker.StartColumn, marker.StartLine); TextLocation endLocation = new TextLocation(marker.EndColumn, marker.EndLine); _textArea.SelectionManager.SetSelection(new DefaultSelection(_textArea.TextView.Document, startLocation, endLocation)); _textArea.Caret.Position = startLocation; _textArea.SetDesiredColumn(); _textArea.Focus(); return; } if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { ExtendSelectionToMouse(); } else { TextLocation realmousepos = _textArea.TextView.GetLogicalPosition(mousepos.X - _textArea.TextView.DrawingPosition.X, mousepos.Y - _textArea.TextView.DrawingPosition.Y); _clickedOnSelectedText = false; int offset = _textArea.Document.PositionToOffset(realmousepos); if (_textArea.SelectionManager.HasSomethingSelected && _textArea.SelectionManager.IsSelected(offset)) { _clickedOnSelectedText = true; } else { _textArea.SelectionManager.ClearSelection(); if (mousepos.Y > 0 && mousepos.Y < _textArea.TextView.DrawingPosition.Height) { TextLocation pos = new TextLocation { X = realmousepos.X, Y = Math.Min(_textArea.Document.TotalNumberOfLines - 1, realmousepos.Y), }; _textArea.Caret.Position = pos; _textArea.SetDesiredColumn(); } } } } else if (_button == MouseButtons.Right) { // Rightclick sets the cursor to the click position unless // the previous selection was clicked TextLocation realmousepos = _textArea.TextView.GetLogicalPosition(mousepos.X - _textArea.TextView.DrawingPosition.X, mousepos.Y - _textArea.TextView.DrawingPosition.Y); int offset = _textArea.Document.PositionToOffset(realmousepos); if (!_textArea.SelectionManager.HasSomethingSelected || !_textArea.SelectionManager.IsSelected(offset)) { _textArea.SelectionManager.ClearSelection(); if (mousepos.Y > 0 && mousepos.Y < _textArea.TextView.DrawingPosition.Height) { TextLocation pos = new TextLocation { X = realmousepos.X, Y = Math.Min(_textArea.Document.TotalNumberOfLines - 1, realmousepos.Y), }; _textArea.Caret.Position = pos; _textArea.SetDesiredColumn(); } } } } _textArea.Focus(); }