Spawner.cs 654 B

123456789101112131415161718
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Spawner : MonoBehaviour {
  5. public GameObject prefeb;
  6. public EnemyType type;
  7. public enum EnemyType { Arrow, Mover, Heavy }
  8. public GameObject parent;
  9. public void Spawn() {
  10. GameObject obj = Instantiate(prefeb, transform);
  11. obj.transform.parent = parent.transform;
  12. obj.GetComponent<EnemyBase>().movingLeft = transform.localScale.x < 0;
  13. if (type == EnemyType.Arrow) {
  14. obj.transform.position += Mathf.RoundToInt((float) Modules.randomDefault.NextDouble() - 0.15f) * Vector3.down * 0.8f;
  15. }
  16. }
  17. }