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";
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ public class Player : MonoBehaviour, IPlayer
|
||||
[SerializeField] private ParticleSystem jumpParticle;
|
||||
[SerializeField] private CinemachineImpulseSource cinemachineImpulseSource;
|
||||
|
||||
[SerializeField] private Material playerMaterial;
|
||||
[SerializeField] Color[] playerMaterialColors;
|
||||
|
||||
public bool isDead { get; private set; }
|
||||
|
||||
[Inject] private IDeathScreenController IdeathScreenController;
|
||||
@@ -22,6 +25,7 @@ public class Player : MonoBehaviour, IPlayer
|
||||
private void Start()
|
||||
{
|
||||
isDead = false;
|
||||
playerMaterial.color = playerMaterialColors[Random.Range(0, playerMaterialColors.Length)];
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
@@ -46,8 +50,8 @@ public class Player : MonoBehaviour, IPlayer
|
||||
float splashYPos = collision.transform.position.y + 0.155f;
|
||||
ContactPoint contact = collision.contacts[0];
|
||||
Vector3 surfacePoint = new Vector3(contact.point.x, splashYPos, contact.point.z);
|
||||
GameObject instancedSplash = Instantiate(splashObject, surfacePoint, splashObject.transform.rotation, splashParent);
|
||||
instancedSplash.transform.localScale = new Vector3(Random.Range(0.08f, 0.1f), Random.Range(0.08f, 0.1f),1);
|
||||
GameObject instancedSplash = Instantiate(splashObject, surfacePoint, splashObject.transform.rotation, collision.gameObject.transform);
|
||||
instancedSplash.transform.localScale = new Vector3(Random.Range(0.05f, 0.09f), Random.Range(0.05f, 0.09f),1);
|
||||
Destroy(instancedSplash, 2f);
|
||||
}
|
||||
private void Die()
|
||||
|
||||
Reference in New Issue
Block a user