public void Init(GameController game, GameGrid grid, Hud hud) { this.game = game; this.grid = grid; this.hud = hud; SelectGameTool(GameTools.TILE); }
void Awake() { // !BETTER NOT DOING THIS HERE! DOTween.Init (); disposables = new CompositeDisposable (); spacePartition = new GameGrid (planet.transform); }
private void Awake() { gameGrid = GameGrid.Instance; waitTime = new WaitForSeconds(spawnFrequency); rightSpawnIndex = gameGrid.Width - 1; EventManager.OnMoveTopDown += UpdateHeight; }
public void activate(GameGrid grid) { if (Activate != null) { Activate(this, new EventArgs()); } grid.GetCell(location).emptyCell(); }
private void Initialize(InputReceiver inputReceiver, GameGrid gameGrid, IBlockItemsPoolModule blockItemsPoolModule, Option <BlockItem[]> blockItems) { GameGrid = gameGrid; BlockItems = blockItems; _blockItemsPoolModule = blockItemsPoolModule; SubscribeToObservables(inputReceiver); }
public static List <Node> Astar(Vector3 a_StartPos, Vector3 a_TargetPos, GameGrid grid) { Node StartNode = grid.NodeFromWorldPosition(a_StartPos); Node TargetNode = grid.NodeFromWorldPosition(a_TargetPos); if (TargetNode.IsWall) { TargetNode = grid.GetNonWallNeighbor(TargetNode, a_TargetPos); } List <Node> OpenList = new List <Node>(); HashSet <Node> ClosedList = new HashSet <Node>(); List <Node> FinalPath = new List <Node>(); OpenList.Add(StartNode); while (OpenList.Count > 0) { Node CurrentNode = OpenList[0]; for (int i = 1; i < OpenList.Count; i++) { if (OpenList[i].FCost < CurrentNode.FCost && OpenList[i].hCost < CurrentNode.hCost) { CurrentNode = OpenList[i]; } } OpenList.Remove(CurrentNode); ClosedList.Add(CurrentNode); if (CurrentNode == TargetNode) { FinalPath = GetFinalPath(StartNode, TargetNode); break; } foreach (Node NeighborNode in grid.GetNeighboringNodes(CurrentNode)) { if (NeighborNode.IsWall || ClosedList.Contains(NeighborNode)) { continue; } int MoveCost = CurrentNode.gCost + GetManhattenDistance(CurrentNode, NeighborNode); if (MoveCost < NeighborNode.FCost || !OpenList.Contains(NeighborNode)) { NeighborNode.gCost = MoveCost; NeighborNode.hCost = GetManhattenDistance(NeighborNode, TargetNode); NeighborNode.Parent = CurrentNode; if (!OpenList.Contains(NeighborNode)) { OpenList.Add(NeighborNode); } } } } return(FinalPath); }
public static ShapeElement Create(InputReceiver inputReceiver, GameGrid gameGrid, IBlockItemsPoolModule blockItemsPoolModule, Option <BlockItem[]> blockItems) { var shapeGameObject = new GameObject("Shape"); var blockGroups = shapeGameObject.AddComponent <ShapeElement>(); blockGroups.Initialize(inputReceiver, gameGrid, blockItemsPoolModule, blockItems); return(blockGroups); }
public TurtleChallengeUnitTests() { _gameGrid = JsonConvert.DeserializeObject <GameGrid>(File.ReadAllText("TestGameGrid.json")); _gameObject = new GameObject(_gameGrid.Rows, _gameGrid.Columns, _gameGrid.TurtlePosition.Position, _gameGrid.Mines.Select(m => m.Position), _gameGrid.Exit.Position); }
public void WhenGridIsConstructedWidthAndHeightMatch() { int width = 100; int height = 120; var gameGrid = new GameGrid(width, height); Assert.AreEqual(width, gameGrid.Width); Assert.AreEqual(height, gameGrid.Height); }
// Use this for initialization void Start() { for (int i = 0; i < GameGrid.GetnumberOfPipes(); i++) { Transform child = this.gameObject.transform.GetChild(i); Animator animator = child.gameObject.GetComponent <Animator>(); animator.SetBool("isWhite", true); child.GetComponent <SpriteRenderer>().sortingOrder = 1; } }
public GridCell GetNeighbor(GridCell cell, GameGrid grid, MoveDirection dir) { var offset = dir.ToOffset(); var neighborPosition = cell.TargetGridPosition.Translate(offset); var cellAtPosition = grid.FilledCells.FirstOrDefault(p => p.TargetGridPosition.X == neighborPosition.X && p.TargetGridPosition.Y == neighborPosition.Y); return(cellAtPosition); }
public void GenerateMap(GameGrid grid, Texture2D map, GameGridManager manager) { for (int widthIndex = 0; widthIndex < map.width; ++widthIndex) { for (int heightIndex = 0; heightIndex < map.height; ++heightIndex) { GenerateObjectForPixel(grid, map, widthIndex, heightIndex, manager); } } }
private void NewGame() { gameGrid = new GameGrid(Properties.Settings.Default.Width, Properties.Settings.Default.Height); Debug.WriteLine("new game"); CreateCells(); RaisePropertyChangedEvent("Width"); RaisePropertyChangedEvent("Height"); RaisePropertyChangedEvent("Cells"); RaisePropertyChangedEvent("Score"); }
private void SetWaveTile(int Ypos, int Xpos) { //set the tile to a picture of empty waves Image wave = GameGrid.FindByName <Image>("ImageWaves"); wave.SetValue(Grid.RowProperty, Ypos); wave.SetValue(Grid.ColumnProperty, Xpos); wave.IsVisible = true; _movingTurn = true; }
public void InitializeGame() { movesLeft.Clear(); playerTurn = false; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { (GameGrid.FindName("tb" + i.ToString() + j.ToString()) as TextBlock).Text = ""; board[i, j] = spatiu; movesLeft.Add(i.ToString() + j.ToString()); } } if (difficulty != "impossible") { Random a = new Random(); int rate = a.Next(0, 100); if (rate > firstRate) { ai = 'X'; human = 'O'; Random r = new Random(); int ri = r.Next(0, 3); int rj = r.Next(0, 3); board[ri, rj] = ai; (GameGrid.FindName("tb" + ri.ToString() + rj.ToString()) as TextBlock).Text = ai.ToString(); (GameGrid.FindName("tb" + ri.ToString() + rj.ToString()) as TextBlock).Foreground = Brushes.Red; movesLeft.Remove(ri.ToString() + rj.ToString()); } else { ai = 'O'; human = 'X'; } } else { human = 'X'; ai = 'O'; } playerTurn = true; nextI = 0; nextJ = 0; timerIsOn = false; }
public MainWindow() { InitializeComponent(); _gameGrid = new GameGrid(); ContentGrid.Children.Add(_gameGrid); this.SizeChanged += OnSizeChanged; this.KeyDown += MainWindow_KeyDown; }
public override void StartDefault() { base.StartDefault(); if (GameGrid.GetInstance() == null) { return; } SetGridPosition(GameGrid.GetInstance().GetClosestFreeNode(transform.position)); }
public GameInstance(int _gridSizeX, int _gridSizeY, Func <bool> _refreshRenderingMethod, ref List <TweakingMenu.TetriminoTweak> _availableTetrimini) { m_availableTetrimini = new List <Tetrimino.eTetriminoType>(); for (int i = 0; i < _availableTetrimini.Count; i++) { m_availableTetrimini.Add(_availableTetrimini[i].m_type); } m_grid = new GameGrid(_gridSizeX, _gridSizeY, _refreshRenderingMethod); m_grid.OnInstantiateTetrimino(InstantiateNewTetrimino()); }
public void Construct(GameGrid gridModel, Cell.Pool cellPool, Grid gridComponent) { this.gridModel = gridModel; this.cellPool = cellPool; this.gridComponent = gridComponent; gridCornerOffset = gridComponent.cellSize / 2f; cells = new Cell[gridModel.Size.x, gridModel.Size.y]; gridModel.OnMinoAdded += SpawnCell; gridModel.OnMinoDeleted += DespawnCell; }
private void DrawGrid(GameGrid grid) { foreach (var t in grid.EnumerateTiles()) { var tile = grid[t]; SetTile((int)t.X, (int)t.Y, tile.ToString(), tileColors[Math.Min(tileColors.Length - 1, tile.Power)], textColors[Math.Min(textColors.Length - 1, tile.Power)]); } scoreText.Text = string.Format("Score: {0}", grid.Score); }
internal static bool IsCellFree(GameGrid grid, int v, int j) { if (grid.IsCellFree(v, j)) { return(true); } else { return(false); } }
void Start() { sceneManager = SceneManager.instance; grid = GameGrid.instance; gizmothing = DebugGizmo.instance; unitStateHandler = GetComponent <UnitStateHandler>(); Debug.Assert(aStar = GetComponent <AStar>()); Debug.Assert(unit = GetComponent <Unit>()); Debug.Assert(inputHandler = GetComponent <InputHandler>()); target = FindObjectOfType <TargetPosition>().transform; }
public GameGrid CreateNew(ICollection <GridCell> cellCollection, Size size, int filledCells) { var grid = new GameGrid(cellCollection, size); foreach (var ix in Enumerable.Range(0, filledCells)) { AddRandomCell(grid); } return(grid); }
private void DrawGrid() { Int32 rowCount = model.Categories.Max(category => category.QuestionEntries.Count); Int32 columnCount = model.Categories.Count; for (var i = 0; i < rowCount + 1; i++) { GameGrid.RowDefinitions.Add(new RowDefinition()); } for (var i = 0; i < columnCount; i++) { GameGrid.ColumnDefinitions.Add(new ColumnDefinition()); } GameGrid.UpdateLayout(); for (var c = 0; c < columnCount; c++) { var columnHeader = new Label() { Content = model.Categories[c].Heading, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, FontSize = 48 }; Grid.SetColumn(columnHeader, c); Grid.SetRow(columnHeader, 0); GameGrid.Children.Add(columnHeader); for (var r = 0; r < rowCount; r++) { ExtendedQuestionEntry questionEntry = model.Categories[c].QuestionEntries[r]; var rowLabel = new Label() { Content = questionEntry.PointValue, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, FontSize = 48 }; rowLabel.MouseDown += (sender, args) => { // This needs to show the question text, then, upon click, show the answer, before returning to the main screen and hiding this label var questionDisplay = new QuestionDisplayTemp(questionEntry.Question, questionEntry.Answer); questionDisplay.ShowDialog(); rowLabel.Visibility = Visibility.Hidden; // TODO This should update the 'answered' property of the question entry }; Grid.SetColumn(rowLabel, c); Grid.SetRow(rowLabel, r + 1); GameGrid.Children.Add(rowLabel); } } }
/// <summary> /// Fills the grid with the current snake part locations. /// </summary> /// <param name="grid">The grid of the current level.</param> public void spawn(GameGrid grid) { head.fillGrid(grid, color); foreach (BodyType segment in body) { segment.fillGrid(grid, color); } tail.fillGrid(grid, color); }
public static void GetSurroundingNodes(Int2 _nodeGridPos, out Node _nodeTL, out Node _nodeT, out Node _nodeTR, out Node _nodeR, out Node _nodeBR, out Node _nodeB, out Node _nodeBL, out Node _nodeL) { _nodeTL = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.UpLeft); _nodeT = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.Up); _nodeTR = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.UpRight); _nodeR = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.Right); _nodeBR = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.DownRight); _nodeB = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.Down); _nodeBL = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.DownLeft); _nodeL = GameGrid.GetInstance().TryGetNode(_nodeGridPos + Int2.Left); }
async void CellClicked(System.Object sender, System.EventArgs e) { var color = await ColorPickerDialog.Show(OuterGrid, "Cell Color", CellColor, null); if (color != null) { CellColor = color; cellpaint.Color = ToSkiaColor(color); GameGrid.InvalidateSurface(); } }
public Move GetMove(GameGrid grid) { string input = null; do { Console.WriteLine($"{PlayerName}, please enter your move (column, row)"); input = Console.ReadLine(); } while (!IsValidInput(input)); var pos = new GridPosition(input[0], int.Parse(input.Substring(1))); return new Move(pos, PlayerSide); }
public static void allReady() { List<List<GameCell>> contents = new List<List<GameCell>>(); for (int i = 0; i < cells.Count; i++) { contents.Add(new List<GameCell>()); for (int j = 0; j < cells[i].Count; j++) { contents[i].Add(new GameCell(cells[i][j].initRabbits, cells[i][j].initFoxes, cells[i][j].initVegetation)); } } Source = new GameGrid(contents); }
public virtual void Init(GameGrid grid, int x, int y) { this.grid = grid; this.x = x; this.y = y; img = transform.Find("Sprite").GetComponent<SpriteRenderer>(); grid.layers.Set<Entity>(y, x, this); selector = transform.Find("Selector").gameObject; selector.SetActive(false); LocateAtCoords(x, y); }
public void Init() { hud = GetComponent<Hud>(); hud.Init(); grid = GetComponent<GameGrid>(); grid.Init(this); map = GetComponent<GameMap>(); map.Init(this, grid, hud); collectables = new List<Collectable>(); paused = false; }
public MainWindow() { InitializeComponent(); _gameGrid = new GameGrid(); ContentGrid.Children.Add(_gameGrid); this.SizeChanged += OnSizeChanged; this.KeyDown += MainWindow_KeyDown; // Start Manager realSenseManager = new RealSenseManager(GameGestureFired); realSenseManager.Start(); }
public MainWindow() { InitializeComponent(); _gameGrid = new GameGrid(); ContentGrid.Children.Add(_gameGrid); this.SizeChanged += OnSizeChanged; this.KeyDown += MainWindow_KeyDown; //slide var cam = Camera.Create(); cam.Gestures.SlideLeft += (sender, args) => { _gameGrid.HandleMove(MoveDirection.Left); }; cam.Gestures.SlideRight += (sender, args) => { _gameGrid.HandleMove(MoveDirection.Right); }; cam.Start(); }
public void Init(GameGrid grid, TileTypes type, int x, int y) { this.grid = grid; this.type = type; this.x = x; this.y = y; // locate tile float ratio = grid.tileHeight / (float)grid.tileWidth; transform.localPosition = new Vector3(x, y * ratio, 0); // create images dictionary: images will be accessible by state key for (int i = 0; i < tileSprites.Length; i++) { sprites.Add(tileSprites[i].state, tileSprites[i].sprite); } // set tile image img = transform.Find("Sprite").GetComponent<SpriteRenderer>(); img.sortingOrder = grid.height - y; // set tile state SetState(TileStates.NORMAL); }
public GridValue? GetWinner(GameGrid grid) { // Diagonal if (HaveSameValue(grid[0, 0], grid[1, 1], grid[2, 2]) || HaveSameValue(grid[2, 0], grid[1, 1], grid[0, 2])) { return grid[1, 1]; } // Lines for (var x = 0; x < 3; x++) { if (HaveSameValue(grid[x, 0], grid[x, 1], grid[x, 2])) { return grid[x, 0]; } if (HaveSameValue(grid[0, x], grid[1, x], grid[2, x])) { return grid[0, x]; } } return null; }
public TenCellRow(GameGrid grid) : base(grid) { }
// Use this for initialization void Start() { if (Mode == PlayMode.CollectAtoms) { var targetContainers = GameObject.Find("TargetContainers"); if (targetContainers != null) { TargetContainers = targetContainers.GetComponent<GameGrid>(); } TargetFormula = new[] { ComplexMoleculeData.Parse("H2O"), ComplexMoleculeData.Parse("NO2"), ComplexMoleculeData.Parse("NaCl"), }; CreateCar(1, TargetFormula[0].Formula); CreateCar(2, TargetFormula[1].Formula); CreateCar(3, TargetFormula[2].Formula); TargetContainers.SizeX = TargetFormula.Count(); TargetContainers.CreateGrid(); CreateTargetContainer(0, TargetFormula[0].Formula); CreateTargetContainer(1, TargetFormula[1].Formula); CreateTargetContainer(2, TargetFormula[2].Formula); ComponentFormulas = TargetFormula.SelectMany(c => c.Molecules.Select(n=>n.Atom.symbol)).Distinct().ToArray(); UpdateProgressLabels(); } //AtomData.LoadAtoms(); for (int i = 0; i < Grid.SizeX; i++) { for (int j = 0; j < Grid.SizeY; j++) { CreateAtomAt(i * Grid.SizeX + j); } } Current.PutCoins(100); }
public Move GetMove(GameGrid grid) { var state = new TicTacToeState(PlayerSide, grid); return _search.RunMinimax(state, 10).ActionsToState.First(); }
public Exploder(GameGrid grid) : base(grid) { }
public Glider(GameGrid grid) : base(grid) { }
void Start(){ gameGrid = new GameGrid(); //block = new Block("block", 'F', 64, 1, 1); }
public Blinker(GameGrid grid) : base(grid) { }
public Pattern(GameGrid targetGrid) { grid = targetGrid; }
public override void Init(GameGrid grid, int x, int y) { base.Init(grid, x, y); }
public BHepto(GameGrid grid) : base(grid) { }
public Spaceship(GameGrid grid) : base(grid) { }
public SmallExploder(GameGrid grid) : base(grid) { }
public RPento(GameGrid grid) : base(grid) { }
public Rabbits(GameGrid grid) : base(grid) { }
public Acorn(GameGrid grid) : base(grid) { }