protected override void UseInternal() { // check for hostile objects within range int hits = Physics.OverlapSphereNonAlloc(transform.position, _model.EffectRadius, _hits, _shockWaveItemModel.ShockWaveAffectedLayers); if (hits <= 0) { return; } // loop over all hits and if theyre a damageObstacle, destroy them foreach (Collider col in _hits) { if (col == null) { return; } DamageObstacle damageObstacle = col.GetComponent <DamageObstacle>(); if (damageObstacle) { Destroy(damageObstacle.gameObject); } } }
private void OnObstacleHitGround(DamageObstacle obj) { if (obj == null) { return; } _currentScore++; _scoreText.text = _currentScore.ToString(); }
/// <summary> /// Called when any hostile obstacle hits the ground /// </summary> /// <param name="obj"></param> private void OnDamageObstacleHitGround(DamageObstacle obj) { if (obj == null) { return; } // every hostile obstacle awards one coin _coinsCollectedThisRun++; UpdateCoinsDuringRun?.Invoke(_coinsCollectedThisRun); }
public void TestDecoratorToMakeObstacle() { GameObject obstacle = new DamageObstacle(baseObject); obstacle.Decorate(); Assert.IsTrue(obstacle.damage > 0); obstacle = new Tree(obstacle); obstacle.Decorate(); Assert.IsTrue(obstacle.shape == Shape.Ellipse); Assert.IsTrue(obstacle.brush == Brushes.DarkGreen); obstacle = new Wall(obstacle); obstacle.Decorate(); Assert.IsTrue(obstacle.shape == Shape.Rectangle); Assert.IsTrue(obstacle.brush == Brushes.DarkGray); obstacle = new Water(obstacle); obstacle.Decorate(); Assert.IsTrue(obstacle.shape == Shape.Rectangle); Assert.IsTrue(obstacle.brush == Brushes.DarkSlateBlue); obstacle = new Boulder(obstacle); obstacle.Decorate(); Assert.IsTrue(obstacle.shape == Shape.Ellipse); Assert.IsTrue(obstacle.brush == Brushes.Gray); obstacle = new OutlineObstacle(obstacle); obstacle.Decorate(); Color color = (obstacle.brush as SolidBrush).Color; Assert.IsTrue(obstacle.outlinePen.Color.Equals(color.Tint(Color.FromArgb(64, Color.Black)))); }