private void Spawn() { for (int i = 1; i <= lanesToSpawn; ++i) { int randomNumber = Random.Range(1, 6); if (i != randomNumber) { continue; } Vector2 spawnPosition = new Vector2(11, i); BoardPiece newAttacker = Instantiate( attackers[Random.Range(0, attackerTier)], spawnPosition, Quaternion.identity ); Health newAttackerHealth = newAttacker.GetComponent <Health>(); if (newAttackerHealth) { newAttackerHealth.AddHealth( difficultyLevel * difficultyMultiplier * difficultyMultiplier ); } newAttacker.transform.SetParent(transform); levelController.AttackerSpawned(); } }
private void Defeated() { isDefeated = true; Vector2 currentScale = transform.localScale; currentScale.x *= -1; transform.localScale = currentScale; BoardPiece boardPiece = GetComponent <BoardPiece>(); if (boardPiece) { boardPiece.SetCanAttack(false); Collider2D coll = boardPiece.GetComponent <Collider2D>(); boardPiece.SetMovingDirectionToRunning(); animator.SetBool("Defeated", true); if (coll) { coll.enabled = false; } } Destroy(gameObject, destroyDelay); }
public override void RaiseEventSwitchSuccess(Match3Tile neighborTile) { base.RaiseEventSwitchSuccess(neighborTile); //If this boardpiece is a dropperBehaviour if (BoardPiece.GetComponent <DropperBehaviour>() != null && !isDropping) { StartCoroutine(Drop()); } }
/// <summary>Fills a given piece at a given position.</summary> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> /// <param name="pieceToFill">The piece to fill.</param> /// <param name="automaticallySetLocation">If the transform should automaticaly be set.</param> private void FillPieceAt(int x, int y, BoardPiece pieceToFill, bool automaticallySetLocation = false) { Assert.IsTrue(PointIsOnBoard(x, y), string.Format("Expected point ({0}, {1}) to be within ({2}, {3}).", x, y, COLUMNS, ROWS)); Assert.IsTrue(IsValidCell(x, y), string.Format("Expected point ({0}, {1}) to be valid.", x, y)); BoardPiece piece = Instantiate(pieceToFill, this.transform, false) as BoardPiece; piece.SetXY(x, y, automaticallySetLocation); pieces[x, y] = piece; if (!visible) { piece.GetComponent <SpriteRenderer>().enabled = false; } }