// Update is called once per frame void Update() { //MUST have internet connection if (Const.TEST_CONNECTION) { if (!doneTesting) { string str = Utilities.check_InternetConnection(); if (str.Length == 0) //we're good to go { doneTesting = true; titleText.text = Database.tcText_main; } else { titleText.text = str; } } } #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_IPHONE if (!android_window_displayed) { android_window_displayed = true; finished_reading = false; ad.clearflag(); ad.DisplayAndroidWindow(Database.tcmsg, AndroidDialogue.DialogueType.YESONLY); } if (!URL_opened && ad.yesclicked() && !finished_reading) { //open URL URL_opened = true; Application.OpenURL("http://echolock.andrew.cmu.edu/consent/"); //"http://echolock.andrew.cmu.edu/consent/?" } else if (URL_opened && !finished_reading) //report code from popup using reportConsent() { finished_reading = true; ad.clearflag(); ad.DisplayAndroidWindow("Enter code provided from \n the consent form:", AndroidDialogue.DialogueType.INPUT); } else if (URL_opened && finished_reading && ad.yesclicked()) { Utilities.writefile("consentRecord", "1"); reportConsent(ad.getInputStr()); ad.clearflag(); ad.DisplayAndroidWindow("Thank you!", AndroidDialogue.DialogueType.YESONLY); SceneManager.LoadScene("Title_Screen"); } #endif play_audio(); //Check if we are running either in the Unity editor or in a standalone build. #if UNITY_STANDALONE || UNITY_WEBPLAYER if (eh.isActivate()) { InputEvent ie = eh.getEventData(); switch (ie.keycode) { //Get input from the input manager, round it to an integer and store in horizontal to set x axis move direction case KeyCode.RightArrow: //SoundManager.instance.PlaySingle(swipeRight); break; case KeyCode.LeftArrow: SceneManager.LoadScene("Title_Screen"); SoundManager.instance.PlaySingle(Database.instance.swipeAhead); break; case KeyCode.UpArrow: break; case KeyCode.DownArrow: //BACK //SoundManager.instance.PlaySingle(Database.instance.swipeAhead); //credit break; default: break; } } //Check if we are running on iOS, Android, Windows Phone 8 or Unity iPhone #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_IPHONE Screen.sleepTimeout = SleepTimeout.NeverSleep; Screen.orientation = ScreenOrientation.Landscape; #endif //End of mobile platform dependendent compilation section started above with #elif }
// Update is called once per frame void Update() { play_audio(); //Check if we are running either in the Unity editor or in a standalone build. #if UNITY_STANDALONE || UNITY_WEBPLAYER //Get input from the input manager, round it to an integer and store in horizontal to set x axis move direction if (Input.GetKeyUp(KeyCode.RightArrow)) { //SoundManager.instance.PlaySingle(swipeRight); } else if (Input.GetKeyUp(KeyCode.LeftArrow)) { gotoNextAgreement(); SoundManager.instance.PlaySingle(swipeAhead); } else if (Input.GetKeyUp(KeyCode.UpArrow)) //Up { } else if (Input.GetKeyUp(KeyCode.DownArrow)) //BACK //SoundManager.instance.PlaySingle(swipeAhead); //credit { } //Check if we are running on iOS, Android, Windows Phone 8 or Unity iPhone #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_IPHONE //AndroidDialogue if (ad.noclicked()) { ad.clearflag(); gotoNextAgreement(); } else if (ad.yesclicked()) { ad.clearflag(); gotoNextAgreement(); } //in-game control Screen.sleepTimeout = SleepTimeout.NeverSleep; Screen.orientation = ScreenOrientation.Landscape; if ((Input.deviceOrientation == DeviceOrientation.LandscapeLeft) || (Input.deviceOrientation == DeviceOrientation.LandscapeRight)) { isLandscape = true; } else if (Input.deviceOrientation == DeviceOrientation.Portrait) { isLandscape = false; } float TOUCH_TIME = 0.05f; //Check if Input has registered more than zero touches int numTouches = Input.touchCount; if (numTouches > 0) { //Store the first touch detected. Touch myTouch = Input.touches[0]; //Check if the phase of that touch equals Began if (myTouch.phase == TouchPhase.Began) { //If so, set touchOrigin to the position of that touch touchOrigin = myTouch.position; touchTime = Time.time; } //If the touch phase is not Began, and instead is equal to Ended and the x of touchOrigin is greater or equal to zero: else if (myTouch.phase == TouchPhase.Ended && touchOrigin.x >= 0) { //Set touchEnd to equal the position of this touch Vector2 touchEnd = myTouch.position; //Calculate the difference between the beginning and end of the touch on the x axis. float x = touchEnd.x - touchOrigin.x; //Calculate the difference between the beginning and end of the touch on the y axis. float y = touchEnd.y - touchOrigin.y; //Set touchOrigin.x to -1 so that our else if statement will evaluate false and not repeat immediately. touchOrigin.x = -1; //Check if the difference along the x axis is greater than the difference along the y axis. if (Mathf.Abs(x) > Mathf.Abs(y) && Mathf.Abs(x) >= minSwipeDist) { //If x is greater than zero, set horizontal to 1, otherwise set it to -1 if (x > 0) //RIGHT //SoundManager.instance.PlaySingle(swipeRight); { } else //LEFT { gotoNextAgreement(); SoundManager.instance.PlaySingle(swipeAhead); } } else if (Mathf.Abs(y) > Mathf.Abs(x) && Mathf.Abs(y) >= minSwipeDist) { //If y is greater than zero, set vertical to 1, otherwise set it to -1 if (y > 0) //FRONT //SoundManager.instance.PlaySingle(swipeAhead); { } else //BACK //SoundManager.instance.PlaySingle(swipeAhead); //credit { } } else if (Mathf.Abs(Time.time - touchTime) > TOUCH_TIME) { if (numTouches == 2) { //GameMode.gamemode = GameMode.Game_Mode.MAIN; //SceneManager.LoadScene("Main"); } else { } } } } #endif //End of mobile platform dependendent compilation section started above with #elif }