示例#1
0
 public void switchLeverNoPropagation()
 {
     if (activated == false)
     {
         targetHeight = maxHeight;
         activated    = true;
         if (level_N != null)
         {
             if (activateSound_N != null)
             {
                 level_N.playSound(activateSound_N);
             }
         }
     }
     else
     {
         targetHeight = minHeight;
         activated    = false;
         if (level_N != null)
         {
             if (activateSound_N != null)
             {
                 level_N.playSound(deactivateSound_N);
             }
         }
     }
 }
示例#2
0
 public void activate()
 {
     state = 1;
     image.raycastTarget = true;
     image.enabled       = true;
     level.playSound(waterSound);
 }
    IEnumerator SpawnShoper()
    {
        GameObject shoper = shopers [Random.Range(0, shopers.Length)].gameObject;

        path = Random.Range(0, paths.Length);

        if (doors [path] != null)
        {
            doors [path].GetComponent <BetterDoor2> ()._wm_open();
        }
        else
        if (CalculatePlayerPos())
        {
            lvl.playSound(openSound);
        }

        yield return(new WaitForSeconds(0.5f));

        shoper.GetComponent <NPCGoInPath> ().pathName = paths [path].name;
        shoper.GetComponent <NPCGoInPath> ().cont     = 0;
        Instantiate(shoper, paths [path].transform.position, shoper.transform.rotation);

        yield return(new WaitForSeconds(1.0f));

        if (doors [path] != null)
        {
            doors [path].GetComponent <BetterDoor2> ()._wm_close();
        }
        else
        if (CalculatePlayerPos())
        {
            lvl.playSound(closeSound);
        }
    }
示例#4
0
    public void _wm_open()
    {
        bool canOpen = true;

        if (!permissionVariable.Equals(""))
        {
            canOpen = level.retrieveBoolValue(permissionVariable);
        }

        if (!canOpen)
        {
            if (cannotOpenSound != null)
            {
                level.playSound(cannotOpenSound);
            }
            return;
        }

        level.storeBoolValue("Is" + this.name + "Open", true);
        isOpen      = true;
        targetAngle = openAngle;

        if (calculatePos && CalculatePlayerPos() || !calculatePos)
        {
            if (openSound != null)
            {
                level.playSound(openSound);
            }
        }

        if (secondaryDoor != null)
        {
            secondaryDoor._wm_open();
        }
    }
示例#5
0
 public void openDrawer()
 {
     targetZ = openZ;
     isOpen  = true;
     if ((lvl != null) && (openSound != null))
     {
         lvl.playSound(openSound);
     }
 }
示例#6
0
 public void _wm_close()
 {
     targetX = 0;
     if ((level != null) && (dragSound != null))
     {
         //level.playSound (dragSound);
         level.playSound(dragSound, level.player.transform.position, this.transform.position, 0.00025f);
     }
 }
示例#7
0
 public void openCloset()
 {
     targetAngle = openAngle;
     if ((level != null) && (openSound != null))
     {
         level.playSound(openSound);
     }
     isOpen = true;
 }
示例#8
0
    public void _wm_open()
    {
        level.storeBoolValue("Is" + this.name + "Open", true);
        targetAngle = openAngle;

        if (openSound != null)
        {
            level.playSound(openSound);
        }
    }
    public void immediateBreak()
    {
        //roca.GetComponent<Renderer> ().enabled = false;
        anim.SetBool("Roto", true);

        //Destroy (roca.gameObject, tiempoDesaparece);
        markedForHiding = true;
        hidingTimer     = 2.0f;

        level.playSound(sonido);
    }
示例#10
0
    public void _wm_open()
    {
        if (state == DoorState.Closed)
        {
            state = DoorState.Opening;
        }

        if ((openSound != null) && (level != null))
        {
            level.playSound(openSound);
        }
        masterController.getStorage().storeBoolValue("IsDoor" + this.name + "Open", true);
    }
