/Scripts/Tutorial.js
http://acid-and-base.googlecode.com/ · JavaScript · 527 lines · 472 code · 44 blank · 11 comment · 110 complexity · 6675225e2ed74adcc8bd28694544e655 MD5 · raw file
- var inRange : boolean = false;
- var inRangeB : boolean = false;
- var inRangeC : boolean = false;
- var showGUI : boolean = false;
- var resetdialog : boolean = true;
- var part : int;
- var tutorialtext : String;
- var speakChar : String;
- private var count : int = 0;
- private var wi : int;
- private var he : int;
- private var i : int;
- private static var lineLength = 90;
- private var bred;
- private var acid;
- private var base;
- private var mcont : MasterController_edit;
- var weedkiller : boolean = false;
- var shovel : boolean = false;
- var moveshow : boolean = false;
- private var enter : String = "Press Space to Continue";
- function Start ()
- {
- mcont = GameObject.Find("Master Controller Light").GetComponent("MasterController_edit");
- bred = GameObject.Find("Big Red");
- acid = GameObject.Find("Acid");
- base = GameObject.Find("Base");
- switch(part)
- {
- case 0:
- speakChar = "System";
- tutorialtext = "Press W A S D to Move.";
- break;
-
- case 1:
- speakChar = "System";
- tutorialtext = "Press E to Interact.";
- break;
-
- case 2:
- speakChar = "Acid";
- tutorialtext = "Oh... hi there. I'm Acid!";
- break;
-
- case 3:
- speakChar = "Base";
- tutorialtext = "Oh thank you for freeing me! I'm Base. I'd be happy to help you.";
- break;
-
- case 4:
- speakChar = "System";
- tutorialtext = "Acid and Base need to be neutral enough to climb.";
- break;
-
- case 5:
- speakChar = "Sad Ant";
- tutorialtext = "Man, I wish I could bring that steak \n back to my queen but it's blocked!";
- break;
-
- default:
- break;
- }
-
- tempStart();
- }
- function Update ()
- {
- switch(part)
- {
- case 0:
- if(!showGUI && count == 0)
- {
- count = 1;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- }
- else if(count == 1 && !showGUI && moveshow)
- {
- showGUI = true;
- }
- else if(showGUI)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- Destroy(this);
- }
- }
- break;
-
- case 1:
- if(showGUI)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- Destroy(this);
- }
- }
- else if(inRange)
- {
- showGUI = true;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- }
- break;
-
- case 2:
- if(inRange && count == 0)
- {
- showGUI = true;
- bred.GetComponent("ModifiedController").enabled = false;
- count = 1;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- }
- else if(count == 1)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 2;
- speakChar = "Acid";
- tutorialtext = "What? You're stuck in a dream?";
- }
- }
- else if(count == 2)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 3;
- speakChar = "Acid";
- tutorialtext = "Okay, I'll help you, but you have to let me free my friend Base first. He got caught in a rat cage!";
- }
- }
- else if(count == 3)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 4;
- speakChar = "Acid";
- tutorialtext = "I can melt it if I become stronger. Help me find an item that will lower my pH.";
- }
- }
- else if(count == 4)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 5;
- speakChar = "System";
- tutorialtext = "Press Q to switch control between characters.";
- }
- }
- else if(count == 5)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 6;
- speakChar = "System";
- tutorialtext = "Press F while touching a character to toggle follow.\nThe character will stop following you if you press E or Q.";
- }
- }
- else if(count == 6)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {print("give me the controls back");
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- mcont.gotAcid = true;
- Destroy(this);
- }
- }
- break;
-
- case 3:
- if(count == 4)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- acid.GetComponent("ModifiedController").enabled = true;
- mcont.both = true;
- Destroy(this);
- }
- }
- else if(count == 3)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 4;
- speakChar = "System";
- tutorialtext = "Press ESC key to go to the pause menu.";
- }
- }
- else if(count == 2)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 3;
- /*var scale : controlInstruction = GameObject.Find("Master Controller Light").GetComponent("controlInstruction");
- scale.canShowScale = true;*/
- //scale.showScale = true;
- speakChar = "System";
- tutorialtext = "The top right bar on the pause screen represents the pH levels of Acid and Base.";
- }
- }
- else if(count == 1)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 2;
- speakChar = "Base";
- tutorialtext = "Let's get out of here first.\nI can't climb the dandelion though because I'm too basic.";
- }
- }
- else if(inRangeB || inRange && count == 0)
- {
- showGUI = true;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- acid.GetComponent("ModifiedController").enabled = false;
- acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- mcont.gotAcid = false;
- count = 1;
- }
- break;
-
- case 4:
- if(showGUI)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- acid.GetComponent("ModifiedController").enabled = true;
- base.GetComponent("ModifiedController").enabled = true;
- mcont.both = true;
- Destroy(this);
- }
- }
- else if(inRangeC)
- {
- showGUI = true;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- acid.GetComponent("ModifiedController").enabled = false;
- acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- base.GetComponent("ModifiedController").enabled = false;
- base.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- mcont.both = false;
- }
- break;
-
- case 5:
- if(showGUI && !weedkiller)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- resetdialog = false;
- bred.GetComponent("ModifiedController").enabled = true;
- acid.GetComponent("ModifiedController").enabled = true;
- base.GetComponent("ModifiedController").enabled = true;
- mcont.both = true;
- //Destroy(this);
- }
- }
- if(showGUI && weedkiller && count == 0)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 1;
- resetdialog = false;
- speakChar = "Base";
- tutorialtext = "I bet I can use the steak to become soapy!";
- }
- }
- else if(count == 1)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- acid.GetComponent("ModifiedController").enabled = true;
- base.GetComponent("ModifiedController").enabled = true;
- mcont.both = true;
- count = 0;
- speakChar = "Sad Ant";
- tutorialtext = "Man, I wish I could bring that steak back to my queen but it's blocked!";
- //Destroy(this);
- }
- }
- else if(inRangeC && resetdialog)
- {
- showGUI = true;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- acid.GetComponent("ModifiedController").enabled = false;
- acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- base.GetComponent("ModifiedController").enabled = false;
- base.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- mcont.both = false;
- }
- if(shovel)
- {
- part = 6;
- }
- break;
-
- case 6:
- if(showGUI && count == 0)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- count = 1;
- speakChar = "Base";
- tutorialtext = "I bet I can use the steak to become soapy!";
- }
- }
- else if(count == 1)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- acid.GetComponent("ModifiedController").enabled = true;
- base.GetComponent("ModifiedController").enabled = true;
- mcont.both = true;
- Destroy(this);
- }
- }
- else if(inRangeC)
- {
- showGUI = true;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- acid.GetComponent("ModifiedController").enabled = false;
- acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- base.GetComponent("ModifiedController").enabled = false;
- base.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- mcont.both = false;
- speakChar = "Happy Ant";
- tutorialtext = "I wanna take you for a ride!";
- GameObject.Find("Ant").GetComponent("AntRide").enabled = true;
- }
- break;
-
- default:
- if(showGUI)
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- showGUI = false;
- bred.GetComponent("ModifiedController").enabled = true;
- acid.GetComponent("ModifiedController").enabled = true;
- base.GetComponent("ModifiedController").enabled = true;
- mcont.both = true;
- Destroy(this);
- }
- }
- else if(inRangeC)
- {
- showGUI = true;
- bred.GetComponent("ModifiedController").enabled = false;
- bred.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- acid.GetComponent("ModifiedController").enabled = false;
- acid.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- base.GetComponent("ModifiedController").enabled = false;
- base.GetComponent(CharacterMotor).inputMoveDirection = Vector3(0,0,0);
- mcont.both = false;
- }
- break;
- }
- tempUpdate();
- }
- function OnTriggerEnter (col : Collider)
- {
- var prop : Properties = col.GetComponent("Properties");
- if(col.GetComponent(CharacterController) == null)
- return;
- inRangeC = true;
- if(prop != null)
- {
- if(prop.abType == AcidOrBase.Acid)
- inRangeB = true;
- return;
- }
- inRange = true;
- }
- function OnTriggerExit (col : Collider)
- {
- var prop : Properties = col.GetComponent("Properties");
- if(col.GetComponent(CharacterController) == null)
- return;
- inRangeC = false;
- resetdialog = true;
- if(prop != null)
- {
- if(prop.abType == AcidOrBase.Acid)
- inRangeB = false;
- return;
- }
- inRange = false;
- }
- function OnGUI()
- {
- if (showGUI)
- {
- //GUI.Label (Rect (Screen.width/2 - wi/2, Screen.height/2 - he/2, wi, he), tutorialtext, "box");
- //GUI.Label (Rect (Screen.width/2 - (10*enter.length/2), Screen.height/2 + he/2 + 10, (10*enter.length), 20), enter, "box");
- displayTextGUI(speakChar, tutorialtext);
- }
- tempOnGUI();
- }
- // below here are temporarily here for tomorrow's demo
- private var guiHeight = 0; // gui window height.
- private var guiPadding = 10; // gui padding
- var bgGoesHere : Texture2D;
- var putFontHere : Font;
- var acidFullImage : Texture2D;
- var baseFullImage : Texture2D;
- var redFullImage : Texture2D;
- var bgStyle : GUIStyle; // textbox GUI style
- var idStyle : GUIStyle; // text GUI style
- var txtStyle : GUIStyle; // text GUI style (2)
- var emptyStyle : GUIStyle; // empty style for images
- private var dispChar;
- private var dispMessage;
- private var wTop;
- private var wLeft;
- private var wLength;
- private var wWidth;
- private var gapForName;
- private var fNameSize;
- private var fTextSize;
- var displayGUI = false;
- function tempStart()
- {
- // here goes the style!!
- bgStyle.name = "box";
- bgStyle.normal.background = bgGoesHere;
- idStyle.name = "text_name";
- idStyle.wordWrap = true;
- idStyle.font = putFontHere;
- idStyle.padding.left = 10;
- idStyle.padding.top = 10;
- idStyle.padding.right = 10;
- idStyle.padding.bottom = 10;
- idStyle.fontSize = 30;
- idStyle.normal.textColor = Color(1,1,1,1);
- txtStyle.name = "text_conversation";
- txtStyle.wordWrap = true;
- txtStyle.font = putFontHere;
- txtStyle.padding.left = 10;
- txtStyle.padding.top = 10;
- txtStyle.padding.right = 10;
- txtStyle.padding.bottom = 10;
- txtStyle.fontSize = 20;
- txtStyle.normal.textColor = Color(1,1,1,1);
-
- dispChar = "NULL";
- dispMessage = "NULL String is NULL";
- }
- function tempUpdate()
- {
- // height of the GUI will always be 1/3 of the screen...
- guiHeight = Screen.height/3;
-
- wLeft = guiPadding;
- wTop = Screen.height-guiHeight;
- wLength = Screen.width-(2*guiPadding);
- wWidth = guiHeight-guiPadding;
-
- fNameSize = guiHeight/5;
- idStyle.fontSize = fNameSize;
-
- fTextSize = guiHeight/8;
- txtStyle.fontSize = fTextSize;
-
- gapForName = fNameSize;
- }
- function tempOnGUI()
- {
- if (displayGUI)
- {
- //GUI.Box(Rect(0,0,Screen.width,Screen.height),acidFullImage,emptyStyle);
- GUI.Box(Rect(wLeft,wTop,wLength,wWidth),"",bgStyle);
- GUI.Box(Rect(wLeft,wTop,wLength,wWidth),dispChar,idStyle);
- GUI.Box(Rect(wLeft,wTop+gapForName,wLength,wWidth),dispMessage,txtStyle);
- }
- }
- function displayTextGUI(chara : String, message : String)
- {
- displayGUI = true;
- dispChar = chara;
- dispMessage = message;
- }
- function removeGUI()
- {
- displayGUI = false;
- }