public void MoveAPoint(int id, Point newPoint) { // Get the old point Point oldPoint = points[id]; // Get the previous point Point pointPrevious = points[(id + 3) % 4]; // Get the next point Point pointNext = points[(id + 1) % 4]; // Get the opposite point Point pointOpposite = points[(id + 2) % 4]; // I call sides points, but they are actually vectors. // Get side from 'oldPoint' to 'pointPrevious'. Point sidePrevious = pointPrevious.Substract(oldPoint); // Get side from 'oldPoint' to 'pointNext'. Point sideNext = pointNext.Substract(oldPoint); // Get side from 'pointOpposite' to 'newPoint'. Point sideTransversal = newPoint.Substract(pointOpposite); PointF previousProjection; PointF nextProjection; // ---------- Last edit starts here. ---------- if (sideNext.X == 0 && sideNext.Y == 0) { if (sidePrevious.X == 0 && sidePrevious.Y == 0) { return; } sideNext = new PointF(-sidePrevious.Y, sidePrevious.X); } else { sidePrevious = new PointF(-sideNext.Y, sideNext.X); } // ---------- Last edit ends here. ---------- Point previousProjection = Projection(delta, sidePrevious); Point nextProjection = Projection(delta, sideNext); pointNext = pointOpposite.AddPoints(previousProjection); pointPrevious = pointOpposite.AddPoints(nextProjection); pointNext.SetToPoint(pointNext.AddPoints(previousProjection)); pointPrevious.SetToPoint(pointPrevious.AddPoints(nextProjection)); oldPoint.SetToPoint(newPoint); }
public void MoveBlock_WithoutHindrance_MoveBlock(int move_x, int move_y) { Point startPoint = new Point(1, 2); Block block = new Block(); _board.AddBlockAt(block, startPoint); Point byPoint = new Point(move_x, move_y); _board.MoveBlock(block, byPoint); Point endPoint = Point.AddPoints(startPoint, byPoint); Assert.Null(_board.BlockAt(startPoint)); Assert.Equal(_board.BlockAt(endPoint), block); }
public void MoveBlock_AgainstOtherBlock_DontMoveBlock(int move_x, int move_y) { Point startPoint = new Point(1, 2); Block block = new Block(); _board.AddBlockAt(block, startPoint); Point byPoint = new Point(move_x, move_y); Point endPoint = Point.AddPoints(startPoint, byPoint); Block blockInTheWay = new Block(); _board.AddBlockAt(blockInTheWay, endPoint); _board.MoveBlock(block, byPoint); Assert.Equal(_board.BlockAt(startPoint), block); Assert.Equal(_board.BlockAt(endPoint), blockInTheWay); }
//Given a point, returns all (valid) neighbours public static List <Point> FindAllNeighbours(Point startingPoint, List <Point> generators) { List <Point> neighbours = new List <Point>(); var dimension = startingPoint.GetDimension(); var validFlag = true; foreach (Point generator in generators) { validFlag = true; Point newPoint = Point.AddPoints(startingPoint, generator); if (newPoint == null) { Console.WriteLine("ERROR: startingPoint and generator are not the same dimension."); continue; } if (!Heuristics.TestDoubleDescription(newPoint, generators)) { validFlag = false; Console.WriteLine("Point: " + newPoint.ToString() + " eliminated because of DD."); } if (validFlag && !Heuristics.TestEachCoordinate(newPoint)) { validFlag = false; Console.WriteLine("Point: " + newPoint.ToString() + " eliminated because of Coordinate Test."); } if (validFlag) { neighbours.Add(newPoint); } } //add each vector to starting point //use heuristics to determine if point is valid //if valid, add to list (neighbours) //if not valid, log reason why it's not valid. return(neighbours); }
public void Update() { if (!Visible) return; ShowInstructionalButtons(); NativeFunction.CallByName<uint>("HIDE_HUD_AND_RADAR_THIS_FRAME"); ProcessControls(); ProcessMouse(); var res = UIMenu.GetScreenResolutionMantainRatio(); var safe = new Point(300, 180); new ResText(Title, new Point(safe.X, safe.Y - 80), 1f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Left) { DropShadow = true, }.Draw(); if (Photo == null) { new Sprite("char_multiplayer", "char_multiplayer", new Point((int)res.Width - safe.X - 64, safe.Y - 80), new Size(64, 64)).Draw(); } else { Photo.Position = new Point((int)res.Width - safe.X - 100, safe.Y - 80); Photo.Size = new Size(64, 64); Photo.Draw(); } new ResText(Name, new Point((int)res.Width - safe.X - 70, safe.Y - 95), 0.7f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Right) { DropShadow = true, }.Draw(); string subt = Money; if (string.IsNullOrEmpty(Money)) { subt = DateTime.Now.ToString(); } new ResText(subt, new Point((int)res.Width - safe.X - 70, safe.Y - 60), 0.4f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Right) { DropShadow = true, }.Draw(); new ResText(MoneySubtitle, new Point((int)res.Width - safe.X - 70, safe.Y - 40), 0.4f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Right) { DropShadow = true, }.Draw(); for (int i = 0; i < Tabs.Count; i++) { var activeSize = res.Width - 2 * safe.X; activeSize -= 4 * 5; int tabWidth = (int)activeSize / 5; var tabColor = Tabs[i].Active ? Color.White : Color.Black; new ResRectangle(safe.AddPoints(new Point((tabWidth + 5) * i, 0)), new Size(tabWidth, 40), Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)).Draw(); new ResText(Tabs[i].Title.ToUpper(), safe.AddPoints(new Point((tabWidth / 2) + (tabWidth + 5) * i, 5)), 0.35f, Tabs[i].Active ? Color.Black : Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Centered).Draw(); if (Tabs[i].Active) { new ResRectangle(safe.SubtractPoints(new Point(-((tabWidth + 5) * i), 10)), new Size(tabWidth, 10), Color.DodgerBlue).Draw(); } } Tabs[Index].Draw(); _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1); _sc.Render2D(); }
public void Update() { if (!Visible || TemporarilyHidden) { return; } ShowInstructionalButtons(); Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME); Function.Call(Hash._SHOW_CURSOR_THIS_FRAME); var res = UIMenu.GetScreenResolutionMaintainRatio(); var safe = new Point(300, 180); if (!HideTabs) { new UIResText(Title, new Point(safe.X, safe.Y - 80), 1f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true, }.Draw(); if (Photo == null) { new Sprite("char_multiplayer", "char_multiplayer", new Point((int)res.Width - safe.X - 64, safe.Y - 80), new Size(64, 64)).Draw(); } else { Photo.Position = new Point((int)res.Width - safe.X - 100, safe.Y - 80); Photo.Size = new Size(64, 64); Photo.Draw(); } new UIResText(Name, new Point((int)res.Width - safe.X - 70, safe.Y - 95), 0.7f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); string t = Money; if (string.IsNullOrEmpty(Money)) { t = DateTime.Now.ToString(); } new UIResText(t, new Point((int)res.Width - safe.X - 70, safe.Y - 60), 0.4f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); string subt = MoneySubtitle; if (string.IsNullOrEmpty(MoneySubtitle)) { subt = ""; } new UIResText(subt, new Point((int)res.Width - safe.X - 70, safe.Y - 40), 0.4f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); for (int i = 0; i < Tabs.Count; i++) { var activeSize = res.Width - 2 * safe.X; activeSize -= 4 * 5; int tabWidth = (int)activeSize / Tabs.Count; Game.EnableControlThisFrame(0, Control.CursorX); Game.EnableControlThisFrame(0, Control.CursorY); var hovering = UIMenu.IsMouseInBounds(safe.AddPoints(new Point((tabWidth + 5) * i, 0)), new Size(tabWidth, 40)); var tabColor = Tabs[i].Active ? Color.White : hovering?Color.FromArgb(100, 50, 50, 50) : Color.Black; new UIResRectangle(safe.AddPoints(new Point((tabWidth + 5) * i, 0)), new Size(tabWidth, 40), Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)).Draw(); new UIResText(Tabs[i].Title.ToUpper(), safe.AddPoints(new Point((tabWidth / 2) + (tabWidth + 5) * i, 5)), 0.35f, Tabs[i].Active ? Color.Black : Color.White, Font.ChaletLondon, UIResText.Alignment.Centered) .Draw(); if (Tabs[i].Active) { new UIResRectangle(safe.SubtractPoints(new Point(-((tabWidth + 5) * i), 10)), new Size(tabWidth, 10), Color.DodgerBlue).Draw(); } if (hovering && Game.IsControlJustPressed(0, Control.CursorAccept) && !Tabs[i].Active) { Tabs[Index].Active = false; Tabs[Index].Focused = false; Tabs[Index].Visible = false; Index = (1000 - (1000 % Tabs.Count) + i) % Tabs.Count; Tabs[Index].Active = true; Tabs[Index].Focused = true; Tabs[Index].Visible = true; Tabs[Index].JustOpened = true; if (Tabs[Index].CanBeFocused) { FocusLevel = 1; } else { FocusLevel = 0; } Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } } } Tabs[Index].Draw(); _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1); _sc.Render2D(); }
public void Update() { if (!Visible) { return; } ShowInstructionalButtons(); Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME); ProcessControls(); ProcessMouse(); var res = UIMenu.GetScreenResolutionMantainRatio(); var safe = new Point(300, 180); new UIResText(Title, new Point(safe.X, safe.Y - 80), 1f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true, }.Draw(); if (Photo == null) { new Sprite("char_multiplayer", "char_multiplayer", new Point((int)res.Width - safe.X - 64, safe.Y - 80), new Size(64, 64)).Draw(); } else { Photo.Position = new Point((int)res.Width - safe.X - 100, safe.Y - 80); Photo.Size = new Size(64, 64); Photo.Draw(); } new UIResText(Name, new Point((int)res.Width - safe.X - 70, safe.Y - 95), 0.7f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); string t = Money; if (string.IsNullOrEmpty(Money)) { t = DateTime.Now.ToString(); } new UIResText(t, new Point((int)res.Width - safe.X - 70, safe.Y - 60), 0.4f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); string subt = MoneySubtitle; if (string.IsNullOrEmpty(MoneySubtitle)) { subt = ""; } new UIResText(subt, new Point((int)res.Width - safe.X - 70, safe.Y - 40), 0.4f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); for (int i = 0; i < Tabs.Count; i++) { var activeSize = res.Width - 2 * safe.X; activeSize -= 4 * 5; int tabWidth = (int)activeSize / 5; var tabColor = Tabs[i].Active ? Color.White : Color.Black; new UIResRectangle(safe.AddPoints(new Point((tabWidth + 5) * i, 0)), new Size(tabWidth, 40), Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)).Draw(); new UIResText(Tabs[i].Title.ToUpper(), safe.AddPoints(new Point((tabWidth / 2) + (tabWidth + 5) * i, 5)), 0.35f, Tabs[i].Active ? Color.Black : Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw(); if (Tabs[i].Active) { new UIResRectangle(safe.SubtractPoints(new Point(-((tabWidth + 5) * i), 10)), new Size(tabWidth, 10), Color.DodgerBlue).Draw(); } } Tabs[Index].Draw(); _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1); _sc.Render2D(); }
public void Update() { if (!Visible || TemporarilyHidden) { return; } ShowInstructionalButtons(); NativeFunction.Natives.HideHudAndRadarThisFrame(); //NativeFunction.CallByHash<uint>(0xaae7ce1d63167423); // _SHOW_CURSOR_THIS_FRAME ProcessControls(); var res = UIMenu.GetScreenResolutionMantainRatio(); var safe = new Point(300, 180); if (!HideTabs) { ResText.Draw(Title, new Point(safe.X, safe.Y - 80), 1f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Left, true, false, Size.Empty); if (Photo == null) { Sprite.Draw("char_multiplayer", "char_multiplayer", new Point((int)res.Width - safe.X - 64, safe.Y - 80), new Size(64, 64), 0f, Color.White); } else { Photo.Position = new Point((int)res.Width - safe.X - 100, safe.Y - 80); Photo.Size = new Size(64, 64); Photo.Draw(); } ResText.Draw(Name, new Point((int)res.Width - safe.X - 70, safe.Y - 95), 0.7f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Right, true, false, Size.Empty); string subt = Money; if (string.IsNullOrEmpty(Money)) { subt = DateTime.Now.ToString(); } ResText.Draw(subt, new Point((int)res.Width - safe.X - 70, safe.Y - 60), 0.4f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Right, true, false, Size.Empty); ResText.Draw(MoneySubtitle, new Point((int)res.Width - safe.X - 70, safe.Y - 40), 0.4f, Color.White, Common.EFont.ChaletComprimeCologne, ResText.Alignment.Right, true, false, Size.Empty); for (int i = 0; i < Tabs.Count; i++) { var activeSize = res.Width - 2 * safe.X; activeSize -= 4 * 5; int tabWidth = (int)activeSize / Tabs.Count; //Game.DisableControlAction(0, GameControl.CursorX, false); //Game.DisableControlAction(0, GameControl.CursorY, false); //bool hovering = UIMenu.IsMouseInBounds(safe.AddPoints(new Point((tabWidth + 5) * i, 0)), new Size(tabWidth, 40)); var tabColor = Tabs[i].Active ? Color.White : /*hovering ? Color.FromArgb(100, 50, 50, 50) :*/ Color.Black; ResRectangle.Draw(safe.AddPoints(new Point((tabWidth + 5) * i, 0)), new Size(tabWidth, 40), Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)); ResText.Draw(Tabs[i].Title.ToUpper(), safe.AddPoints(new Point((tabWidth / 2) + (tabWidth + 5) * i, 5)), 0.35f, Tabs[i].Active ? Color.Black : Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Centered, false, false, Size.Empty); if (Tabs[i].Active) { ResRectangle.Draw(safe.SubtractPoints(new Point(-((tabWidth + 5) * i), 10)), new Size(tabWidth, 10), Color.DodgerBlue); } //if (hovering && Common.IsDisabledControlJustPressed(0, GameControl.CursorAccept) && !Tabs[i].Active) //{ // Tabs[Index].Active = false; // Tabs[Index].Focused = false; // Tabs[Index].Visible = false; // Index = (1000 - (1000 % Tabs.Count) + i) % Tabs.Count; // Tabs[Index].Active = true; // Tabs[Index].Focused = true; // Tabs[Index].Visible = true; // Tabs[Index].JustOpened = true; // FocusLevel = Tabs[Index].CanBeFocused ? 1 : 0; // Common.PlaySound("NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET"); //} } } Tabs[Index].Draw(); _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1); _sc.Render2D(); }
public void Update() { if (!Visible || TemporarilyHidden) return; ShowInstructionalButtons(); Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME); Function.Call(Hash._SHOW_CURSOR_THIS_FRAME); var res = UIMenu.GetScreenResolutionMantainRatio(); var safe = new Point(300, 180); if (!HideTabs) { new UIResText(Title, new Point(safe.X, safe.Y - 80), 1f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { DropShadow = true, }.Draw(); if (Photo == null) { new Sprite("char_multiplayer", "char_multiplayer", new Point((int) res.Width - safe.X - 64, safe.Y - 80), new Size(64, 64)).Draw(); } else { Photo.Position = new Point((int) res.Width - safe.X - 100, safe.Y - 80); Photo.Size = new Size(64, 64); Photo.Draw(); } new UIResText(Name, new Point((int) res.Width - safe.X - 70, safe.Y - 95), 0.7f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); string t = Money; if (string.IsNullOrEmpty(Money)) { t = DateTime.Now.ToString(); } new UIResText(t, new Point((int) res.Width - safe.X - 70, safe.Y - 60), 0.4f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); string subt = MoneySubtitle; if (string.IsNullOrEmpty(MoneySubtitle)) { subt = ""; } new UIResText(subt, new Point((int) res.Width - safe.X - 70, safe.Y - 40), 0.4f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Right) { DropShadow = true, }.Draw(); for (int i = 0; i < Tabs.Count; i++) { var activeSize = res.Width - 2*safe.X; activeSize -= 4*5; int tabWidth = (int) activeSize/Tabs.Count; Game.EnableControl(0, Control.CursorX); Game.EnableControl(0, Control.CursorY); var hovering = UIMenu.IsMouseInBounds(safe.AddPoints(new Point((tabWidth + 5)*i, 0)), new Size(tabWidth, 40)); var tabColor = Tabs[i].Active ? Color.White : hovering ? Color.FromArgb(100, 50, 50, 50) : Color.Black; new UIResRectangle(safe.AddPoints(new Point((tabWidth + 5)*i, 0)), new Size(tabWidth, 40), Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)).Draw(); new UIResText(Tabs[i].Title.ToUpper(), safe.AddPoints(new Point((tabWidth/2) + (tabWidth + 5)*i, 5)), 0.35f, Tabs[i].Active ? Color.Black : Color.White, Font.ChaletLondon, UIResText.Alignment.Centered) .Draw(); if (Tabs[i].Active) { new UIResRectangle(safe.SubtractPoints(new Point(-((tabWidth + 5)*i), 10)), new Size(tabWidth, 10), Color.DodgerBlue).Draw(); } if (hovering && Game.IsControlJustPressed(0, Control.CursorAccept) && !Tabs[i].Active) { Tabs[Index].Active = false; Tabs[Index].Focused = false; Tabs[Index].Visible = false; Index = (1000 - (1000%Tabs.Count) + i)%Tabs.Count; Tabs[Index].Active = true; Tabs[Index].Focused = true; Tabs[Index].Visible = true; Tabs[Index].JustOpened = true; if (Tabs[Index].CanBeFocused) FocusLevel = 1; else FocusLevel = 0; Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1); } } } Tabs[Index].Draw(); _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1); _sc.Render2D(); }
static void Main(string[] args) { Point a = new Point(1, 2); Point b = new Point(2, 4); Point c = a.AddPoints(b); }
//*******Ellenőrzési fázis******* //Adott pontot és szomszédjait "rekurzivan" vizsgálja, hogy kapcsolatban vannak-e List <Point> IsConnected(Point checkedPoint, bool isItMainCall) { List <Point> listOfConnectedPoints = new List <Point>(); int valueOfOurPoint = GetValueofPoint(checkedPoint); List <Point> pointsInLine = new List <Point>(); int sameType = 0; //Irányok Point[] directions = { Point.Up, Point.Right, Point.Down, Point.Left }; //A pontot vizsgálva végigmegy az irányokon és vonalat keres (+ alakban ellenőriz) /* [X] * XX[X]O vagy X O * X */ foreach (Point dir in directions) { pointsInLine.Clear(); sameType = 0; //Minden irányban 2 távolságig elmegy for (int i = 1; i < 3; i++) { Point nextPoint = Point.AddPoints(checkedPoint, Point.MultiplyPoint(dir, i)); //Ha igen akkor szamontartjuk es noveljuk a countert if (GetValueofPoint(nextPoint) == valueOfOurPoint) { pointsInLine.Add(nextPoint); sameType++; } } //Ha adott irányban több azonos típus van if (sameType > 1) { //A fő connection listához adjuk a pontjainkat IncludePoints(ref listOfConnectedPoints, pointsInLine); } } //Check hogy egy match közepe vagyunk-e //Pl: X[X]X for (int i = 0; i < 2; i++) { pointsInLine.Clear(); sameType = 0; Point[] checkedPoints = { Point.AddPoints(checkedPoint, directions[i]), Point.AddPoints(checkedPoint, directions[i + 2]) }; foreach (Point nextPoint in checkedPoints) { if (GetValueofPoint(nextPoint) == valueOfOurPoint) { pointsInLine.Add(nextPoint); sameType++; } } if (sameType > 1) { IncludePoints(ref listOfConnectedPoints, pointsInLine); //A fő connection listához adjuk a pontjainkat } } //Ellenőrzi hogy van-e 2x2, azaz square match //Pl: X X // [X]X for (int i = 0; i < 4; i++) { pointsInLine.Clear(); sameType = 0; int nextDirection = i + 1; if (nextDirection >= 4) { nextDirection -= 4; } //Hozzaadja a horizontal, vertical es diagonal szomszedokat Point[] nextPoints = { Point.AddPoints(checkedPoint, directions[i]), Point.AddPoints(checkedPoint, directions[nextDirection]), Point.AddPoints(checkedPoint, Point.AddPoints(directions[i], directions[nextDirection])) }; foreach (Point nextPoint in nextPoints) { if (GetValueofPoint(nextPoint) == valueOfOurPoint) { pointsInLine.Add(nextPoint); sameType++; } } if (sameType > 2) { IncludePoints(ref listOfConnectedPoints, pointsInLine); //A fo connected listahoz adja ezeket a pontokat } } //Rekurziós cucc if (isItMainCall) { for (int i = 0; i < listOfConnectedPoints.Count; i++) { IncludePoints(ref listOfConnectedPoints, IsConnected(listOfConnectedPoints[i], false)); } } return(listOfConnectedPoints); }