Placido_GDD

MVC Rougelike roomInfo

Jan 14th, 2022 (edited)
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class RoomInfo : MonoBehaviour
  6. {
  7.     private RoomTemplates templates;
  8.     public int RoomType;
  9.     public bool roomSpawned;
  10.     private GameObject roomSpawner;
  11.     //1:need bottom door
  12.     //2:need top door
  13.     //3:need left door
  14.     //4:need right door
  15.     private GenerateRooms GenRooms;
  16.     private RoomTemplates RoomTemp;
  17.  
  18.     void Start()
  19.     {
  20.         roomSpawner = this.gameObject;
  21.         RoomTemp = GameObject.FindGameObjectWithTag("Rooms").GetComponent<RoomTemplates>();
  22.         GenRooms = GameObject.FindGameObjectWithTag("R_Gen").GetComponent<GenerateRooms>();
  23.         Invoke("InstantiateRoom", 0.1f);
  24.              
  25.     }
  26.  
  27.    void InstantiateRoom()
  28.     {
  29.         if (roomSpawned == false)
  30.         {
  31.             GenRooms.SpawnRoom(this.gameObject.transform.position,RoomType);
  32.         }
  33.        roomSpawned = true;
  34.     }
  35.  
  36.     private void OnTriggerEnter(Collider other)
  37.     {
  38.         if (other.CompareTag("SpawnPoint"))
  39.         {
  40.             if (other.GetComponent<RoomInfo>().roomSpawned == false && roomSpawned == false)
  41.             {
  42.                 GenRooms.SpawnRoom(this.gameObject.transform.position,0);
  43.                 Destroy(gameObject);
  44.             }
  45.             roomSpawned = true;
  46.         }
  47.     }
  48.  
  49.  
  50. }
  51.  
Add Comment
Please, Sign In to add comment