示例#11
0
 public void open()
 {
     if ((level != null) && (sound != null))
     {
         level.playSound(sound);
     }
     targetAngle = openAngle;
     if (level == null)
     {
         level = GameObject.Find("LevelController").GetComponent <LevelControllerScript> ();
     }
     level.storeBoolValue(this.name, true);
 }
示例#12
0
    public void alert(string msg)
    {
        text = msg;
        if (chispaIsOut == false)
        {
            chispaIsOut = true;
            if (chispaWorld != null)
            {
                chispaWorld._wa_appear(this);
                if ((level != null) && (openSound != null))
                {
                    level.playSound(openSound);
                }
                this.isWaitingForActionToComplete = true;
            }
            else
            {
                this.isWaitingForActionToComplete = false;
            }
            state = UIChispAlertState.waitingForAppearance;
            return;
        }

        alphaRect.transform.position = new Vector3(-Screen.width / 20.0f - 160.0f - Screen.width - 600.0f, 0, 0);
        theText.text  = text;
        theText.color = new Color(0, 0, 0, 0);
        backdrop.setFadeColor(1, 1, 1);
        backdrop.fadeOut();
        backdrop.GetComponent <Image> ().raycastTarget = true;
        theText.raycastTarget = true;
        if (ChispaLeftToRight)
        {
            chispa.swipeLeftToRight();
            if ((level != null) && (lToR != null))
            {
                level.playSound(lToR);
            }
        }
        else
        {
            chispa.swipeRightToLeft();
            if ((level != null) && (rToL != null))
            {
                level.playSound(rToL);
            }
        }

        ChispaLeftToRight = !ChispaLeftToRight;
    }
示例#13
0
 public void open()
 {
     targetDisplacement = openDisplacement;
     if ((level != null) && (closeSound != null))
     {
         if (state == 0)
         {
             level.playSound(openSound, this.gameObject);
         }
     }
     state = 1;
     if (reentrant)
     {
         level.storeBoolValue(this.name + "Open", true);
     }
 }
示例#14
0
 public void twist()
 {
     targetAngle += angleDelta;
     if ((level != null) && (sounds.Length > 0) && (soundIndex < sounds.Length) && (sounds [soundIndex] != null))
     {
         level.playSound(sounds [soundIndex]);
         soundIndex = (soundIndex + 1) % sounds.Length;
     }
 }
示例#15
0
 public void _wm_elevate()
 {
     targetY = topY;
     if ((level != null) && (elevateClip != null))
     {
         level.playSound(elevateClip);
     }
     if (level != null)
     {
         level.storeBoolValue(reentryVariable, true);
     }
 }
示例#16
0
    // Update is called once per frame
    new void Update()
    {
        if (state == HUDCrackGlassState.cracking)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > nextTimeToCrack)
            {
                elapsedTime     = 0.0f;
                nextTimeToCrack = FloatRandom.floatRandomRange(minTimeToCrack, maxTimeToCrack);
                if (frame < crackedGlass.Length - 1)
                {
                    ++frame;
                    theImage.sprite = crackedGlass [frame];
                    levelController.playSound(crackAudio [frame]);
                }
                else
                {
                    state = HUDCrackGlassState.cracked;
                }
            }
        }

        if (state == HUDCrackGlassState.cracked)
        {
        }

        if (state == HUDCrackGlassState.changingActivity)
        {
            --waitFrames;
            if (waitFrames == 0)
            {
                ds.storeStringValue("ReturnLocation", levelController.locationName);
                levelController.storeStringValue("CurrentLevel", levelController.locationName);
                levelController.storePlayerCoordinates();
                SceneManager.LoadScene("Scenes/QA");
            }
        }
    }
    public void _wm_checkFerfufloAccess()
    {
        level.blockPlayerControls();

        int correct   = level.retrieveIntValue("FerfufloCorrect");
        int completed = level.retrieveIntValue("FerfufloCompleted");

        Debug.Log("Correct answers: " + correct);
        Debug.Log("Completed answers: " + completed);

        if (correct >= numberOfFerfufloTests)
        {
            level.playSound(openSound);
            level.player.blockControls();
            level.storeBoolValue("FerfuflosDone", true);
            level._wm_alert("Puerta abierta");
            state = 1;
        }
        else
        {
            if (completed >= numberOfFerfufloTests)
            {
                level.playSound(noOpenSound);
                level.player.blockControls();
                level._wm_alert("El código configurado en las tarjetas no es válido. Como medida de seguridad, se han reiniciado las tarjetas.");
                state = 2;
            }
            else
            {
                percent = (int)(((float)level.retrieveIntValue("FerfufloCompleted") / 41.0f) * 100.0f);
                percent = percent > 100 ? 100 : percent;
                level.player.blockControls();
                level.playSound(noOpenSound);
                state = 3;
            }
        }
    }
示例#18
0
 public void lightButton()
 {
     unlitPiece.GetComponent <Renderer> ().enabled = false;
     litPiece.GetComponent <Renderer> ().enabled   = true;
     state       = 1;
     elapsedTime = 0.0f;
     if (lightRef != null)
     {
         lightRef.intensity = litIntensity;
     }
     if ((level != null) && (sound != null))
     {
         level.playSound(sound);
     }
 }
示例#19
0
 public void select1()
 {
     response            = 1;
     multiDigitResponse += response * ((int)Mathf.Pow(10, (float)multiDigitResponsePosition));
     if (multiDigitResponsePosition > 0)
     {
         --multiDigitResponsePosition;
     }
     responseAvailable = true;
     if (alertController != null)
     {
         alertController.close();
     }
     if ((level != null) && (userInputSound != null))
     {
         level.playSound(userInputSound);
     }
 }
示例#20
0
    public void activate()
    {
        if (state == MirrorState.activated)
        {
            return;
        }

        elapsedTime = 0.0f;
        state       = MirrorState.activating;
        ds.storeBoolValue(level.locationName + MirrorColor + "MirrorActivated", true);
        interactEnabled = true;
        interactIcon();

        if (activationSound)
        {
            level.playSound(activationSound);
        }
    }
    public void action()
    {
        int leverOK = 0;

        for (int i = 0; i < levers.Length; ++i)
        {
            if (levers [i].isActivated())
            {
                ++leverOK;
            }
        }

        if (leverOK == levers.Length)
        {
            if ((level != null) && (prizeSound != null))
            {
                level.playSound(prizeSound);
                if (prizeProgram != null)
                {
                    prizeProgram.startProgram(0);
                }
            }
        }
    }
