//room types //0: entry room //1: exit room //2: key room //3: enemy room //4: med room public void fillRoom(SubDungeon room, int type) { if (type == 3) { Vector2 loc = room.randRoomPoint(room); GameObject instance = Instantiate(enemy, loc, Quaternion.identity) as GameObject; //TransporterScript tsScript = instance.GetComponent<TransporterScript>(); //tsScript.accessible == instance.transform.SetParent(transform); //boardPositionsFloor[i, j] = instance; } else if (type == 1) { Vector2 loc = room.randRoomPoint(room); GameObject instance = Instantiate(teleporter, loc, Quaternion.identity) as GameObject; TransporterScript tsScript = instance.GetComponent <TransporterScript>(); tsScript.accessible = true; tsScript.newScene = true; instance.transform.SetParent(transform); //boardPositionsFloor[i, j] = instance; } else if (type == 4) { Vector2 loc = room.randRoomPoint(room); Vector2 loc2 = room.randRoomPoint(room); GameObject instance = Instantiate(hpack, loc, Quaternion.identity) as GameObject; GameObject instance2 = Instantiate(hpack, loc, Quaternion.identity) as GameObject; //TransporterScript tsScript = instance.GetComponent<TransporterScript>(); //sScript.newScene = true; instance.transform.SetParent(transform); } }
void playerWorldInteraction() { Vector2 pos = new Vector2(this.transform.position.x, this.transform.position.y); if (Input.GetKeyDown(KeyCode.G)) { if (checkForItems(pos)) { GameObject found = findInScene(GameObject.FindGameObjectsWithTag("Item"), pos); //GameObject copy = GameObject.Instantiate(found); if (found.name == "hpack") { Body body = GetComponentInChildren <Body>(); body.heal(50); Destroy(found); } bool destroy = inventory.addToInventory(found); if (destroy) { // not currently destroying the object because unity //GameObject.Destroy(found); } //GameObject.Destroy(copy); } } if (Input.GetKeyDown(KeyCode.L)) { //drop item } if (Input.GetKeyDown(KeyCode.P)) { //teleport to location pointed to by whatever transporter the player is on //used by stairs and teleporters if (checkForTransporter(pos)) { GameObject[] objs; objs = GameObject.FindGameObjectsWithTag("Transporter"); GameObject trans = findInScene(objs, pos); TransporterScript transporter = trans.GetComponent <TransporterScript>(); if (transporter.newScene) { transporter.loadNewScene(); } else if (transporter.accessible) { teleport(transporter.destination); } } } }