public override List <SignalSample> GetSamples() { SquareGenerator square = new SquareGenerator(0.2d, 3d, 0d, 0.2d); SignalSampler sampler = new SignalSampler(square); return(sampler.GetSamples(20d, 0.1d)); }
private static void SerializeFlatGenerator() { var generator1 = new SquareGenerator(100, 100, new Size(75, 75), 0.5f); var generator2 = new SquareGenerator(100, 100, new Size(75, 75), new Point(25, 25), 0.5f); //var generator1 = new FlatGenerator(200, 200, 1); //var generator2 = new DSNoiseGenerator(200, 200, seed: 10); var filename = GetFilename("serial.json"); var node1 = new GeneratorNode(generator1); var node2 = new GeneratorNode(generator2); var blend = new BlendingNode(BlendModes.Difference); blend.AddDependency(node1); blend.AddDependency(node2); blend.Execute(); var bitmap = blend.Result.AsBitmap(); var filename2 = GetFilename("generated.png"); bitmap.Save(filename2, ImageFormat.Png); Process.Start(filename2); }
void Start () { c = GetComponent<Controller> (); sr = GetComponent<SpriteRenderer> (); sg = GameObject.Find("MapGenerator").GetComponent<SquareGenerator> (); velocity = new Vector3 (); direction = new Vector2 (); stats = new Characteristics (); }
void Start () { stats = new Characteristics(); sr = GetComponent<SpriteRenderer> (); sg = GameObject.Find ("MapGenerator").GetComponent<SquareGenerator>(); controller = GetComponent<Controller> (); gravity = -(2 * stats.jumpHeight) / Mathf.Pow (stats.timeToJumpApex, 2); targetDirection = (int)UnityEngine.Random.Range(0, 1) == 0 ? 1 : -1; jumpVelocity = Mathf.Abs (gravity) * stats.timeToJumpApex; }
public NavigationPage() { InitializeComponent(); int colorNum = 6; Color[] colors = SquareGenerator.randomColor(colorNum); CustomizedButton2 exitButton = new CustomizedButton2("退 出", colors[0]); exitButton.button.Click += exitGame_Click; exitButton.SetValue(Grid.RowProperty, 3); CustomizedButton2 startGameButton = new CustomizedButton2("开始游戏", colors[1]); startGameButton.button.Click += gotoGameModeSel_Click; startGameButton.SetValue(Grid.RowProperty, 0); CustomizedButton2 achievementButton = new CustomizedButton2("成就系统", colors[2]); achievementButton.button.Click += gotoAchievement_Click; achievementButton.SetValue(Grid.RowProperty, 1); CustomizedButton2 settingsButton = new CustomizedButton2("设 置", colors[3]); settingsButton.button.Click += gotoSetting_Click; settingsButton.SetValue(Grid.RowProperty, 2); ButtonsGrid.Children.Add(startGameButton); ButtonsGrid.Children.Add(achievementButton); ButtonsGrid.Children.Add(settingsButton); ButtonsGrid.Children.Add(exitButton); StringGrid title = new StringGrid("Tetris", SquareGenerator.squareSize / 1.1); outerGrid.Children.Add(title); title.SetValue(Grid.RowProperty, 1); title.SetValue(Grid.ColumnProperty, 1); title.noAnimation(); Pic.Cat2Gen pic = new Pic.Cat2Gen(); Pic.PicGenGrid pg = new Pic.PicGenGrid(pic, SquareGenerator.picSquareSize / 1.2); aCanvas.Children.Add(pg); pg.SetValue(Canvas.ZIndexProperty, 0); Canvas.SetRight(pg, 2); Canvas.SetBottom(pg, 2); }
public void FindUsedSquares_GivenTestKey_Returns8108() { string key = "flqrgnkx"; int expected = 8108; int actual = SquareGenerator.FindUsedSquares(key); Assert.AreEqual(expected, actual); }
public void FindUniqueRegions_GivenTestKey_Returns1242() { string key = "flqrgnkx"; int expected = 1242; int actual = SquareGenerator.FindUniqueRegions(key); Assert.AreEqual(expected, actual); }
// used to draw the game public void OnDrawing(Tetris.GameBase.TetrisGame game, Tetris.GameBase.TetrisGame.DrawEventArgs e) { Square[,] image = game.Image; if (imageCache == null) { imageCache = new int[image.GetUpperBound(0) + 1, image.GetUpperBound(1) + 1]; Array.Clear(imageCache, 0, (image.GetUpperBound(0) + 1) * (image.GetUpperBound(1) + 1)); } int i, j; for (i = 0; i < game.Height; i++) { for (j = 0; j < game.Width; j++) { // only draw the changed part if ((image[i, j] == null && imageCache[i, j] != 0) || (image[i, j] != null && image[i, j].Color + image[i, j].SubId != imageCache[i, j])) { imageCache[i, j] = image[i, j] == null ? 0 : image[i, j].Color + image[i, j].SubId; try { squaresMatrix[i, j].Dispatcher.Invoke( new Action( delegate { /* * squaresMatrix[i, j].Fill = * new SolidColorBrush( * colorMap[ * image[i, j] == null * ? 0 * : (image[i, j].Color < colorMap.Length * ? image[i, j].Color * : colorMap.Length - 1)]); */ squaresMatrix[i, j].Fill = SquareGenerator.brushClone( brushesMap[ image[i, j] == null ? 0 : (image[i, j].Color + image[i, j].SubId < brushesMap.Length ? image[i, j].Color + +image[i, j].SubId : brushesMap.Length - 1)]); } )); } catch { } } } } }
// Use this for initialization void Start() { //platformWidth = thePlatform.GetComponent<BoxCollider2D> ().size.x; platformWidths = new float[theObjectPools.Length]; for (int i = 0; i < theObjectPools.Length; i++) { platformWidths[i] = theObjectPools[i].pooledObject.GetComponent <BoxCollider2D>().size.x; } minHeight = transform.position.y; maxHeight = maxHeightPoint.position.y; theSquareGenerator = FindObjectOfType <SquareGenerator> (); }
// the single mode setting private Grid ButtonGridSingle(Grid holder) { Grid aGrid = new Grid(); setGrid(2, 3, aGrid); int colorNum = 6; Color[] colors = SquareGenerator.randomColor(colorNum); CustomizedLabel whoAreYouPlayer1 = whoAreYouLabel(0, colors[0], "昵称:"); TextBox aBox = setTextBox(0, 1, 0); CustomizedButton2 goButton = new CustomizedButton2("开始游戏", colors[1]); //goButton.Width = 100; goButton.button.Click += new RoutedEventHandler( delegate { PlayersName.setName(0, aBox.Text); nav = NavigationService.GetNavigationService(this); SingleModePage nextPage = new SingleModePage(); nextPage.holderWin = holderWin; nav.Navigate(nextPage); }); goButton.SetValue(Grid.RowProperty, 1); CustomizedButton2 backButton = new CustomizedButton2("后 退", colors[2]); //backButton.Width = 100; backButton.button.Click += new RoutedEventHandler( delegate { Grid nextGrid = ButtonGrid1(holder); switchGrid(aGrid, nextGrid, holder, backButton.button); }); backButton.SetValue(Grid.RowProperty, 3); aGrid.Children.Add(whoAreYouPlayer1); aGrid.Children.Add(aBox); aGrid.Children.Add(goButton); aGrid.Children.Add(backButton); return(aGrid); }
private static List <Line> CreateWalls(string[] commandArgs, Position position, List <SavedPosition> savedPositions, List <Line> lines) { IGenerator generator; ISquareOptions walls = new Options(); walls.Fill = false; switch (commandArgs.Length) { // width height block [postition] case 5: walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; walls.CenterX = position.X; walls.CenterY = position.Y; walls.CenterZ = position.Z; break; case 6: walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; var center = savedPositions.Single(a => a.Name.Equals(commandArgs[5])).Position; walls.CenterX = center.X; walls.CenterY = center.Y; walls.CenterZ = center.Z; break; case 8: walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; walls.CenterX = commandArgs[5].ToInt(); walls.CenterY = commandArgs[6].ToInt(); walls.CenterZ = commandArgs[7].ToInt(); break; } generator = new SquareGenerator(); lines = generator.Run((Options)walls); return(lines); }
// the first group of setting private Grid ButtonGrid1(Grid holder) { Grid aGrid = new Grid(); setGrid(1, 3, aGrid); int colorNum = 6; Color[] colors = SquareGenerator.randomColor(colorNum); CustomizedButton2 singleModeButton = new CustomizedButton2("单人游戏", colors[0]); singleModeButton.button.Click += new RoutedEventHandler( delegate { Grid nextGrid = this.ButtonGridSingle(holder); switchGrid(aGrid, nextGrid, holder, singleModeButton.button); }); singleModeButton.SetValue(Grid.RowProperty, 0); CustomizedButton2 dualModeButton = new CustomizedButton2("双人游戏", colors[1]); dualModeButton.button.Click += new RoutedEventHandler( delegate { Grid nextGrid = this.ButtonGridDual(holder); switchGrid(aGrid, nextGrid, holder, dualModeButton.button); }); dualModeButton.SetValue(Grid.RowProperty, 1); CustomizedButton2 backButton = new CustomizedButton2("后 退", colors[2]); backButton.button.Click += back_Click; backButton.SetValue(Grid.RowProperty, 3); aGrid.Children.Add(singleModeButton); aGrid.Children.Add(dualModeButton); aGrid.Children.Add(backButton); return(aGrid); }
private static List <Line> CreateWalls(IMinecraftCommandService commandService, string[] commandArgs, Position position, List <SavedPosition> savedPositions) { ISquareOptions walls = new Options { Fill = false, Thickness = 1 }; var location = position; switch (commandArgs.Length) { case 5: // width(X) length(Z) height(Y) block @ current position walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; break; case 6: // width(X) length(Z) height(Y) block savedposition case 7: // width(X) length(Z) height(Y) block savedposition thickness case 8: // width(X) length(Z) height(Y) block x y z case 9: // width(X) length(Z) height(Y) block x y z thickness walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; location = location.GetAbsolutePosition(commandArgs.Skip(5).Take(3), savedPositions); walls.Thickness = (commandArgs.ElementAtOrDefault(commandArgs.Length == 7 ? 6 : 8) ?? "1").ToInt(); break; default: var help = "\nCREATE WALLS\n" + "create walls width(X) length(Z) height(Y) block - defaults to center at current position, thickness 1\n" + "create walls width(X) length(Z) height(Y) block [named position] [thickness]\n" + "create walls width(X) length(Z) height(Y) block [x y z] [thickness]"; commandService.Status(help); return(new List <Line>()); } walls.Start = location.ToPoint(); IGenerator generator = new SquareGenerator(); return(generator.Run((Options)walls)); }
public static float[] CreateTable(int size, WaveformEnum type) { Generator generator; if (type == WaveformEnum.Sine) { generator = new SineGenerator(new GeneratorDescriptor()); } else if (type == WaveformEnum.Square) { generator = new SquareGenerator(new GeneratorDescriptor()); } else if (type == WaveformEnum.Triangle) { generator = new TriangleGenerator(new GeneratorDescriptor()); } else if (type == WaveformEnum.Saw) { generator = new SawGenerator(new GeneratorDescriptor()); } else if (type == WaveformEnum.WhiteNoise) { generator = new WhiteNoiseGenerator(new GeneratorDescriptor()); } else { return(null); } float[] table = new float[size]; double phase, increment; phase = generator.StartPhase; increment = generator.Period / size; for (int x = 0; x < table.Length; x++) { table[x] = generator.GetValue(phase); phase += increment; } return(table); }
// the dual mode setting private Grid ButtonGridDual(Grid holder) { String[] contents1 = new string[2] { " 人 ", "电 脑" }; String[] contents2 = new string[3] { "低难度", "中难度", "高难度" }; Grid aGrid = new Grid(); setGrid(2, 6, aGrid); int colorNum = 6; Color[] colors = SquareGenerator.randomColor(colorNum); CustomizedLabel player1 = whoAreYouLabel(0, colors[5], "玩家1:"); SwitchLabel player1Sel = setSwitchLabel(0, contents1, 1); CustomizedLabel whoAreYouPlayer1 = whoAreYouLabel(1, colors[0], "昵称:"); CustomizedLabel difficulty1 = whoAreYouLabel(1, colors[0], "难 度:"); difficulty1.Opacity = 0; TextBox aBox1 = setTextBox(1, 1, 0); SwitchLabel dif1Sel = setSwitchLabel(1, contents2, 0); CustomizedLabel player2 = whoAreYouLabel(2, colors[3], "玩家2:"); SwitchLabel player2Sel = setSwitchLabel(2, contents1, 1); CustomizedLabel whoAreYouPlayer2 = whoAreYouLabel(3, colors[4], "昵称:"); CustomizedLabel difficulty2 = whoAreYouLabel(3, colors[4], "难 度:"); difficulty2.Opacity = 0; TextBox aBox2 = setTextBox(3, 1, 1); SwitchLabel dif2Sel = setSwitchLabel(3, contents2, 0); DualModePage.gameMode[] pModes = new DualModePage.gameMode[2]; CustomizedButton2 goButton = new CustomizedButton2("开始游戏", colors[2]); // used to store the settings and go to dual game goButton.button.Click += new RoutedEventHandler( delegate { if (player1Sel.getLabelIndex() == 0) // player1 is 人 { PlayersName.setName(0, aBox1.Text); pModes[0] = new DualModePage.gameMode(0, 0); } else { PlayersName.setName(0, ""); pModes[0] = new DualModePage.gameMode(1, dif1Sel.getLabelIndex()); } if (player2Sel.getLabelIndex() == 0) // player2 is 人 { PlayersName.setName(1, aBox2.Text); pModes[1] = new DualModePage.gameMode(0, 0); } else { PlayersName.setName(1, ""); pModes[1] = new DualModePage.gameMode(1, dif2Sel.getLabelIndex()); } nav = NavigationService.GetNavigationService(this); DualModePage nextPage = new DualModePage(pModes); nextPage.holderWin = holderWin; nav.Navigate(nextPage); }); goButton.SetValue(Grid.RowProperty, 4); CustomizedButton2 backButton = new CustomizedButton2("后 退", colors[1]); backButton.button.Click += new RoutedEventHandler( delegate { Grid nextGrid = ButtonGrid1(holder); switchGrid(aGrid, nextGrid, holder, backButton.button); }); backButton.SetValue(Grid.RowProperty, 6); aGrid.Children.Add(player1); aGrid.Children.Add(player2); aGrid.Children.Add(player1Sel); aGrid.Children.Add(whoAreYouPlayer1); aGrid.Children.Add(aBox1); aGrid.Children.Add(player2Sel); aGrid.Children.Add(whoAreYouPlayer2); aGrid.Children.Add(aBox2); aGrid.Children.Add(goButton); aGrid.Children.Add(backButton); setClickSwitch(whoAreYouPlayer1, difficulty1, aBox1, dif1Sel, player1Sel, aGrid); setClickSwitch(whoAreYouPlayer2, difficulty2, aBox2, dif2Sel, player2Sel, aGrid); return(aGrid); }
private List <Line> CreateWalls(string[] commandArgs, Position position, List <SavedPosition> savedPositions, List <Line> lines) { IGenerator generator; ISquareOptions walls = new Options(); walls.Fill = false; switch (commandArgs.Length) { // width height block [postition] case 5: walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; walls.CenterX = position.X; walls.CenterY = position.Y; walls.CenterZ = position.Z; break; case 6: walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; var center = savedPositions.Single(a => a.Name.Equals(commandArgs[5])).Position; walls.CenterX = center.X; walls.CenterY = center.Y; walls.CenterZ = center.Z; break; case 8: walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; walls.CenterX = commandArgs[5].ToInt(); walls.CenterY = commandArgs[6].ToInt(); walls.CenterZ = commandArgs[7].ToInt(); walls.Thickness = 1; break; case 9: walls.Width = commandArgs[1].ToInt(); walls.Length = commandArgs[2].ToInt(); walls.Height = commandArgs[3].ToInt(); walls.Block = commandArgs[4]; walls.CenterX = commandArgs[5].ToInt(); walls.CenterY = commandArgs[6].ToInt(); walls.CenterZ = commandArgs[7].ToInt(); walls.Thickness = commandArgs[8].ToInt(); break; default: var help = "create walls length width height block - center at current position\n" + "create walls length width height block [named position]\n" + "create walls length width height block x y z"; _minecraft.Status(help); return(new List <Line>()); } generator = new SquareGenerator(); lines = generator.Run((Options)walls); return(lines); }
// next block drawing public void OnDrawing(Tetris.GameBase.TetrisGame game, Tetris.GameBase.TetrisGame.DrawEventArgs e) { var factory = game.Factory as CacheFactory; var block = factory.NextBlock(); if (block.Id == id) { return; } id = block.Id; int i, j; try { nextBlockGrid.Dispatcher.Invoke( new Action( delegate { nextBlockGrid.SetValue(Canvas.TopProperty, (this.Height - 6 - _squareSize * block.Width) / 2); nextBlockGrid.SetValue(Canvas.LeftProperty, (this.Width - 6 - _squareSize * block.Height) / 2); } )); } catch { } for (i = 0; i < _gridHeight; i++) { for (j = 0; j < _gridWidth; j++) { try { squaresMatrix[i, j].Dispatcher.Invoke( new Action( delegate { /* * squaresMatrix[i, j].Fill = * //new SolidColorBrush(Colors.Transparent); * * new SolidColorBrush(colorMap[block.SquareAt(j, i) == null ? 0 : * (block.SquareAt(j, i).Color < colorMap.Length ? * block.SquareAt(j, i).Color : colorMap.Length - 1)]); */ squaresMatrix[i, j].Fill = SquareGenerator.brushClone( brushesMap[ block.SquareAt(j, i) == null ? 0 : (block.SquareAt(j, i).Color + block.SquareAt(j, i).SubId < brushesMap.Length ? block.SquareAt(j, i).Color + block.SquareAt(j, i).SubId : brushesMap.Length - 1)]); } )); } catch { } } } }
public Target(SquareGenerator squareGenerator) { this.squareGenerator = squareGenerator; }
public Pattern(SquareGenerator squareGenerator) { target_ = new Target(squareGenerator); background_ = new Background(squareGenerator); }
public Background(SquareGenerator squareGenerator) { this.squareGenerator = squareGenerator; }