Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EnemySpawner : MonoBehaviour
- {
- public List<GameObject> enimiesToSpawn;
- public float spawntime;
- public float enemyCount;
- public Transform spawnPoint;
- public Sprite spawnSprite, dmg1Sprite, dmg2Sprite, dmg3Sprite;
- ButtonMash buttonMash;
- public SpriteRenderer thesr;
- // Start is called before the first frame update
- void Start()
- {
- thesr= GetComponent<SpriteRenderer>();
- StartCoroutine(SpawnEnemy(spawntime, enimiesToSpawn[0]));
- }
- // Update is called once per frame
- void Update()
- {
- }
- private IEnumerator SpawnEnemy(float spawnTime, GameObject enemy)
- {
- yield return new WaitForSeconds(spawnTime);
- GameObject newEnemy = Instantiate(enemy, spawnPoint.transform);
- enemyCount++;
- StartCoroutine(SpawnEnemy(spawnTime, enemy));
- }
- private void OnTriggerStay2D(Collider2D other)
- {
- if (other.tag == "Player")
- {
- buttonMash.canMash = true;
- if (buttonMash.mash == 10)
- {
- thesr.sprite = dmg1Sprite;
- }
- if (buttonMash.mash == 20)
- {
- thesr.sprite = dmg2Sprite;
- }
- if (buttonMash.mash == 30)
- {
- thesr.sprite = dmg3Sprite;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement