void Start() { states = GetComponent <PlayerStates>(); bc = GetComponent <BoxCollider2D>(); colliderManager = GetComponent <ColliderManager>(); spaceChecker = GetComponent <SpaceChecker>(); movement = GetComponent <Movement>(); smallerDimension = Mathf.Min(bc.size.x, bc.size.y); biggerDimension = Mathf.Max(bc.size.x, bc.size.y); }
private void TryPlaceBomb() { if (bombsCount > 0) { var roundedPosition = Vector3Int.RoundToInt(transform.position); var blockingItems = SpaceChecker.GetCollidingGameItems(roundedPosition, this.gameObject); if (blockingItems.Count() < 2) { var bomb = Instantiate(bombPrefab, roundedPosition, Quaternion.identity).GetComponent <Bomb>(); bomb.SetUp(3, Radius, Damage); bombsCount -= 1; } } }
private void AffectNeighbour(Vector3 offset, float damage, float rangeLeft) { var explosionPosition = transform.position + offset; var gameItems = SpaceChecker.GetCollidingGameItems(explosionPosition, gameObject); foreach (var gameItem in gameItems) { gameItem.OnHit(); } if (rangeLeft-- == 0 || gameItems.Any(gi => gi.BlocksExplosion)) { return; } ShowParticles(offset); AffectNeighbour(offset + offset.normalized, damage, rangeLeft); }