示例#22
0
	new void Update () 
	{
        if(meditatingRemaining > 0.0f)
        {
            meditatingRemaining -= Time.deltaTime;
            return;
        }

        if (remainingBlinks > 0) // orthogonal blinking state
        {
            remainingBlinkTime -= Time.deltaTime;
            if(remainingBlinkTime <= 0.0f)
            {
                BlinkShow = !BlinkShow;
                remainingBlinkTime = 0.08f;
                --remainingBlinks;
                if(remainingBlinks == 0)
                {
                    BlinkShow = true;
                }
                spriteQuadRef.GetComponent<SpriteRenderer>().enabled = BlinkShow;
            }
        }

        if (mustSnapToPlayerStart > 0) {
			if (GameObject.Find ("PlayerStart")) 
			{
				Vector3 newPos = GameObject.Find ("PlayerStart").transform.position;
				this.transform.position = newPos;
			}
			mustSnapToPlayerStart--;
		}

		if (!started)
			return;
		if (state == PlayerState.idling) 

		{
			materializated = true;
		}

		if (state2 == PlayerState.enteringMirror) 
		{			
			lerp += Time.deltaTime;
			if (lerp > 1.0f) 
			{
				lerp = 1.0f;					
			}
			if (blink) {
				spriteQuadRef.GetComponent<SpriteRenderer> ().enabled = false;
				mirroredPlayer.gameObject.SetActive(false);
			} else {
				spriteQuadRef.GetComponent<SpriteRenderer> ().enabled = true;
				mirroredPlayer.gameObject.SetActive(true);
			}

			blink = !blink;
			Vector3 pos = Vector3.Lerp (enterMirrorStartPosition, enterMirrorPosition, lerp);
			this.transform.position = pos;
			this.transform.localScale = new Vector3 (1.0f - lerp, 1.0f - lerp, 1.0f - lerp);
			mirroredPlayer.transform.localScale = this.transform.localScale;
		}
		if (mirrorActivationDelaying) 
		{ // Reentry condition: showing mirror activation
			if (elapsedTime > mirrorActivationDelay) {
				ds.storeStringValue ("ReentryCondition", "");
				string returnLocation = ds.retrieveStringValue ("ReturnLocation");
				SceneManager.LoadScene (returnLocation);
			}
			return;
		}

		if (state2 == PlayerState.seekingMirrorPoint1) 
		{
			if((agent.remainingDistance < 0.25f) && agent.velocity.magnitude == 0) 
			{	
				Vector3 target = agent.destination + new Vector3 (0, 0, 0.25f);
				agent.destination = target;
				elapsedTime = 0.0f;
				directionFromVector (target, false);
				state2 = PlayerState.seekingMirrorPoint2;
				camRef.GetComponent<CameraUtils>().grab();

			}
		}

		if (state2 == PlayerState.seekingMirrorPoint2) 
		{
			elapsedTime += Time.deltaTime;
			if (elapsedTime > 9.0f) {
				SceneManager.LoadScene("Scenes/WordFight");
			}
		}

		if (state == PlayerState.dematerialized) 
		{
			++dematDelayFrames;

			blockedElapsedTime += Time.deltaTime;

			if (blockedElapsedTime > dematerializationDelay) {
				blockedElapsedTime = 0.0f;
				state = PlayerState.materializing;
				GameObject AuraGO = (GameObject)Instantiate (auraPrefab, 
					this.transform.position + new Vector3(0, 0.16f, -0.5f), 
					Quaternion.Euler (0, 0, 0));
				levelRef.playSound (matSound);
			} else
				return;
		}

		if (state == PlayerState.materializing) 
		{
			blockedElapsedTime += Time.deltaTime;
			float newOpacity = elapsedTime / materializationDuration;
			if (newOpacity > 1.0f)
				newOpacity = 1.0f;
			iTween.ColorUpdate(spriteQuadRef, new Color (1, 1, 1, 1), 4);

			if (blockedElapsedTime > materializationDuration) 
			{
				blockedElapsedTime = 0.0f;
				playerMatRef.color = new Color (1, 1, 1, 1);
				state = PlayerState.idling;
				blocked = false;
				ds.storeBoolValue ("PlayerMustMaterialize", false);
				materializated = true;
			}
		}

		if (Input.GetMouseButtonDown(0) && interaction != Interaction.None) 
		{
			contador = 1;
		}

		if (Input.GetMouseButton (0)) 
		{
			contador += Time.deltaTime;
		}

		if (!blocked && Input.GetMouseButtonUp (0)) 
		{
			if (!canInteract) {
				if (canOpenInventory) {
					if (contador < 0.5f) {
						Ray ray = camRef.ScreenPointToRay (Input.mousePosition);
						//Physics.RaycastAll (ray, out hit);

						RaycastHit[] hits;
						hits = Physics.RaycastAll (ray, 2000);
						for (int i = 0; i < hits.Length; i++) {
							RaycastHit hit = hits [i];

							if (hit.collider != null) {
								if (hit.collider.tag == "Player") {
									blockControls ();
									//inventory._wm_open ();
									inventory.open (1);
								}
							}
						}
					}
				}
			}
			contador = 0;
		}

		if (state2 == PlayerState.spinning) 
		{
			angle += angleSpeed * Time.deltaTime;
			angleSpeed += angleAccel * Time.deltaTime;
			if (angleSpeed > maxAngleSpeed)
				angleSpeed = maxAngleSpeed;
			directionFromAngle (angle);
			playerRendRef.sprite = images [0];
			otherPlayerRendRef.sprite = images [0];
			if (angle > angleThreshold) {
				state2 = PlayerState.spinning2;
				elapsedTime = 0.0f;
				frame = 0;
			}
		}

		if (state2 == PlayerState.spinning2) 
		{
			elapsedTime += Time.deltaTime;
			if (elapsedTime > (1.0f / descendingAnimationSpeed)) {

				if (frame < Descending.Length) {
					frame++;
					elapsedTime = 0.0f;
				} else {
					//levelRef.fadeout (this);
					//this.isWaitingForActionToComplete = true;
					camRef.GetComponent<CameraUtils>().grab();
					mcsRef.getStorage ().storeBoolValue ("IsChangingPlanes", true);
					setOrientation (0);
					idlePose ();
					state2 = PlayerState.spinning3;
					return;
				}
			}
		}

		if (state2 == PlayerState.spinning3)
		{
			//if (isWaitingForActionToComplete)
			//	return;
			string loc = levelRef.lowerFloorName;
			mcsRef.getStorage().storeBoolValue ("InhibitVignette", true);
			mcsRef.getStorage ().storeFloatValue ("Coords" + loc + "X", this.transform.position.x);
			mcsRef.getStorage ().storeFloatValue ("Coords" + loc + "Y", this.transform.position.y);
			mcsRef.getStorage ().storeFloatValue ("Coords" + loc + "Z", this.transform.position.z);
			mcsRef.getStorage ().storeFloatValue ("Coords" + levelRef.lowerFloorName + "X", this.transform.position.x);
			mcsRef.getStorage ().storeFloatValue ("Coords" + levelRef.lowerFloorName + "Y", this.transform.position.y);
			mcsRef.getStorage ().storeFloatValue ("Coords" + levelRef.lowerFloorName + "Z", this.transform.position.z);
			mcsRef.getStorage().storeIntValue ("Orientation", 0);
			SceneManager.LoadScene (levelRef.lowerFloorName);
		}

		if (state2 == PlayerState.ascending) 
		{
			elapsedTime += Time.deltaTime;
			state2 = PlayerState.ascending2;
//			if (elapsedTime > (1.0f / ascendingAnimationSpeed)) {
//				elapsedTime = 0.0f;
//				if (meditationFrame < Ascending.Length) {
//					//playerRendRef.sprite = Ascending [meditationFrame];
//					//otherPlayerRendRef.sprite = Ascending [meditationFrame++];
//				} else {
//					state2 = PlayerState.ascending2;
//					ascendPos = 0.0f;
//					ascendSpeed = 0.0f;
//					ascendStartPos = spriteQuadRef.transform.localPosition;
//				}
//			}
		}

		if (state2 == PlayerState.ascending2) 
		{
			//Vector3 newPos = new Vector3 (ascendStartPos.x, ascendStartPos.y + ascendPos, ascendStartPos.z);
			ascendPos += ascendSpeed * Time.deltaTime;
			ascendSpeed += ascendAccel * Time.deltaTime;
			//spriteQuadRef.transform.localPosition = newPos;
			if ((ascendPos > 90.0f) && !grabbedFrame) {
				camRef.GetComponent<CameraUtils> ().grab ();
				mcsRef.getStorage ().storeBoolValue ("IsChangingPlanes", true);
				mcsRef.getStorage().storeBoolValue ("InhibitVignette", true);
				grabbedFrame = true;
				//levelRef.fadeout ();
			}
			if(ascendPos > 100.0f) {
				string loc = levelRef.upperFloorName;
//				mcsRef.getStorage ().storeFloatValue ("Coords" + loc + "X", this.transform.position.x);
//				mcsRef.getStorage ().storeFloatValue ("Coords" + loc + "Y", this.transform.position.y);
//				mcsRef.getStorage ().storeFloatValue ("Coords" + loc + "Z", this.transform.position.z);
				mcsRef.getStorage ().storeFloatValue ("Coords" + levelRef.upperFloorName + "X", this.transform.position.x);
				mcsRef.getStorage ().storeFloatValue ("Coords" + levelRef.upperFloorName + "Y", this.transform.position.y);
				mcsRef.getStorage ().storeFloatValue ("Coords" + levelRef.upperFloorName + "Z", this.transform.position.z);

				//levelRef.storePhysicalCameraPosition (levelRef.upperFloorName);

//				ds.storeFloatValue ("Pos" + loc + "X", cam.gameObject.transform.position.x);
//				ds.storeFloatValue ("Pos" + loc + "Y", cam.gameObject.transform.position.y);
//				ds.storeFloatValue ("Pos" + loc + "Z", cam.gameObject.transform.position.z);
//				ds.storeFloatValue ("Rot" + loc + "Y", cam.pivotY.transform.localEulerAngles.y);
//				ds.storeFloatValue ("Rot" + loc + "X", cam.pivotX.transform.localEulerAngles.x);
//				ds.storeFloatValue ("PosIn" + loc + "Z", cam.pivotZ.transform.localPosition.z);

				//ds.storeFloatValue ("PosIn" + loc + "M", cam.mainCamera.transform.localPosition.z);
				//SceneManager.LoadScene (levelRef.upperFloorName);
				levelRef.loadScene(levelRef.upperFloorName);
			}
		}

		if (state2 == PlayerState.spawningShadow1)
		{
			blockedElapsedTime = 0.0f;
			state2 = PlayerState.spawningShadow2; 
		}

		if (state2 == PlayerState.spawningShadow2) 
		{
			blockedElapsedTime += Time.deltaTime;
			if(blockedElapsedTime > 1.0f) { // WARNING constantize
				blockedElapsedTime = 0.0f;
				blinkRemainingTime = 0.0f;
				state2 = PlayerState.spawningShadow3;
			}
		}

		if (state2 == PlayerState.spawningShadow3)
		{
			blockedElapsedTime += Time.deltaTime;

			if (blockedElapsedTime > 1f) 
			{
				if (blocked) 
				{
					unblockControls ();
				}
			}

			if (blockedElapsedTime > blinkingTime) {
				blockedElapsedTime = 0.0f;
				state2 = PlayerState.spawningShadow4;
				spriteQuadRef.GetComponent<SpriteRenderer> ().enabled = true;
			}
			blinkRemainingTime += Time.deltaTime;
			if (blinkRemainingTime > (1.0f / shadowBlinkAnimationSpeed)) {
				blinkRemainingTime = 0.0f;
				blink = !blink;
				if (blink)
					spriteQuadRef.GetComponent<SpriteRenderer> ().enabled = false;
				else
					spriteQuadRef.GetComponent<SpriteRenderer> ().enabled = true;
			}
		}

		if (state2 == PlayerState.spawningShadow4) 
		{
			spriteQuadRef.GetComponent<SpriteRenderer> ().enabled = true;
			state = PlayerState.idling;
			state2 = PlayerState.idling;
			iNetRef.frozen = false;
		}

		spawningShadowElapsedTime += Time.deltaTime;

		if (isWaitingForActionToComplete)
			return;
	}
示例#23
0
    new void Update()
    {
        bool change = Utils.updateSoftVariable(ref sparkScale, sparkTargetScale, 30.0f);

        if (change)
        {
            spark1.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
            spark2.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
            spark3.transform.localScale = new Vector3(sparkScale, sparkScale, sparkScale);
        }

        if (state == QAControllerState.idle)
        {
            elapsedTime += Time.deltaTime;


            if (elapsedTime > initialDelay)
            {
                letterOutputSpeed = slowletterOutputSpeed;
                state             = QAControllerState.idle2;
            }
        }

        if (state == QAControllerState.idle2)
        {
            /* extract question and answers */

            ab            = qa.getNextBank();
            correctAnswer = qb.correntAnswer [currentQuestion];
            ab.rosetta    = rosetta;
            qb.rosetta    = rosetta;

            ab.reset();

            burn [currentQuestion].lightUp();

            question = qb.getNextString();

            state = QAControllerState.printingQuestion;

            questionLetterOutput = 0.0f;
        }

        if (state == QAControllerState.printingQuestion)
        {
            int letters = (int)questionLetterOutput;

            if (Input.GetMouseButtonDown(0))
            {
                letterOutputSpeed = fastletterOutputSpeed;
            }

            if ((letters > 2) && (letters < question.Length - 2))
            {
                questionText.text = "<color=" + color1 + ">" + question.Substring(0, letters) + "</color>" +
                                    "<color=" + color2 + ">" + question.Substring(letters, 1) + "</color>" +
                                    "<color=" + color3 + ">" + question.Substring(letters + 1, 1) + "</color>" +
                                    "<color=" + color4 + ">" + question.Substring(letters + 2, question.Length - 1 - letters - 2) +
                                    "</color>";
            }
            if (letters == question.Length)
            {
                questionText.text = question;
            }
            questionLetterOutput += letterOutputSpeed * Time.deltaTime;

            if (letters > question.Length - 1)
            {
                letters           = question.Length - 1;
                questionText.text = "" + question;
                state             = QAControllerState.waitingForAnswer;

                for (int i = 0; i < maxAnswers; ++i)
                {
                    answerGO [i] = null;
                }

                float yPos = YAdjust - (question.Length / QuestionLettersPerLine) * QuestionLineHeight;
                for (int i = 0; i < ab.nItems(); ++i)
                {
                    GameObject newAnswer;
                    newAnswer = Instantiate(QAnswerPrefab);
                    newAnswer.transform.SetParent(answerPanel.transform);
                    newAnswer.transform.localScale = Vector3.one;
                    newAnswer.GetComponent <RectTransform>().sizeDelta        = new Vector2(800, 45);
                    newAnswer.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
                    newAnswer.GetComponent <Text> ().alignment = TextAnchor.UpperCenter;
                    newAnswer.GetComponent <QAAnswer> ().initialize(yPos);
                    newAnswer.GetComponent <QAAnswer> ().answerNumber = i + 1;
                    int nLines;
                    newAnswer.GetComponent <QAAnswer> ().setText(StringUtils.chopLines(ab.getNextString(), 85, out nLines));
                    newAnswer.GetComponent <QAAnswer> ().setDelay(i * 0.3f);
                    yPos        -= (InterAnswerDistance + AnswerLineHeight * (nLines - 1));
                    answerGO [i] = newAnswer;
                }
            }
        }

        if (state == QAControllerState.waitingForAnswer)
        {
            bool waiting = true;
            for (int i = 0; i < ab.nItems(); i++)
            {
                if (answerGO [i].GetComponent <QAAnswer> ().state != QAAnswerState.idle)
                {
                    waiting = false;
                }
                else
                {
                    waiting = true;
                }
            }

            if (waiting)
            {
                for (int i = 0; i < ab.nItems(); i++)
                {
                    answerGO [i].GetComponent <QAAnswer> ().state = QAAnswerState.ready;
                    state = QAControllerState.waitingForAnswer2;
                }
            }
        }

        if (state == QAControllerState.waitingForAnswer2)
        {
        }

        if (state == QAControllerState.answered)
        {
            letterOutputSpeed = slowletterOutputSpeed;
            for (int i = 0; i < ab.nItems(); ++i)
            {
                if (answerGO [i].GetComponent <QAAnswer> ().answerNumber != selectedAnswer)
                {
                    answerGO [i].GetComponent <QAAnswer> ().dispose();
                }
                else
                {
                    answerGO [i].GetComponent <QAAnswer> ().blink(selectedAnswer == correctAnswer);
                    if (selectedAnswer == correctAnswer)
                    {
                        levelRef.playSound(hitSound);
                    }
                    else
                    {
                        levelRef.playSound(missSound);
                    }
                }
            }

            elapsedTime = 0.0f;
            state       = QAControllerState.preparingNextQuestion;
        }

        if (state == QAControllerState.preparingNextQuestion)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > postAnswerTimeOut)
            {
                elapsedTime = 0.0f;
                state       = QAControllerState.preparingNextQuestion2;
                if (selectedAnswer == correctAnswer)
                {
                    burn [currentQuestion].burstInFlames();
                }
                else
                {
                    ++nMisses;
                    if (nMisses > 1)
                    {
                        fader._wa_fadeOut(this);
                        keyChannel = -1;
                        // mark this flame for resurrection, please
                        string lvl           = ds.retrieveStringValue("CurrentLevelFlame");
                        int    FlameIndex    = ds.retrieveIntValue("CurrentFlameIndex");
                        string FlameName     = ds.retrieveStringValue("FlameResurrectionName" + lvl + FlameIndex);
                        string FlameLocation = ds.retrieveStringValue("FlameResurrectionLocation" + lvl + FlameIndex);
                        ds.storeIntValue("Flame" + (FlameIndex) + "Resurrect" + FlameLocation, 3);
                        ds.storeStringValue("Flame" + (FlameIndex) + "Resurrect" + FlameLocation, FlameName);
                        this.isWaitingForActionToComplete = true;
                        state = QAControllerState.exitting3;
                    }
                }
                if (currentQuestion == numQuestions - 1)
                {
                    //fader._wa_fadeOut (this);
                    //this.isWaitingForActionToComplete = true;
                    /* do the flower thing */
                    flowerRenderQuad.GetComponent <GameObjectFader> ().fadeIn();
                    flowerAnim.SetBool("open", true);
                    spark1Anim.SetBool("open", true);
                    spark2Anim.SetBool("open", true);
                    spark3Anim.SetBool("open", true);
                    levelRef.dipMusic(4);
                    levelRef.playSound(sparksSound);
                    sparkTargetScale = 60.0f;
                    elapsedTime      = 0.0f;
                    state            = QAControllerState.exitting1;
                }
            }
        }

        if (state == QAControllerState.preparingNextQuestion2)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > postAnswerTimeOut)
            {
                questionText.text = "";
                ++currentQuestion;
                state = QAControllerState.idle;
            }
        }

        if (state == QAControllerState.exitting1)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 5.6f)
            {
                fader.setFadeColor(1, 1, 1);
                fader._wa_fadeOut(this);
                keyImageFader.fadeIn();
                youGotAKeyTextFader.fadeIn();
                this.isWaitingForActionToComplete = true;
                state = QAControllerState.exitting2;
            }
        }

        if (state == QAControllerState.exitting2)
        {
            if (!isWaitingForActionToComplete)
            {
                levelRef.playSound(winSound);
                elapsedTime = 0.0f;
                state       = QAControllerState.exitting3;
            }
        }

        if (state == QAControllerState.exitting3)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > 2.0f)
            {
                secondFader.setFadeValue(1.0f);
                secondFader.setFadeColor(0, 0, 0);
                secondFader._wa_fadeOut(this);
                this.isWaitingForActionToComplete = true;
                state = QAControllerState.exitting4;
            }
        }

        if (state == QAControllerState.exitting4)
        {
            string rLoc = mcRef.getStorage().retrieveStringValue("ReturnLocation");
            string lvl  = rLoc.Substring(0, 6);

            if (isWaitingForActionToComplete)
            {
            }
            else
            {
                switch (keyChannel)
                {
                case 0:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "RedKey", true);
                    break;

                case 1:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "OrangeKey", true);
                    break;

                case 2:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "BlueKey", true);
                    break;

                case 3:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "GreenKey", true);
                    break;

                case 4:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "YellowKey", true);
                    break;

                case 5:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "PurpleKey", true);
                    break;

                case 6:
                    mcRef.getStorage().storeBoolValue("Has" + lvl + "BrownKey", true);
                    break;
                }
                mcRef.getStorage().storeBoolValue("IsHUDCracked", false);                   // return HUD crack to non-crcked

                // increment number of keys
                string curLev = mcRef.getStorage().retrieveStringValue("CurrentLevel");
                int    n      = mcRef.getStorage().retrieveIntValue(curLev + "NumberOfKeys");
                ++n;
                mcRef.getStorage().storeIntValue(curLev + "NumberOfKeys", n);
                SceneManager.LoadScene(rLoc);
            }
        }
    }