Commit 6321c0fd authored by Ashley's avatar Ashley

Added DoorScript and KeyScript, started DoorSceneScript

parent 163e296f
using UnityEngine;
using System.Collections;
public class DoorSceneScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
fileFormatVersion: 2
guid: f6bea97f02675a04ab7e41327c0eb915
timeCreated: 1478828866
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class DoorScript : MonoBehaviour {
public enum State
{
closed,
open,
locked
}
public KeyColor doorColor;
public State state;
private Collider2D collider;
void Start()
{
collider = GetComponent<Collider2D>();
}
// Update is called once per frame
void Update()
{
if(state == State.closed)
{
//change sprite to be a closed door sprite
collider.enabled = true;
}
if(state == State.locked)
{
//change sprite to be a locked door sprite
collider.enabled = true;
}
if(state == State.open)
{
//change sprite to be an open door sprite
collider.enabled = false;
}
}
void unlockDoor()
{
if(state == State.locked)
{
state = State.open;
}
Debug.Log("Door Unlocked");
}
void OnCollisionEnter2D(Collision2D coll)
{
if(coll.gameObject.tag == "Player")
{
if (state == State.locked)
{
KeyScript[] keyScripts = coll.gameObject.GetComponents<KeyScript>();
foreach (KeyScript key in keyScripts)
{
if (key.color == doorColor)
{
unlockDoor();
break;
}
}
}
}
}
}
fileFormatVersion: 2
guid: 626a32dcf7a1f8346a8a675af9f9ecb3
timeCreated: 1478218850
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections;
public class KeyScript : MonoBehaviour {
public KeyColor color;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter2D(Collision2D coll)
{
if(coll.gameObject.tag == "Player")
{
KeyScript ks = coll.gameObject.AddComponent<KeyScript>();
ks.color = this.color;
}
}
}
public enum KeyColor
{
red,
blue,
green,
purple,
yellow,
orange
}
fileFormatVersion: 2
guid: 1a3035633693fa445898879705a191ae
timeCreated: 1478825784
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: a7980e3cc7ad39d4aa968cb9fe241a0a
folderAsset: yes
timeCreated: 1477613634
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9c9cc0aa126d8b84494ab110abe4d840
timeCreated: 1478218669
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9dbbd5fe69390d5489f18914e7f5f7ad
folderAsset: yes
timeCreated: 1477085342
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 98cacb8c64e9186478cfed1f1e585757
timeCreated: 1478218669
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 91273c6ae51601d4caf154810604da16
folderAsset: yes
timeCreated: 1477613634
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0bc1ee29b443c744a879fae3a31be6e0
timeCreated: 1478218669
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 647a00acb440c0c4aa002d9f0ae2ffd5
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0aa7e9ee35c587c4e8c03208b88269cb
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: a25513e707cbe794aa471c196b40ee22
folderAsset: yes
timeCreated: 1475761198
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment