Created
July 3, 2015 14:20
-
-
Save gotwig/3e2edd4f21e2eb46fecd to your computer and use it in GitHub Desktop.
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 UnityEngine; | |
using System.Collections; | |
public class dooropenclose : MonoBehaviour { | |
public bool open = false; | |
public bool locked = false; | |
// Use this for initialization | |
void Start () { | |
} | |
public void interact(){ | |
if(locked==false){ | |
if(open==false){ | |
this.gameObject.transform.Translate (0.0f,0.0f,1.1f); | |
open=true; | |
}else{ | |
this.gameObject.transform.Translate (0.0f,0.0f,-1.1f); | |
open=false; | |
} | |
} | |
} | |
public void lockit(){ | |
if(locked==false){ | |
locked=true; | |
}else{ | |
locked=false; | |
} | |
} | |
void Update () { | |
} | |
} |
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
switch (interactionType) { | |
case "doorLock": | |
dooropenclose door = otherobject.GetComponent<dooropenclose>(); | |
door.lockit(); | |
if (!door.open){ | |
talkreference = gameObject.AddComponent<talk>(); | |
talkreference.customStuff(dialogID); | |
} | |
break; | |
default: | |
case "dialog": | |
talkreference = gameObject.AddComponent<talk>(); | |
talkreference.customStuff(dialogID); | |
break; | |
case "doorInteract": | |
if (!doorreference){ | |
doorreference = gameObject.AddComponent<dooropenclose>(); | |
} | |
doorreference.interact(); | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment