added platfrom break effect
This commit is contained in:
@@ -8,6 +8,10 @@ public class Platform : MonoBehaviour, IPlatform
|
||||
[SerializeField] private List<GameObject> _platformPiece = new List<GameObject>();
|
||||
[SerializeField] private Material _safeMaterial;
|
||||
[SerializeField] private Material _deathMaterial;
|
||||
[SerializeField] private ParticleSystem _particleSystem;
|
||||
|
||||
[SerializeField]private Color[] safeMaterialColors;
|
||||
[SerializeField] private Color[] deathMaterialColors;
|
||||
|
||||
public List<GameObject> platformPiece => _platformPiece;
|
||||
public Material safeMaterial => _safeMaterial;
|
||||
@@ -21,6 +25,18 @@ public class Platform : MonoBehaviour, IPlatform
|
||||
[Inject] IPlatformManager platformManager;
|
||||
[Inject] IScoreService IscoreService;
|
||||
[Inject] IAudioController IaudioController;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if(_particleSystem == null) _particleSystem = GetComponent<ParticleSystem>();
|
||||
_safeMaterial.color = ReturnMaterialColor(safeMaterialColors);
|
||||
_deathMaterial.color = ReturnMaterialColor(deathMaterialColors);
|
||||
}
|
||||
|
||||
Color ReturnMaterialColor(Color[] color)
|
||||
{
|
||||
return color[Random.Range(0,color.Length)];
|
||||
}
|
||||
public void SetPlatformRule(IPlatformRule platformRule)
|
||||
{
|
||||
_platformRule = platformRule;
|
||||
@@ -35,9 +51,18 @@ public class Platform : MonoBehaviour, IPlatform
|
||||
Debug.Log("Score Increased");
|
||||
IscoreService.AddScore();
|
||||
IaudioController.PlayScoredSound();
|
||||
_particleSystem.Play();
|
||||
HideThisPlatfromPiece();
|
||||
|
||||
}
|
||||
}
|
||||
void HideThisPlatfromPiece()
|
||||
{
|
||||
foreach(var piece in _platformPiece)
|
||||
{
|
||||
piece.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -72,6 +97,7 @@ public class FirstPlatform : IPlatformRule
|
||||
{
|
||||
piece.SetActive(true);
|
||||
piece.GetComponent<Renderer>().material = platform.safeMaterial;
|
||||
piece.gameObject.SetActive(true);
|
||||
piece.tag = "Safe";
|
||||
}
|
||||
platform.platformPiece[Random.Range(1,platform.platformPiece.Count)].gameObject.SetActive(false);
|
||||
@@ -87,6 +113,7 @@ public class OtherPlatform : IPlatformRule
|
||||
{
|
||||
piece.SetActive(true);
|
||||
piece.GetComponent<Renderer>().material = platform.safeMaterial;
|
||||
piece.gameObject.SetActive(true);
|
||||
piece.tag = "Safe";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user