// Use this for initialization void Start() { currentScore = GameObject.Find("CurrentScore").GetComponent<CurrentScore>(); fullScore = GameObject.FindObjectOfType<FullScore>(); score = GetComponent<Score>(); energy = GetComponent<Energy>(); energyLine = GameObject.FindObjectOfType<EnergyLine>(); inputController = GameObject.FindObjectOfType<InputController>(); timerScript = GameObject.FindObjectOfType<TimerScript>(); timerUI = GameObject.FindObjectOfType<TimerUI>(); info = GetComponent<Info>(); taskStrings = GetComponent<TaskStrings>(); pauseButton = GameObject.FindObjectOfType<PauseButton>().gameObject; pauseMenu = GameObject.Find("Canvas").GetComponentInChildren<PauseMenu>(); // endMenu = GameObject.FindObjectOfType<EndMenu>(); taskHelper = GameObject.FindObjectOfType<TaskHelper>(); globalController = GetComponent<GlobalController>(); cam = GameObject.Find("MainCamera"); secondCamera = GameObject.Find("SecondCamera"); wordRideCanvas = GameObject.FindObjectOfType<WordRideCanvas>(); metalSparksPrefab = Resources.Load("Prefabs/Particles/MetalSpark") as GameObject; carUserParametres = GetComponent<CarUserParametres>(); gameUI = GameObject.FindObjectOfType<GameUI>(); canvasController = GameObject.FindObjectOfType<CanvasController>(); particleCanvas = GameObject.Find("ParticleCanvas"); carCreator = GameObject.FindObjectOfType<CarCreator>(); mainBonus = GameObject.FindObjectOfType<MainBonus>(); waitBackground = GameObject.FindObjectOfType<WaitBackground>(); }
// Use this for initialization public void Start () { m_playerScore = 0; m_LevelComplete = false; m_Timer = GameManager.GetUIManager().gameObject.GetComponentInChildren<TimerScript>(); m_pState = FindObjectOfType<PlayerState>(); }
//assume normal context initially, have to store here to allow access both by player and gamemanger void Start () { DontDestroyOnLoad (transform.gameObject); //timer = GameObject.FindGameObjectWithTag("Timer"); Stages.Add (new Stage ("Title Screen", 0, 100, true, "", false)); Stages.Add (new Stage ("Mom's House", 1, 30, true, "Does she know my life is on the line?")); Stages.Add (new Stage ("Ex-Girlfriends'", 2, 55, false, "It was a bad breakup.")); Stages.Add (new Stage ("Guardian Angel's", 3, 30, false, "Talk about a leap of faith.")); Stages.Add (new Stage ("The Jetsons",4,45,false,"I hate sky deliveries.")); Stages.Add (new Stage ("Bouncy Bill's",5,30,false,"Used to love coming here as a kid.")); currLevel = 0; timer = new TimerScript (); }
// Update is called once per frame void UpdateScore() { Transform t = HUDCanvas.transform.FindChild("Timer"); time = t.gameObject.GetComponent<TimerScript>(); // set the text with score int sec = (int)(time.getTime() * 10.0f); timeScore = sec * 10; totalScore = timeScore + coinScore; text.text = "Score: " + totalScore; stateMachine.updateScore (totalScore); }
// Use this for initialization void Start() { if (stateMachine == null) stateMachine = GameObject.FindGameObjectWithTag("SM").GetComponent<CentralStateScript>(); text = GetComponent<Text>(); if (HUDCanvas == null) HUDCanvas = GameObject.FindGameObjectWithTag("HUD").GetComponent<Canvas>(); totalScore = 0; timeScore = 0; coinScore = 0; scoreMultiplier = 1; Transform t = HUDCanvas.transform.FindChild("Timer"); time = t.gameObject.GetComponent<TimerScript>(); InvokeRepeating("UpdateScore", 0, 0.1f); }
void Start() { //init the actions in the level actionList[0] = new string[2]{"manrestroom","find"}; actionList[1] = new string[2]{"pantsfly","find"}; actionList[2] = new string[2]{"toilet","focus"}; actionList[3] = new string[2]{"pantsfly", "find"}; actionList[4] = new string[2]{"done", "you're"}; curAction = actionList[actionIndex]; actionPrompt = GameObject.Find("Action Prompt"); actionPrompt.guiText.text = formatActionPromptText(); action01 = GameObject.Find("Action01"); action02 = GameObject.Find("Action02"); action02.SetActive(false); actionTimer = GameObject.Find("Timer").GetComponent<TimerScript>(); }
// Use this for initialization void Start() { //load JSON file from a relative path www = new WWW("file://"+Application.dataPath+"/ChaptersData/chapter"+level+".json"); /*we haven't finish loading the JSON data here, so there is no data to load for UI text. I remove them to Updata()*/ //TODO find out a mechanics to listen to a event like onComplete //actionPrompt = GameObject.Find("Action Prompt"); //actionPrompt.guiText.text = formatActionPromptText(); if (level == 3){ action01 = GameObject.Find("Action01"); action02 = GameObject.Find("Action02"); action02.SetActive(false); } actionTimer = GameObject.Find("Timer").GetComponent<TimerScript>(); am = GameObject.Find("AudioManager").GetComponent<AudioManager>(); }
public void NextBtnClicked() { Debug.Log("NextBtnClicked()"); string classId = Global.classId; if (word_length <= 0) { Debug.Log("NextBtnClicked() word_length is zero, return"); return; } CantTouchPage.SetActive(true); if (prev_or_next == false && startIndex == 2) { startIndex++; } prev_or_next = true; Transform tempTransform = gameObject.transform; StopCoroutine(TimerScript.StopWatchStart()); int clickTime = (int)TimerScript.sw.ElapsedMilliseconds; TimerScript.sw.Stop(); sentenceTimer.Add(clickTime); ps = GameObject.FindObjectOfType <PostScript>(); /* * forelink - startIndex transition on study contents * (1 -> Popup -> 3 -> Popup -> 4 -> 5 -> 6) x 2 -> 7 * 1: study1 - sentence intro * 3: study3 - word1 meaning (Study3*.wav) * 4: study4 - word1 usage 1 (Study4*.wav) * 5: study5 - word1 usage 2 * 6: study6 - word1 usage 3 * forelink - startIndex transition on quiz contents * 8 -> 9 -> 10 -> 11 -> 12 -> 13 -> 14 -> 8 -> 9 -> 10 -> 11 -> 12 -> 13 -> 14 * 8: quiz1 - meaning of word1 * 9: quiz2 - sound of word1 * 10: quiz3 - select correct word1 for blank in sentence * 11: quiz4 - meaning of word2 * 12: quiz5 - sound of word2 * 13: quiz6 - select correct word2 for blank in sentence * 14: quiz7 - ordering words for sentence */ switch (startIndex)//인덱스에 해당하는 DB에 가서 그 값을 저장한다 { case 1: if (word_count == 1) //단어가 여러개일때 다시 여기로 오면서 타임 값이 0이 되므로 word_count가 1일때 한번만 저장시키기로 한다 { val_str = sentence_count.ToString() + ",DayTimerTable,Study1," + clickTime.ToString() + "," + rotate_number.ToString(); //Debug.Log("val_str = " + val_str); ps.RenumPostInit(val_str); } break; case 3: val_str = sentence_count.ToString() + ",DayTimerTable,Study3_" + word_count.ToString() + "," + clickTime.ToString() + "," + rotate_number.ToString(); ps.RenumPostInit(val_str); break; case 4: val_str = sentence_count.ToString() + ",DayTimerTable,Study4_" + word_count.ToString() + "," + clickTime.ToString() + "," + rotate_number.ToString(); ps.RenumPostInit(val_str); break; case 7: val_str = sentence_count.ToString() + ",DayTimerTable,Study5," + clickTime.ToString() + "," + rotate_number.ToString(); ps.RenumPostInit(val_str); break; default: break; } TimerScript.sw.Reset(); if ((startIndex == (ps.parse_Attribute[7 + 2 * (word_count - 1)].Split(';').Length + 2)) && (word_count < word_number)) { tempTransform.Find(page[startIndex]).gameObject.SetActive(false); startIndex = 1; word_count++; StudyText[1].text = ps.parse_Attribute[2 + word_count - 1]; StudyText[2].text = ps.parse_Attribute[6 + 2 * (word_count - 1)]; StudyText[3].text = ps.parse_Attribute[7 + 2 * (word_count - 1)].Split(';')[0]; StudyText[4].text = ps.parse_Attribute[7 + 2 * (word_count - 1)].Split(';')[1]; StudyText[5].text = ps.parse_Attribute[7 + 2 * (word_count - 1)].Split(';')[2]; for (int i = 0; i < ps.tempSpriteList.Count; i++) { if (sentence_count + "_2_" + word_count.ToString() == ps.tempSpriteList[i].name) { Debug.Log("sentence_count + _2_ + word_count.ToString() = " + sentence_count + "_2_" + word_count.ToString()); Debug.Log("ps.tempSpriteList[i].name = " + ps.tempSpriteList[i].name); StudyImage[1].sprite = ps.tempSpriteList[i]; StudyImage[2].sprite = ps.tempSpriteList[i]; StudyImage[3].sprite = ps.tempSpriteList[i]; StudyImage[4].sprite = ps.tempSpriteList[i]; } } tempTransform.Find(page[startIndex]).gameObject.SetActive(true); word_length = StudyText[1].text.Length; NextBtnClicked();//Study1이 화면에 보이지 않고 바로 넘어가게 끔 } else if (startIndex == 2) { tempTransform.Find(page[startIndex - 1]).gameObject.SetActive(false); tempTransform.Find(page[startIndex]).gameObject.SetActive(true); tempTransform.Find(page[startIndex + 1]).gameObject.SetActive(true); startIndex++; } else if (startIndex == 0 || startIndex == 4 || startIndex == 5 || startIndex == 6 || startIndex == 8 || startIndex == 9) { while (!ps.isParseDone) { if (ps.isParseDone) { break; } } if (tempTransform.Find(page[startIndex + 1]).Find("CurrentText") != null) { tempTransform.Find(page[startIndex + 1]).Find("CurrentText").GetComponent <Text>().text = StudyText[1].text; } tempTransform.Find(page[startIndex]).gameObject.SetActive(false); tempTransform.Find(page[startIndex + 1]).gameObject.SetActive(true); startIndex++; } else if (startIndex == 1 || startIndex == 3 || startIndex == 7) { if (startIndex == 1) { tempTransform.Find(page[startIndex]).gameObject.GetComponent <AudioSource>().clip = null; tempTransform.parent.Find("PopUpPage").Find("panel").Find("Text").gameObject.GetComponent <Text>().text = "'" + StudyText[1].text + "'" + " 단어를 배워봐요!"; tempTransform.parent.Find("PopUpPage").gameObject.GetComponent <AudioSource>().clip = Resources.Load("Sound/PopUpSound/word_study_start") as AudioClip; if (tempTransform.Find(page[startIndex + 1]).Find("CurrentText") != null) { tempTransform.Find(page[startIndex + 1]).Find("CurrentText").GetComponent <Text>().text = StudyText[1].text; } } else if (startIndex == 3) { tempTransform.Find(page[startIndex]).gameObject.GetComponent <AudioSource>().clip = null; tempTransform.parent.Find("PopUpPage").Find("panel").Find("Text").gameObject.GetComponent <Text>().text = "'" + StudyText[1].text + "'" + " 단어는 어떻게 사용될까요?"; tempTransform.parent.Find("PopUpPage").gameObject.GetComponent <AudioSource>().clip = Resources.Load("Sound/PopUpSound/word_use") as AudioClip; if (tempTransform.Find(page[startIndex + 1]).Find("CurrentText") != null) { tempTransform.Find(page[startIndex + 1]).Find("CurrentText").GetComponent <Text>().text = StudyText[1].text; } } else if (startIndex == 7) { CantTouchPage.SetActive(false); if (sentence_count % sentence_lastnumber != 0) { NextSentenceBtnClicked(); } else { ps.StudyInfoInit(sentenceTimer, classId, sentence_count); tempTransform.parent.Find("PopUpPage").Find("panel").Find("Text").gameObject.GetComponent <Text>().text = "학습 종료"; tempTransform.parent.Find("PopUpPage").gameObject.SetActive(true); tempTransform.parent.Find("PopUpPage").GetComponent <AudioSource>().Stop(); } return; } tempTransform.parent.Find("PopUpPage").gameObject.SetActive(true); } if (startIndex == 0 || startIndex == 12) { if (startIndex == 12) { tempTransform.Find(page[11]).gameObject.SetActive(false); } UIpage.SetActive(false); for (int i = 0; i < 6; i++) { if (i == 0 || i == 1 || i == 2) { Quiz1Toggle[i].gameObject.transform.parent.parent.Find("Label").GetComponent <Text>().color = new Color(0.24f, 0.22f, 0.22f); } Quiz1Toggle[i].color = new Color(Quiz1Toggle[i].color.r, Quiz1Toggle[i].color.g, Quiz1Toggle[i].color.b, 0f); } tempTransform.Find("Quiz1").Find("WordQuiz").gameObject.SetActive(false); tempTransform.Find("Quiz1").Find("SentenceQuiz").gameObject.SetActive(false); for (int i = 0; i < 6; i++) { Quiz2Toggle[i].color = new Color(Quiz2Toggle[i].color.r, Quiz2Toggle[i].color.g, Quiz2Toggle[i].color.b, 0f); } tempTransform.Find("Quiz2").Find("WordQuiz").gameObject.SetActive(false); tempTransform.Find("Quiz2").Find("SoundQuiz").gameObject.SetActive(false); tempTransform.Find("Quiz3").Find("Size3").gameObject.SetActive(false); tempTransform.Find("Quiz3").Find("Size4").gameObject.SetActive(false); tempTransform.Find("Quiz3").Find("Size5").gameObject.SetActive(false); for (int i = 0; i < 3; i++) { Quiz4Toggle[i].color = new Color(Quiz4Toggle[i].color.r, Quiz4Toggle[i].color.g, Quiz4Toggle[i].color.b, 0f); } RandomQuizScript.toggleList.Clear(); RandomQuizScript.cp_last_index = 21;//초기화 RandomQuizScript.cp_count = 1; } else { UIpage.SetActive(true); } SlotScript.moveCount = 0; CantTouchPage.SetActive(false); }
// Update is called once per frame void Update() { mBody.velocity = new Vector3(xVel, 0, zVel); bikePosition = mBody.position; updateVelocity(); if (playerDir == Direction.North) { xVel = horizVel; } else if (playerDir == Direction.South) { xVel = -horizVel; } else if (playerDir == Direction.East) { zVel = -horizVel; } else if (playerDir == Direction.West) { zVel = horizVel; } if (keyBoardMode == true) { if (Input.GetKeyDown(arrowL) && (controlLocked == "n") && (laneNum > 1)) { horizVel = -5; StartCoroutine(stopSlide()); laneNum -= 1; controlLocked = "y"; resetPlayer(); } if (Input.GetKeyDown(arrowR) && (controlLocked == "n") && (laneNum < 3)) { horizVel = 5; StartCoroutine(stopSlide()); laneNum += 1; controlLocked = "y"; resetPlayer(); } // for testing arm poses // E is for left and T is for right if (Input.GetKeyDown(keyT)) { rightPlayer.enabled = true; staticPlayer.enabled = false; leftPlayer.enabled = false; } else if (Input.GetKeyDown(keyR)) { rightPlayer.enabled = false; staticPlayer.enabled = true; leftPlayer.enabled = false; } else if (Input.GetKeyDown(keyE)) { rightPlayer.enabled = false; staticPlayer.enabled = false; leftPlayer.enabled = true; } } if (Input.GetKeyDown(keyW)) { bikeSpeed = bikeSpeed + 2; updateVelocity(); } if (Input.GetKeyDown(keyS)) { bikeSpeed = bikeSpeed - 2; updateVelocity(); } if (Input.GetKeyDown(keyD)) { Rotate(90, bikePosition.x, bikePosition.z); StartCoroutine(RotateCam(Vector3.up, 90, 0.3f)); if (helpOn) { TimerScript.stopTimer(); } laneNum = 2; resetPlayer(); } if (Input.GetKeyDown(keyA)) { Rotate(-90, bikePosition.x, bikePosition.z); StartCoroutine(RotateCam(Vector3.up, -90, 0.3f)); if (helpOn) { TimerScript.stopTimer(); } laneNum = 2; resetPlayer(); } // each time you go past the next endpoint, increment streetPieceCounter if (!inBounds()) // if not within boundaries { Debug.Log("RAN OUT OF THE STREET, THATS NO BUENO"); infoText.text = "OOPS, bikes can't go there!"; speedText.text = ""; //Application.Quit(); //Time.timeScale = 0; //Debug.Break(); resetGame(); } if (destroyRoad(bikePosition.x, bikePosition.z)) { createScene(); } }
void Start() { instance = this; }
public void PrevBtnClicked() { string classId = Global.classId; pageNum--; CantTouchPage.SetActive(true); Transform tempTransform = gameObject.transform; StopCoroutine(TimerScript.StopWatchStart()); int clickTime = (int)TimerScript.sw.ElapsedMilliseconds; TimerScript.sw.Stop(); string[] tempString_AA = new string[] { }; tempString_AA = ps.quizJson["data"][0][pageNum]["quiz_id"].ToString().Split(';'); if ((pageNum - wordChangeCount) >= 0) { templistTimer[Int32.Parse(tempString_AA[1].Remove(1)) - 1] += clickTime; } else { pageNum++; TimerScript.sw.Reset(); SlotScript.moveCount_last = 0; SlotScript.moveCount = 0; CantTouchPage.SetActive(false); return; } ps = GameObject.FindObjectOfType <PostScript>(); switch (startIndex)//인덱스에 해당하는 DB에 가서 그 값을 저장한다 { case 8: StartCoroutine(AddAnsweTimer(0)); val_str = sentence_count.ToString() + ",DayTimerTable,Quiz1," + clickTime.ToString() + "," + rotate_number.ToString(); ps.RenumPostInit(val_str); break; case 9: StartCoroutine(AddAnsweTimer(1)); val_str = sentence_count.ToString() + ",DayTimerTable,Quiz2," + clickTime.ToString() + "," + rotate_number.ToString(); ps.RenumPostInit(val_str); break; case 10: StartCoroutine(AddAnsweTimer(2)); val_str = sentence_count.ToString() + ",DayTimerTable,Quiz3," + clickTime.ToString() + "," + rotate_number.ToString(); ps.RenumPostInit(val_str); break; case 11: val_str = sentence_count.ToString() + ",DayTimerTable,Quiz4," + clickTime.ToString() + "," + rotate_number.ToString(); ps.RenumPostInit(val_str); break; default: break; } TimerScript.sw.Reset(); if (pageNum >= 0) { for (int i = 0; i < page.Length; i++) { // Debug.Log(page[i]); if (tempTransform.Find(page[i]) != null) { tempTransform.Find(page[i]).gameObject.SetActive(false); } } // Debug.Log(ps.quizJson["data"][0][pageNum]["quiz_type"].Value); //tempTransform.Find(page[int.Parse(ps.quizJson["data"][0][pageNum]["quiz_type"].Value) + 7]).gameObject.SetActive(true); //tempTransform.Find(page[int.Parse(ps.quizJson["data"][0][pageNum]["quiz_type"].Value) + 7]).GetComponent<RandomQuizScript>().QuizInit(); tempTransform.Find(page[pageNum % 5]).gameObject.SetActive(true); tempTransform.Find(page[pageNum % 5]).GetComponent <RandomQuizScript>().QuizInit(); } else { pageNum = 0; } SlotScript.moveCount_last = 0; SlotScript.moveCount = 0; CantTouchPage.SetActive(false); }
void Start() { timerScript = FindObjectOfType <TimerScript>(); raceScript = FindObjectOfType <RaceOrganizerManager>(); }
// Update is called once per frame void Update() { bike.velocity = new Vector3(xVel, 0, zVel); bikePosition = bike.position; updateVelocity(); updateLean(); if (W.score - lastScore > 150) { velocityScale = (float)(1 + W.score * 0.005); lastScore = W.score; W.levelUp(); } if (bikeDir == World.Direction.North) { xVel = horizVel; } else if (bikeDir == World.Direction.South) { xVel = -horizVel; } else if (bikeDir == World.Direction.East) { zVel = -horizVel; } else if (bikeDir == World.Direction.West) { zVel = horizVel; } if (SocketClient.signalString == "right") { rightPlayer.enabled = true; staticPlayer.enabled = false; leftPlayer.enabled = false; TimerScript.startTimer(3f, 1); } else if (SocketClient.signalString == "left") { rightPlayer.enabled = false; staticPlayer.enabled = false; leftPlayer.enabled = true; TimerScript.startTimer(3f, 0); } else if (SocketClient.signalString == "none") { rightPlayer.enabled = false; staticPlayer.enabled = true; leftPlayer.enabled = false; } else if (Input.GetKeyDown(keyT)) // right { rightPlayer.enabled = true; staticPlayer.enabled = false; leftPlayer.enabled = false; TimerScript.startTimer(3f, 1); } else if (Input.GetKeyDown(keyR)) // middle { rightPlayer.enabled = false; staticPlayer.enabled = true; leftPlayer.enabled = false; } else if (Input.GetKeyDown(keyE)) // left { rightPlayer.enabled = false; staticPlayer.enabled = false; leftPlayer.enabled = true; TimerScript.startTimer(3f, 0); } if (keyBoardMode == true) { if (Input.GetKeyDown(arrowL) && (controlLocked == "n")) { horizVel = -5; StartCoroutine(stopSlide()); laneNum -= 1; controlLocked = "y"; resetPlayer(); } else if (Input.GetKeyDown(arrowR) && (controlLocked == "n")) { horizVel = 5; StartCoroutine(stopSlide()); laneNum += 1; controlLocked = "y"; resetPlayer(); } } if (SocketClientVoice.turn == "L" && lastTurnNumberLeft < SocketClientVoice.turnNumber) { TimerScript.startTimer(2f, 2); Debug.Log("registered: on your left"); lastTurnNumberLeft = SocketClientVoice.turnNumber; } else if (SocketClientVoice.turn == "R" && lastTurnNumberRight < SocketClientVoice.turnNumber) { TimerScript.startTimer(2f, 3); Debug.Log("registered: on your right"); lastTurnNumberRight = SocketClientVoice.turnNumber; } if (Input.GetKeyDown(keyZ)) // on your left { TimerScript.startTimer(4f, 2); Debug.Log("on your left"); } else if (Input.GetKeyDown(keyC)) // on your right { TimerScript.startTimer(4f, 3); Debug.Log("on your right"); } if (Input.GetKeyDown(keyW)) { bikeSpeed = bikeSpeed + 2; updateVelocity(); } if (Input.GetKeyDown(keyS)) { bikeSpeed = bikeSpeed - 2; updateVelocity(); //resetGame(); } if (Input.GetKeyDown(keyD)) // turn right { if (TimerScript.turningAllowed == "right") { Rotate(90, bikePosition.x, bikePosition.z); StartCoroutine(RotateCam(Vector3.up, 90, 0.3f)); TimerScript.stopTimer(); laneNum = 2; resetPlayer(); TimerScript.stopTimer(); } else { endGame(2); } } if (Input.GetKeyDown(keyA)) // turn left { if (TimerScript.turningAllowed == "left") { Rotate(-90, bikePosition.x, bikePosition.z); StartCoroutine(RotateCam(Vector3.up, -90, 0.3f)); TimerScript.stopTimer(); laneNum = 2; resetPlayer(); TimerScript.stopTimer(); } else { endGame(2); } } if (Input.GetKeyDown(keyQ)) { Time.timeScale = 1; resetGame(); } // each time you go past the next endpoint, increment streetPieceCounter checkCrash(); if (W.destroyScene(bikePosition.x, bikePosition.z)) { nextDir = W.createScene(nextDir); } }
private void Awake() { Instance = this; timerScript = TimerScript.Instance; }
void Start() { gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); createScore = GameObject.Find("GameManager").GetComponent <CreateScore>(); timerScript = GameObject.Find("GameManager").GetComponent <TimerScript>(); }
void OnDestroy() { script = timer.GetComponent <TimerScript>(); script.addTime(); }
void Start() { SManager = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>(); StartCoroutine(StartInit()); TScript = GetComponent <TimerScript>(); }
// Start is called before the first frame update void Start() { timer_script = GameObject.FindGameObjectWithTag("TimerObject").GetComponent <TimerScript>(); }
void Start() { Instance = this; }
private void Start() { timer = GameObject.Find("Timer").GetComponent <TimerScript>(); }
void Update() { if (canMove) { GameObject playfield = GameObject.Find("Horizontal Playfield"); RestrictScript field = playfield.GetComponent <RestrictScript>(); if (speedy == true) { float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); setDirection(inputX, inputY); movement = new Vector3(fast.x * inputX, fast.y * inputY, 0); } if (slowly == true) { float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); setDirection(inputX, inputY); movement = new Vector3(slow.x * inputX, slow.y * inputY, 0); } if (speedy != true && slowly != true) { float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); setDirection(inputX, inputY); movement = new Vector3(speed.x * inputX, speed.y * inputY, 0); } movement *= Time.deltaTime; transform.Translate(movement); Vector3 clampedPosition = transform.position; clampedPosition.x = Mathf.Clamp(transform.position.x, field.minX + 1.3f, field.maxX - 1.3f); clampedPosition.y = Mathf.Clamp(transform.position.y, field.minY + 1.60f, field.maxY - 1.05f); transform.position = clampedPosition; } GameObject player = GameObject.Find("Steve_Square"); ScoreScript steve = player.GetComponent <ScoreScript>(); if (steve.score == 3) { gameObject.GetComponent <SpriteRenderer>().enabled = false; gameObject.GetComponent <SteveScript>().enabled = false; } HealthScript health = player.GetComponent <HealthScript>(); if (health.hp <= 1) { gameObject.GetComponent <SpriteRenderer>().enabled = false; gameObject.GetComponent <SteveScript>().enabled = false; } GameObject clock = GameObject.Find("Timer"); TimerScript t = clock.GetComponent <TimerScript>(); if (t.timer >= t.limit) { gameObject.GetComponent <SpriteRenderer>().enabled = false; gameObject.GetComponent <SteveScript>().enabled = false; } }
// Update is called once per frame void Update() { //references to other scripts for time/spawning of food etc GameObject Manage = GameObject.Find("_Manager"); TimerScript timerscript = Manage.GetComponent <TimerScript>(); SpawnBlob spawnfood = Manage.GetComponent <SpawnBlob>(); float timetest = timerscript.Timer; //Coroutines if (!inCoroutine) { StartCoroutine(Coroutine()); } if (!testCoroutine) { StartCoroutine(Couroutine2()); } //Ratio for speed (higher speed = more energy consumption speedmultiplier = navMeshAgent.speed / 3.5f; //if creature has a higher speed, make them consume more energy else run as normal if (fasterspeed == true) { distanceTravelled += (Vector3.Distance(transform.position, lastPosition)) * speedmultiplier; } else { distanceTravelled += Vector3.Distance(transform.position, lastPosition); } lastPosition = transform.position; //Try for mutation at end of day, and Reset values if (timetest == 60) { distanceTravelled = 0; foodcount = 0; outofenergy = false; fooddetected = false; if (mutated == false) { Mutate(); mutated = true; } } //if time is up and creature has 2 pieces of food duplicate it if (timetest == 58 && foodcount >= 2 && reproduced == false) { foodcount = 0; Instantiate(Blob, new Vector3(15, 1, 0), transform.rotation); //Debug.Log("i have reproduced"); reproduced = true; } //destroy remaining food and spawn new ones if (timetest == 60 && fooddeleted == false) { GameObject[] allObjects = GameObject.FindGameObjectsWithTag("Food"); foreach (GameObject obj in allObjects) { Destroy(obj); } spawnfood.SpawnFood(); fooddeleted = true; } //reset temp bool if (timetest == 1) { fooddeleted = false; mutated = false; reproduced = false; recordadded = false; hunting = false; } //no food = death if (timetest == 57 && foodcount == 0) { Destroy(Blob); //Debug.Log("I have died"); } //add record to excel spreadsheet if (timetest == 55) { if (recordadded == false) { addtest(navMeshAgent.speed, energy); recordadded = true; } } //creature is too fast, no more mutations if (navMeshAgent.speed > 10) { toofast = true; } //check if creature and food are in same place(to eat it) foodcheck(); }
// Use this for initialization void Start() { myView = GetComponent<PhotonView>(); GameObject ClockObject = GameObject.FindGameObjectWithTag("timer"); ServerTimer = ClockObject.GetComponent<TimerScript>(); }
// Start is called before the first frame update void Start() { numProblemsSolved = 0; source = GetComponent <AudioSource>(); timerScript = timer.GetComponent <TimerScript>(); }
private void Awake() { timer = GameObject.Find("Timer").GetComponent <TimerScript>(); PlayerScript.OnPlayerDeath += OnPlayerDeath; this.OnGameOver += OnGAMEOVER; }
public void Restart() { m_Timer = GameObject.Find("/TimerController").GetComponent <TimerScript>(); m_Timer.StartTimer(); }
private void Awake() { timerScript = TimerScript.Instance; informationManagerScript = InformationManagerScript.Instance; UpdatePosition(); }
// Use this for initialization void Start() { timerScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <TimerScript> (); timerScript.stop(); }
private void Awake() { data = GameObject.Find("DataCollector").GetComponent <DataCollector>(); http = GameObject.Find("Http").GetComponent <HTTPController>(); timer = GameObject.Find("Timer").GetComponent <TimerScript>(); }
// Start is called before the first frame update void Start() { sceneScript = Camera.main.GetComponent <SceneScript>(); timerScript = GetComponent <TimerScript>(); }
// Use this for initialization void Start() { ts = TimerObject.GetComponent<TimerScript>(); displayTime = GetComponent<Text>(); }
// Use this for initialization void Start() { flag = true; component = gameObject.GetComponent <TimerScript> (); }
void Awake() { instance = this; }
private void GetDependencies() { gameplayScript = GameObject.FindObjectOfType <GameplayScript>(); timerScript = GameObject.FindObjectOfType <TimerScript>(); fieldLabelsScript = GameObject.FindObjectOfType <FieldLabelsScript>(); }
bool inBounds() { Vector3 curPosition = mBody.position; Vector3 endPosition = positions[streetPieceCounter % NUM_ROADS_IN_GAME]; Vector3 nextEndPosition = positions[(streetPieceCounter + 1) % NUM_ROADS_IN_GAME]; // North is z+, South is z-, East is x+, West is x- Direction nextDir = directions[streetPieceCounter % NUM_ROADS_IN_GAME]; // Debug.Log("nextDir: " + nextDir); // Debug.Log("currentDir: " + playerDir); // Debug.Log("curPosition: " + curPosition); // Debug.Log("endPosition: " + endPosition); // Debug.Log("nextEndPosition: " + nextEndPosition); // Debug.Log("ROAD INDEX: " +roadIndex); // Debug.Log("streetPieceCounter " + streetPieceCounter); if (helpOn) { Direction nextNextDir = directions[(streetPieceCounter + 1) % NUM_ROADS_IN_GAME]; if (nextNextDir != playerDir) // if next next piece is a turn { if (playerDir == Direction.North) { if ((curPosition.z - (nextEndPosition.z + 2.5)) > -18) { TimerScript.startTimer(2f); } } else if (playerDir == Direction.South) { if ((curPosition.z - (nextEndPosition.z - 2.5)) < 18) { TimerScript.startTimer(2f); } } else if (playerDir == Direction.East) { if ((curPosition.x - (nextEndPosition.x + 2.5)) > -18) { TimerScript.startTimer(2f); } } else if (playerDir == Direction.West) { if ((curPosition.x - (endPosition.x - 2.5)) < 18) { TimerScript.startTimer(2f); } } } } if (nextDir != playerDir) // if the next piece is a turn { if (playerDir == Direction.North) { if ((curPosition.z - (endPosition.z + 2.5)) > 0) // past the point { return(false); } } else if (playerDir == Direction.South) { if ((curPosition.z - (endPosition.z - 2.5)) < 0) { return(false); } } else if (playerDir == Direction.East) { if ((curPosition.x - (endPosition.x + 2.5)) > 0) { return(false); } } else if (playerDir == Direction.West) { if ((curPosition.x - (endPosition.x - 2.5)) < 0) { return(false); } } } else // if we are going straight, need to be able to increment // streetPieceCounter once we pass a piece { if (playerDir == Direction.North) { if ((curPosition.z - endPosition.z) > 0) // past the point { streetPieceCounter++; } } else if (playerDir == Direction.South) { if ((curPosition.z - endPosition.z) < 0) { streetPieceCounter++; } } else if (playerDir == Direction.East) { if ((curPosition.x - endPosition.x) > 0) { streetPieceCounter++; } } else if (playerDir == Direction.West) { if ((curPosition.x - endPosition.x) < 0) { streetPieceCounter++; } } } // check side boundaries // pieces are 5 units wide return(true); }
private void OnEnable() { Instance = this; t_OriginalColor = m_DisplayTxt.color; }
public void PrevBtnClicked() { if (startIndex != 1 && startIndex != 8) { CantTouchPage.SetActive(true); prev_or_next = false; Transform tempTransform = gameObject.transform; StopCoroutine(TimerScript.StopWatchStart()); startIndex--; if (((startIndex == 2) && (word_count > 1)) || ((startIndex == 1) && (word_count > 1) && gameObject.transform.Find("Study3").gameObject.activeSelf)) { tempTransform.Find(page[startIndex + 1]).gameObject.SetActive(false); startIndex = 6; word_count--; StudyText[1].text = ps.parse_Attribute[2 + word_count - 1]; StudyText[2].text = ps.parse_Attribute[6 + 2 * (word_count - 1)]; StudyText[3].text = ps.parse_Attribute[7 + 2 * (word_count - 1)].Split(';')[0]; StudyText[4].text = ps.parse_Attribute[7 + 2 * (word_count - 1)].Split(';')[1]; StudyText[5].text = ps.parse_Attribute[7 + 2 * (word_count - 1)].Split(';')[2]; for (int i = 0; i < ps.tempSpriteList.Count; i++) { if (sentence_count + "_1" == ps.tempSpriteList[i].name) { StudyImage[0].sprite = ps.tempSpriteList[i]; StudyImage[5].sprite = ps.tempSpriteList[i]; StudyImage[1].sprite = ps.tempSpriteList[i]; StudyImage[2].sprite = ps.tempSpriteList[i]; StudyImage[3].sprite = ps.tempSpriteList[i]; StudyImage[4].sprite = ps.tempSpriteList[i]; } } tempTransform.Find(page[startIndex]).gameObject.SetActive(true); word_length = StudyText[1].text.Length; } else if (startIndex == 1) { tempTransform.Find(page[startIndex + 2]).gameObject.SetActive(false); tempTransform.Find(page[startIndex]).gameObject.SetActive(true); } else if (startIndex == 2) { tempTransform.Find(page[startIndex + 1]).gameObject.SetActive(false); tempTransform.Find(page[startIndex - 1]).gameObject.SetActive(true); startIndex--; } else if (startIndex == 3) { tempTransform.Find(page[startIndex + 1]).gameObject.SetActive(false); startIndex--; tempTransform.Find(page[startIndex + 1]).gameObject.SetActive(true); tempTransform.Find(page[startIndex]).gameObject.SetActive(true); } else { tempTransform.Find(page[startIndex + 1]).gameObject.SetActive(false); tempTransform.Find(page[startIndex]).gameObject.SetActive(true); } SlotScript.moveCount = 0; } CantTouchPage.SetActive(false); }
// Use this for initialization void Start() { canvas = GameObject.Find("Canvas"); timer = canvas.GetComponent <TimerScript> (); Shield = false; }
public void Init(TimerScript timer) { this.timer = timer; }
// Use this for initialization void Start() { timer = GameObject.Find("Timer"); timerScript = timer.GetComponent <TimerScript>(); }
void Awake() { instance = this; gameOver = false; }
void Start() { int x; int y; int z; int axis; yOffset = 1F; Transform blockInstance; BlockScript blockScript; ConnectorScript connectorScript; Transform connectorInstance; TextMesh textMesh; this.gameView = "menu"; this.options = this.gameObject.GetComponent ("OptionsScript") as OptionsScript; this.timer = this.gameObject.GetComponent ("TimerScript") as TimerScript; this.sizeGUI(); this.options.InitOptions(); //setup audio sources AudioSource[] audioSources = GetComponents<AudioSource>(); this.swipeAudioSource = audioSources[0]; this.collideAudioSource = audioSources[1]; this.collideAudioSource.clip = this.collideSound; //instantiate the blocks and connectors and position them for (x = 0; x <= 2; x++) { for (y = 0; y <= 2; y++) { for (z = 0; z <= 2; z++) { //instantiate the block blockInstance = Instantiate (block, new Vector3(x * this.scale, y * this.scale + this.yOffset, z * this.scale), Quaternion.identity) as Transform; this.blocks[x,y,z] = blockInstance; blockScript = blockInstance.gameObject.GetComponent("BlockScript") as BlockScript; blockScript.Initialize(x,y,z,this); } } } // instantiate the connectors for (x = 0; x <= 2; x++) { for (y = 0; y <= 2; y++) { for (z = 0; z <= 2; z++) { //instantiate the x connector connectorInstance = Instantiate (connector) as Transform; connectorScript = connectorInstance.gameObject.GetComponent("ConnectorScript") as ConnectorScript; connectorScript.Initialize(x,y,z,"x", this); this.connectors[x,y,z,0] = connectorInstance; //instantiate the y connector connectorInstance = Instantiate (connector) as Transform; connectorScript = connectorInstance.gameObject.GetComponent("ConnectorScript") as ConnectorScript; connectorScript.Initialize(x,y,z,"y", this); this.connectors[x,y,z,1] = connectorInstance; //instantiate the z connector connectorInstance = Instantiate (connector) as Transform; connectorScript = connectorInstance.gameObject.GetComponent("ConnectorScript") as ConnectorScript; connectorScript.Initialize(x,y,z,"z", this); this.connectors[x,y,z,2] = connectorInstance; } } } //instantiate the move blocks if (PlayerPrefs.HasKey ("game_status")) { this.loadSavedGame(); } else { this.restart (); } }
void Awake() { m_Timer = FindObjectOfType<TimerScript>(); m_scoreScript = GameManager.GetGameRules().GetScoreScript(); }
// Use this for initialization void Start() { // save screen edges in world coordinates float screenZ = -Camera.main.transform.position.z; Vector3 lowerLeftCornerScreen = new Vector3(0, 0, screenZ); Vector3 upperRightCornerScreen = new Vector3( Screen.width, Screen.height, screenZ); Vector3 lowerLeftCornerWorld = Camera.main.ScreenToWorldPoint(lowerLeftCornerScreen); Vector3 upperRightCornerWorld = Camera.main.ScreenToWorldPoint(upperRightCornerScreen); screenLeft = lowerLeftCornerWorld.x; screenRight = upperRightCornerWorld.x; screenTop = upperRightCornerWorld.y; screenBottom = lowerLeftCornerWorld.y; screenMiddle = screenLeft + (screenRight / 2); // create timer fireTimer = gameObject.AddComponent<TimerScript>(); // cache rb2D = GetComponent<Rigidbody2D>(); carSprite = GetComponent<BoxCollider2D>().size; //roadSprite = (RectTransform)road.transform; roadDim = road.GetComponent<MeshRenderer>().bounds.size; // initialize calzones carried if (UnityEngine.SceneManagement.SceneManager.GetActiveScene ().name == "Tutorial") { calzoneCount = 99; } else { calzoneCount = 10; } }