//if im being honest the naming convention is trash RoomSpawner SpawnRSpawner(GameObject loc) // spawns RoomSpawner { RoomSpawner SpawnerScript = null; //instantiate blank RoomSpawner if (Physics2D.OverlapPoint(loc.transform.position, cFilter, detRooms) == 0) //check if not occupied { GameObject RSpawner = Instantiate(Spawner, loc.transform.position, loc.transform.rotation); SpawnerScript = RSpawner.GetComponent <RoomSpawner>(); Debug.Log(loc.name + " Spawned"); } else { for (int i = 0; i < detRooms.Length; i++) { if (detRooms[i].tag != "Room") { GameObject RSpawner = Instantiate(Spawner, loc.transform.position, loc.transform.rotation); SpawnerScript = RSpawner.GetComponent <RoomSpawner>(); Debug.Log(loc.name + " Spawned"); } else { Debug.Log("There is a room at " + loc.name); } } } return(SpawnerScript); }
private void Start() { int r = Random.Range(0, 10); if (vending_Machine[r] != null) { Instantiate(vending_Machine[r], vending_Machine_Spawn_Point.position, vending_Machine_Spawn_Point.rotation); print("VM spawn"); } else { print("Nothing Spawn"); } the_RS = FindObjectOfType <RoomSpawner>(); the_NMS = FindObjectOfType <NavMeshSurface>(); //the_NMS.BuildNavMesh(); foreach (GameObject GO in GameObject.FindGameObjectsWithTag("Enemy")) { if (GO.tag == "Enemy") { enemy_Left.Add(GO); } } }
void OnTriggerEnter2D(Collider2D other) { if ((other.CompareTag("SpawnPoint") && other.GetComponent <RoomSpawner>().spawned == true) || other.CompareTag("EntrySpawn")) { if (templates == null) { templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent <RoomTemplates>(); } if (templates.roomSpawns.Contains(this)) { templates.roomSpawns.Remove(this); } if (templates.finalSpawns.Contains(this)) { templates.finalSpawns.Remove(this); } if (other.CompareTag("SpawnPoint")) { RoomSpawner otherspawner = other.GetComponent <RoomSpawner>(); for (int i = 0; i < doors.Length; i++) { if (doors[i] && !otherspawner.doors[i]) { otherspawner.doors[i] = true; Instantiate(getEndRoom(i), otherspawner.transform.position, Quaternion.identity); } } } //Debug.Log("Enter " + transform.position.x + ", " + transform.position.y + ": " + doors[0] + "," + doors[1] + "," + doors[2] + "," + doors[3]); Destroy(gameObject); } }
private bool IsWallMatch(int x, int y, OpeningSide openingSide, OpeningSide openingSideMask) { bool looking4Wall = openingSide == OpeningSide.NONE; if (x < 0 || y < 0 || x >= roomMapSize || y >= roomMapSize) { // There's no rooms outside the boundary, so the room that called this is // up against a boundary, so we only match a "wall" room return(looking4Wall); } else { if (roomMap[x, y] == null) { // No room next to this wall so we can match anything return(true); } // Need to figure out what wall this room has so we can match it RoomSpawner rS = roomMap[x, y].GetComponent <RoomSpawner>(); var temp = rS.typeOfRoom & openingSideMask; if (looking4Wall) { // Looking for a wall return(temp == OpeningSide.NONE); } else { // Looking for a door return(temp != OpeningSide.NONE); } } }
void SpawnRooms() { // Make sure we only spawn one room in a spot if (spawned == false) { // Identifying the first room with this script (the entry room, already placed) if (xMap == -1 || yMap == -1) { // Spawn bound only exists on the first room since its a member var, we need to copy it into a static roomMap = new GameObject[spawnBounds, spawnBounds]; roomMapSize = spawnBounds; // This room goes in the middle of the map xMap = spawnBounds / 2; yMap = spawnBounds / 2; entryRoom = this; // adding this to the array PlaceRoom(xMap, yMap, this.gameObject); // This logic only gets called once, and we only want this exit room method called once. Invoke("SetExitRoom", 1.5f); } SpawnARoomIfNeeded(-1, 0, OpeningSide.LEFT, OpeningSide.RIGHT, template.RightRooms); SpawnARoomIfNeeded(+1, 0, OpeningSide.RIGHT, OpeningSide.LEFT, template.LeftRooms); SpawnARoomIfNeeded(0, +1, OpeningSide.TOP, OpeningSide.BOTTOM, template.BottomRooms); SpawnARoomIfNeeded(0, -1, OpeningSide.BOTTOM, OpeningSide.TOP, template.TopRooms); spawned = true; } template.roomList.Add(this.gameObject); }
public void CloseRoom(RoomSpawner spawner) { GameObject wall; Vector2 wallPosition; if (spawner.openingDirection == 1 || spawner.openingDirection == 3) { wall = RoomTemplates.instance.closedHorizontalWall; wallPosition = new Vector2( spawner.transform.position.x, spawner.openingDirection == 1 ? spawner.transform.position.y : spawner.transform.position.y + 22 ); } else { wall = RoomTemplates.instance.closedVerticalWall; wallPosition = new Vector2( spawner.openingDirection == 4 ? spawner.transform.position.x : spawner.transform.position.x - 21, spawner.transform.position.y ); } Instantiate(wall, wallPosition, spawner.transform.rotation, spawner.transform.parent.transform); Destroy(spawner.gameObject); }
//private GameObject spawnPoint; //private float waitTime = 0.1f; void Start() { //templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent<RoomTemplates>(); //Destroy(gameObject, waitTime); myTag = gameObject.tag; roomspawn = GameObject.FindObjectOfType <RoomSpawner>(); }
void Start() { //spawns boss and then move his location based on what type //of room he is in so that he is not right in the middle of the room; boss = GameObject.FindGameObjectWithTag("Boss"); boss.SetActive(false); spawnSide = GetComponentInChildren <RoomSpawner>(); bossTransform = boss.GetComponent <Transform>(); if (spawnSide.openingDirection == 1) { bossTransform.position += new Vector3(0.0f, -3.0f, 0.0f); } if (spawnSide.openingDirection == 2) { bossTransform.position += new Vector3(0.0f, 3.0f, 0.0f); } if (spawnSide.openingDirection == 3) { bossTransform.position += new Vector3(-3.0f, 0.0f, 0.0f); } if (spawnSide.openingDirection == 4) { bossTransform.position += new Vector3(3.0f, 0.0f, 0.0f); } }
void SetExit() { if (RoomSpawner.GetRoomAt(transform.position) != RoomSpawner.exitRoom) { this.gameObject.SetActive(false); } }
public void Start() { ceilSpawn = new List <Vector3>(); waterSpawn = new List <RandomeBackground>(); mySpawner = GetComponent <RoomSpawner>(); GenerateMap(); }
private void Awake() { if (instance != null) { Debug.LogWarning("More than one instance of RoomSpawner present"); } instance = this; }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("SpawnPoint")) { RoomSpawner roomSpawner = other.GetComponent <RoomSpawner>(); roomSpawner.CloseRoom(roomSpawner); roomSpawner.spawned = true; } }
void Update() { if (!paused && !win) { gameTime += Time.deltaTime; } activeRoom.myTimer.GetComponent <TextMeshProUGUI>().text = SecondsToTime(gameTime); if (activeRoom.isHall) { activeRoom.nextRoom.myTimer.GetComponent <TextMeshProUGUI>().text = SecondsToTime(gameTime); } if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.P)) { paused = !paused; pauseMenu.SetActive(paused); if (paused) { Time.timeScale = 0; Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; Time.timeScale = 1; } } if (inBattle) { if (activeEnemies.Count == 0) { //check for win if (guns.Count == 0 && activeRoom.isHall) { //win things //Networking.inst.SendScore(PlayerPrefs.GetString("username"), gameTime); win = true; } else { inBattle = false; activeRoom.myDoor.OpenDoor(); if (activeRoom.isHall) { newWeapon = true; } activeRoom = activeRoom.nextRoom; } } } finalTime.text = SecondsToTime(gameTime); }
public static void InitializeLevelManager(UIController uiParent, RoomSpawner roomSpawner, Transform player) { LevelManager.uiParent = uiParent; LevelManager.roomSpawner = roomSpawner; LevelManager.player = player; playerPC = player.GetComponent <PlayerController>(); roomSpawner.InitializeRoomSpawner(); }
void Start() { RoomSpawner = FindObjectOfType <RoomSpawner>(); collider = GetComponent <BoxCollider2D>(); polyCollider = GetComponent <PolygonCollider2D>(); neighbours = new List <EnnemiesSpawner>(); contacts = new List <ContactPoint2D>(); inBetweenPoints = new List <Vector2>(); body = GetComponent <Rigidbody2D>(); }
public void Update() { Object[] t = GameObject.FindObjectsOfTypeAll(typeof(RoomSpawner)); foreach (Object obj in t) { RoomSpawner G = obj as RoomSpawner; if (G.transform.tag != "SpawnPoint") { Debug.LogError("I am not tagged correctly", G.transform); } } }
// Use this for initialization void Start() { locker = GetComponentInParent<LockGates>(); locked = true; anim = GetComponent<Animation>(); player = GameObject.Find ("Warrior"); roomspawner = GameObject.Find("Room Spawner").GetComponent<RoomSpawner>(); enemies = GameObject.Find ("Spawner").GetComponent<SpawnEnemies>(); exp = GameObject.Find ("Warrior").GetComponent<Experience>(); ga = GameObject.Find ("Spawner").GetComponent<GeneticAlgorithm>(); enemyspawner = GameObject.Find ("Spawner").GetComponent<SpawnEnemies>(); }
public void SetSpawner(RoomSpawner mySpawner, Vector2 coordinate, bool hasUp, bool hasDown, bool hasRight, bool hasLeft) { _spawnerReference = mySpawner; _roomCoordinate = coordinate; Initialize(); leftPortal.gameObject.SetActive(hasLeft); rightPortal.gameObject.SetActive(hasRight); upPortal.gameObject.SetActive(hasUp); downPortal.gameObject.SetActive(hasDown); }
void PlaceRoom(int xMap, int yMap, GameObject room) { //Debug.Log($"Place Room: {xMap}, {yMap}"); // stored the room passed in within our array roomMap[xMap, yMap] = room; RoomSpawner spawner = room.GetComponent <RoomSpawner>(); // telling the room where its at (re-setting -1) spawner.xMap = xMap; spawner.yMap = yMap; }
private bool canPlace(int x, int y, GameObject room) { RoomSpawner rS = room.GetComponent <RoomSpawner>(); bool isOk = IsWallMatch(x - 1, y, rS.typeOfRoom & OpeningSide.LEFT, OpeningSide.RIGHT) && IsWallMatch(x + 1, y, rS.typeOfRoom & OpeningSide.RIGHT, OpeningSide.LEFT) && IsWallMatch(x, y + 1, rS.typeOfRoom & OpeningSide.TOP, OpeningSide.BOTTOM) && IsWallMatch(x, y - 1, rS.typeOfRoom & OpeningSide.BOTTOM, OpeningSide.TOP); return(isOk); }
private void Awake() { current = this; Cursor.visible = false; playerTransform = GameObject.FindGameObjectWithTag("Player").transform; fadeToBlackTween = faderImage.DOColor(Color.black, 1.0f); fadeToBlackTween.Pause(); fadeToClearTween = faderImage.DOColor(Color.clear, 1.0f); fadeToClearTween.Pause(); faderImage.color = Color.black; StartCoroutine(SpawnRoomFix()); }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("SpawnPoint")) { RoomSpawner sp = other.GetComponent <RoomSpawner>(); if (sp && sp.isSpawned == false && isSpawned == false) { //Instantiate(.closedRoom, transform.position, Quaternion.identity); Destroy(gameObject); isSpawned = true; } } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag(gameObject.tag)) { RoomSpawner otherRoomSpawner = other.GetComponent <RoomSpawner>(); if (!otherRoomSpawner.spawned && !spawned) { CloseRoom(this); if (otherRoomSpawner.isActiveAndEnabled) { CloseRoom(otherRoomSpawner); } } } spawned = true; }
void OnTriggerEnter(Collider collider) { if (collider.tag == "Spawnpoint" && !hasimp) { RoomSpawner conSpawner = collider.GetComponent <RoomSpawner>(); if (parRoom != null) { parRoom.otherRooms.Add(conSpawner.transform.parent.gameObject); } if (conSpawner != null) { if (collider.GetComponent <RoomSpawner>().spawned == false && spawned == false) { Instantiate(templates.wall, transform.position, Quaternion.identity); parRoom.SpawnWall(openingDirection); Destroy(gameObject); } } spawned = true; } }
public void SpawnRoom() { RoomSpawner spawner = roomSpawners[roomSpawner_Index]; if (roomPositions.Exists(room => room.xPosition == spawner.transform.position.x && room.yPosition == spawner.transform.position.y) || (spawner.transform.position.x == 0 && spawner.transform.position.y == 0)) { Debug.Log("Position of the spawner is: " + spawner.transform.position.x + "," + spawner.transform.position.y); Debug.Log("This Spawner was trying to spawn where there was already a room!"); } else { Debug.Log("There are not enough rooms!"); spawner.Spawn(); roomPositions.Add(new Room((int)spawner.transform.position.x, (int)spawner.transform.position.y)); } roomSpawner_Index++; spawner.Destroy(); Debug.Log("The spawner index to get is: " + roomSpawner_Index); if (roomSpawner_Index == roomSpawners.Count) { roomSpawners.Clear(); } }
private void Start() { rs = GameObject.FindGameObjectWithTag("Rooms").GetComponent <RoomSpawner>(); }
void StateMachine() { if (state != lastState) { Debug.Log(state); lastState = state; } switch (state) { case States.Idle: if (Vector2.Distance(rb.position, target.position) < followDistance && Vector2.Distance(rb.position, target.position) > attackRadius) { state = States.Following; Debug.Log("following"); } break; case States.Following: //UpdatePath(); if (RoomSpawner.GetRoomAt(target.position) != RoomSpawner.GetRoomAt(this.transform.position)) { state = States.Home; //path.vectorPath.Clear(); // temp, will have "return" movement rb.velocity = new Vector2(); Debug.Log("not following"); } if (Vector2.Distance(rb.position, target.position) < attackRadius) { state = States.StartAttacking; } break; case States.StartAttacking: var attackDir = GetDirection(target.position - transform.position); rb.velocity = new Vector2(); switch (attackDir) { case Direction.North: North.gameObject.SetActive(true); break; case Direction.South: South.gameObject.SetActive(true); break; case Direction.East: East.gameObject.SetActive(true); break; case Direction.West: West.gameObject.SetActive(true); break; } attackCounter = attackTime; state = States.Attacking; break; case States.Attacking: attackCounter -= Time.deltaTime; if (attackCounter <= 0) { DisableHitbox(); } // do animation break; case States.Home: HomePath(); break; } }
public void Start() { mySpawner = GetComponent <RoomSpawner>(); GenerateMap(); }