private void OnDestructibleWallDestroy(DestructibleWall destructibleWall) { destructibleWall.OnDestroy.RemoveListener(OnDestructibleWallDestroy); SetEntityType(EEntityType.None, destructibleWall.transform.position); _destructibleWalls.Remove(destructibleWall); // Spanw a bonus? if (Random.value < _gameSettings.BonusProbability) { AddBonus(destructibleWall.transform.position); } }
public void AddDestructibleWall(Vector3 worldPosition) { DestructibleWall destructibleWall = Instantiate( _destructibleWallPrefab, worldPosition, Quaternion.identity, transform ); destructibleWall.OnDestroy.AddListener(OnDestructibleWallDestroy); _destructibleWalls.Add(destructibleWall); SetEntityType(EEntityType.DestructibleWall, destructibleWall.transform.position); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "DestructibleWall") { DestructibleWall wall = collision.gameObject.GetComponent <DestructibleWall>(); if (wall != null && wall.AttemptToDestroy(collision.relativeVelocity.y)) { SoundManager.main.PlaySound(SoundType.DestroyBlock); Debug.Log("Paow!"); } else { Debug.Log(string.Format("Not enough ({0})", collision.relativeVelocity.y)); } } }
public void OnDestroyedWall(DestructibleWall wall) { OnWallDestroy?.Invoke(this); }