Skip to content

Instantly share code, notes, and snippets.

@gotwig
Created July 3, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotwig/3e2edd4f21e2eb46fecd to your computer and use it in GitHub Desktop.
Save gotwig/3e2edd4f21e2eb46fecd to your computer and use it in GitHub Desktop.
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 () {
}
}
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