public void EmptyCookingPlace(bool penalty) { particlesBurst.Play(); particles.Stop(); int p = 0; foreach(Recipes.eIngredients ingr in inPot) { if (ingr != Recipes.eIngredients.empty) { p += Ingredient.INGREDIENT_PENALTY; } } if (penalty) { GameObject.Find("Game").GetComponent<PlaySounds>().playPuff(); Game.GAME.AddScore(-p); PointLabel.SpawnAt(pointLabelPrefab, transform.parent, transform.position, -p); } else { GameObject.Find("Game").GetComponent<PlaySounds>().playComplete(); } effect.transform.localScale = Vector3.zero; inPot = new Recipes.eIngredients[MAX_INGREDIENTS]; for (int i = 0; i < MAX_INGREDIENTS; i++) { inPot[i] = Recipes.eIngredients.empty; } GetComponent<AudioSource>().Stop(); }
private void PostDropColumns() //happens after drop animation { //dispose every pointlabel and remake the list foreach (Label PointLabel in PointLabelList) { PointLabel.Dispose(); } PointLabelList = new List <Label>(); Random r = new Random(); List <Point> MovedTilesToCheck = new List <Point>(); //tiles to check for new matches foreach (int Col in ColumnsToDrop) { int EmptySpacesInColumn = 0; //reset the location of each tile in the columns and count number of empty spaces for (int Row = 0; Row < 9; Row++) { mBoard.Tiles[Row, Col].Location = new Point(BoardOffset + Col * TileSize, BoardOffset + Row * TileSize); if (IntArray[Row, Col] == 0) { EmptySpacesInColumn++; } } //iterating from bottom to top for (int Row = 8; Row >= 0; Row--) { if (Row >= EmptySpacesInColumn) //for each row in the column, except for the ones that will be empty spaces at the top { if (IntArray[Row, Col] == 0) //if it is blank: find the closest valid value above it, copy that value down, and turn the original value to 0 to represent how the tile moved down { for (int UpperRow = Row - 1; UpperRow >= 0; UpperRow--) { if (IntArray[UpperRow, Col] != 0) { IntArray[Row, Col] = IntArray[UpperRow, Col]; IntArray[UpperRow, Col] = 0; //update its image and check it for a match later mBoard.SetNewImage(Row, Col); MovedTilesToCheck.Add(new Point(Col, Row)); break; } } } } else { //for each empty space in the column, which would have bubbled to the top, assign it a new random value and check it for a match later IntArray[Row, Col] = r.Next(1, 7); MovedTilesToCheck.Add(new Point(Col, Row)); mBoard.SetNewImage(Row, Col); } } } CheckNewTiles(MovedTilesToCheck); }
public static void SpawnAt(GameObject prefab, Transform transform, Vector3 position, int points) { GameObject obj = Instantiate(prefab); PointLabel label = obj.GetComponent <PointLabel>(); label.points = points; label.transform.parent = transform; label.transform.position = position; }
private void PostDropColumns() //после анимации падения { foreach (Label PointLabel in PointLabelList) { PointLabel.Dispose(); } PointLabelList = new List <Label>(); Random r = new Random(); List <Point> MovedTilesToCheck = new List <Point>(); foreach (int Col in ColumnsToDrop) { int EmptySpacesInColumn = 0; for (int Row = 0; Row < 8; Row++) { mBoard.Tiles[Row, Col].Location = new Point(BoardOffset + Col * TileSize, BoardOffset + Row * TileSize); if (IntArray[Row, Col] == 0) { EmptySpacesInColumn++; } } for (int Row = 7; Row >= 0; Row--) { if (Row >= EmptySpacesInColumn) { if (IntArray[Row, Col] == 0) { for (int UpperRow = Row - 1; UpperRow >= 0; UpperRow--) { if (IntArray[UpperRow, Col] != 0) { IntArray[Row, Col] = IntArray[UpperRow, Col]; IntArray[UpperRow, Col] = 0; mBoard.SetNewImage(Row, Col); MovedTilesToCheck.Add(new Point(Col, Row)); break; } } } } else { IntArray[Row, Col] = r.Next(1, 6); MovedTilesToCheck.Add(new Point(Col, Row)); mBoard.SetNewImage(Row, Col); } } } CheckNewTiles(MovedTilesToCheck); }
private bool CheckRecipes() { for (int recipeIdx = 0; recipeIdx < Game.GAME.GetFoodOrders().Length; recipeIdx++) { Recipes.Recipe recipe = Game.GAME.GetFoodOrders()[recipeIdx]; if (FitsRecipe(recipe)) { PointLabel.SpawnAt(pointLabelPrefab, transform.parent, transform.position, recipe.points); Game.GAME.AddScore(recipe.points); Game.GAME.NextRecipe(recipeIdx); EmptyCookingPlace(false); return true; } } return false; }
public void Pop() { PointLabel.RemoveFromParent(); Emitter.RemoveFromParent(); }
public void Update() { if (PauseMenu.PAUSED) { return; } if (tile == null) { if (died) { IngredientKillEffects.PlayDeathEffect((int)ingredientType - 1, transform.position, transform.parent); Game.GAME.AddScore(-INGREDIENT_PENALTY); PointLabel.SpawnAt(pointLabelPrefab, transform.parent, transform.position, -INGREDIENT_PENALTY); Debug.Log("-" + INGREDIENT_PENALTY + " points: Fell out of board or was crushed!"); } Destroy(gameObject); return; } if (IsBlocked()) { return; } IBoardMovePattern movePattern = tile.GetMovePattern(); if (wait) { int nextX = boardX + (int)movePattern.NextTile(this).x; int nextY = boardY + (int)movePattern.NextTile(this).y; GameBoardTile nextTile = Game.BOARD.GetTile(nextX, nextY); if (tile is BaseTile && nextTile is BaseTile) { if (IsConveyerBeltAdjacent((BaseTile)tile, (BaseTile)nextTile)) { boardX = nextX; boardY = nextY; tile = nextTile; transform.position = tile.GetMovePattern().GetStart(this); wait = false; } } return; } transform.position += tile.GetMovePattern().Step(this, transform.position); transform.Rotate(tile.GetMovePattern().RotStep(this)); if (movePattern.ReachedDestination(this, transform.position)) { int nextX = boardX + (int)movePattern.NextTile(this).x; int nextY = boardY + (int)movePattern.NextTile(this).y; // This needs to go somewhere else! Yanderedev-Style Code. I know dammit. I dont have much time okay!!! if (nextX == 0 && nextY == -1) { died = false; CookingPlace pot = GameObject.Find("CookingPot1").GetComponent <CookingPlace>(); pot.AddIngredient(ingredientType); } else if (nextX == 2 && nextY == -1) { died = false; CookingPlace pot = GameObject.Find("CookingPot2").GetComponent <CookingPlace>(); pot.AddIngredient(ingredientType); } else if (nextX == -1 && nextY == 2) { died = false; CookingPlace pot = GameObject.Find("CookingPot3").GetComponent <CookingPlace>(); pot.AddIngredient(ingredientType); } else if (nextX == 5 && nextY == 2) { died = false; CookingPlace pot = GameObject.Find("CookingPot4").GetComponent <CookingPlace>(); pot.AddIngredient(ingredientType); } GameBoardTile nextTile = Game.BOARD.GetTile(nextX, nextY); if (nextTile == null) { tile = null; } else { wait = true; } } }