cant write proper code compatible with unity 2017 for "SimulateWin"
Her is my script,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Brick : MonoBehaviour {
public Sprite[] hitSprites;
public static int breakableCount = 0;
private int maxHits;
private int timesHit;
private bool isBeakable;
// Use this for initialization
void Start () {
isBeakable = (this.tag == "Breakable");
if (isBeakable)
{
breakableCount++;
print(breakableCount);
}
timesHit = 0;
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D col)
{
if (isBeakable)
{
HandleHits();
}
}
void HandleHits ()
{
maxHits = hitSprites.Length + 1;
timesHit++;
if (timesHit >= maxHits)
{
breakableCount--;
print(breakableCount);
Destroy(this.gameObject);
}
else
{
LoadSprites();
}
}
void LoadSprites ()
{
int spriteIndex = timesHit - 1;
if (hitSprites[spriteIndex])
{
this.GetComponent<SpriteRenderer>().sprite = hitSprites[spriteIndex];
}
}
}
I don’t want directly to load next level, I want it to show you won or win screen.
please help.