-
-
Save LMichelle/aafcab060cc947eca6d510f62d515eef to your computer and use it in GitHub Desktop.
SPOOK Door system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
public class Doors : MonoBehaviour { | |
public bool openDoor = false; | |
private SpriteRenderer rend; | |
public Sprite openedDoorSprite; | |
public GameObject Spook; | |
public GameObject spawnSpot; | |
public GameObject Camera; | |
public int keyVersion; | |
public GameObject keyPanel; | |
public showKeys keysScript; | |
public GameObject gameController; | |
public Scene_Manager scene; | |
// Use this for initialization | |
void Start () { | |
Spook = GameObject.FindGameObjectWithTag("Player"); | |
rend = GetComponent<SpriteRenderer>(); | |
Camera = GameObject.Find("Main Camera"); | |
//openedDoorSprite = Resources.Load<Sprite>("Art/Door"); | |
//spawnSpot = GameObject.FindGameObjectWithTag("spawnSpot"); | |
keyPanel = GameObject.Find("Panel_Keys"); | |
keysScript = keyPanel.GetComponent<showKeys>(); | |
gameController = GameObject.Find("GameController"); | |
scene = gameController.GetComponent<Scene_Manager>(); | |
; } | |
private void Update() | |
{ | |
if (Spook == null) | |
{ | |
Spook = GameObject.FindGameObjectWithTag("Player"); | |
} | |
} | |
private void OnTriggerStay2D(Collider2D collision) | |
{ | |
if (Input.GetKeyDown(KeyCode.Space)) | |
{ | |
if (keysScript.keys[keyVersion].enabled == true) | |
{ | |
if (keysScript.keys[3].enabled == true) | |
{ | |
Scene sceneCheck = SceneManager.GetActiveScene(); | |
if (sceneCheck.name == "Spook1") | |
{ | |
scene.LoadByIndex(2); | |
} | |
} | |
rend.sprite = openedDoorSprite; | |
Spook.transform.position = spawnSpot.transform.position; | |
Camera.transform.position = new Vector3(Spook.transform.position.x, spawnSpot.transform.position.y + 2, -10); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment