void Start() { GameObject tempObj = GameObject.Find("Character"); scriptInstance = tempObj.GetComponent <RCharacter>(); GameObject tempObj2 = GameObject.Find("Sphere"); scriptCantouch = tempObj2.GetComponent <RNewBehaviourScript>(); }
// Start is called before the first frame update void Start() { AudioListener.volume = PlayerPrefs.GetFloat("volume", 1.0f); GameObject tempObj = GameObject.Find("Sphere"); scriptInstance6 = tempObj.GetComponent <RNewBehaviourScript>(); GameObject tempObj2 = GameObject.Find("Character"); scriptInstance5 = tempObj2.GetComponent <RCharacter>(); MusicSource4.clip = clip4; }
void Start() { AudioListener.volume = PlayerPrefs.GetFloat("volume", 1.0f); CanvasObject.GetComponent <Canvas>().enabled = false; GameObject tempObj = GameObject.Find("Character"); scriptInstance8 = tempObj.GetComponent <RCharacter>(); GameObject tempObj2 = GameObject.Find("Timer"); scriptInstance7 = tempObj2.GetComponent <RTimerEasy>(); MusicSource3.clip = clip3; }
private void Update() { //if moveontonextround=true then i=0 GameObject tempObj = GameObject.Find("Character"); script2Instance = tempObj.GetComponent <RCharacter>(); if (script2Instance.MoveOnToNextRound == true) { i = 0.0f; x = 0; m = 0; hasArrived = false; canMove = false; secondround = true; timer = 0f; moves123 += 0.2f; movementDuration -= 0.05f; if (movementDuration <= 1.1f) { movementDuration = 1.1f; } VenomSpell.Stop(); endParticle = true; if (moves123 < 0) { randomO = 1; vertical = true; Debug.Log(randomO); } if (moves123 >= 5) { randomO = Random.Range(0, 2); Debug.Log(randomO); GameObject PlaneObj = GameObject.Find("Plane"); if (randomO == 1) //vertical { if (vertical == false) { PlaneObj.transform.Rotate(0, 90, 0, Space.World); vertical = true; } else { PlaneObj.transform.Rotate(0, 0, 0, Space.World); vertical = true; } } if (randomO == 0) //horizontal { if (vertical == false) { PlaneObj.transform.Rotate(0, 0, 0, Space.World); vertical = false; } else { PlaneObj.transform.Rotate(0, 90, 0, Space.World); vertical = false; } } } script2Instance.MoveOnToNextRound = false; } if (!hasArrived && i == 0.0f) //1st round 1st move, not origin, 2nd round 2nd move, not same { gameObject.GetComponent <Renderer>().enabled = true; //gameObject.GetComponent<Renderer>().material.color = new Color(147, 176, 145, 255); // make ball original colour hasArrived = true; { float randX = Random.Range(0, 3); float randZ = Random.Range(0, 3); if (secondround == false && randX == 0 && randZ == 0) { randX = Random.Range(1, 3); randZ = Random.Range(0, 3); } if (secondround == true) { while (EscapeLoop == 0) { arrayList2x.Add(randX); arrayList2z.Add(randZ); if (arrayList2x[0].Equals(arrayListx[arrayListx.Count - 1]) && (arrayList2z[0].Equals(arrayListz[arrayListz.Count - 1]))) //change depending on moves { arrayList2x.RemoveAt(arrayList2x.Count - 1); //??? arrayList2z.RemoveAt(arrayList2z.Count - 1); //??? randX = Random.Range(1, 3); randZ = Random.Range(0, 3); //arrayList2x.Clear(); //arrayList2z.Clear(); EscapeLoop = 0; } else { EscapeLoop = 1; } } } arrayList2x.Clear(); arrayList2z.Clear(); arrayListx.Clear(); arrayListz.Clear(); arrayListx.Add(randX); arrayListz.Add(randZ); //change move to teleport //StartCoroutine(MoveToPoint(new Vector3(randX, 0, randZ))); VenomSpell.Play(); ParticleSystem.Play(); StartCoroutine(Wait()); transform.position = new Vector3(randX, 0, randZ); if (randomO == 0) { Vector3 newPosition; newPosition = gameObject.transform.position; newPosition[2] = 2 - newPosition[2]; //convert to negative coordinates arrayList.Add(newPosition); } if (randomO == 1) { Vector3 newPosition; newPosition = gameObject.transform.position; newPosition[0] = 2 - newPosition[0]; //convert to negative coordinates arrayList.Add(newPosition); } } } if (!hasArrived && i >= 1.0f && i < Mathf.Floor(moves123)) //2nd move onwards,no repeat { hasArrived = true; { float randX = Random.Range(0, 3); float randZ = Random.Range(0, 3); arrayListx.Add(randX); arrayListz.Add(randZ); //Debug.Log(arrayListx[x]); //Debug.Log(arrayListx[x + 1]); //Debug.Log(arrayListz[x]); //Debug.Log(arrayListz[x + 1]); while (EscapeLoop == 0) { if (arrayListx[x].Equals(arrayListx[x + 1]) && (arrayListz[x].Equals(arrayListz[x + 1]))) { //HAVE TO REMOVE THE ADDED X AND Z //generate a new random arrayListx.RemoveAt(arrayListx.Count - 1); arrayListz.RemoveAt(arrayListz.Count - 1); randX = Random.Range(1, 3); randZ = Random.Range(0, 3); arrayListx.Add(randX); arrayListz.Add(randZ); EscapeLoop = 0; } else { x += 1; EscapeLoop = 1; } } StartCoroutine(MoveToPoint(new Vector3(randX, 0, randZ))); } } if (!hasArrived && i == Mathf.Floor(moves123)) //change depending on number of moves { //have to change previous if i value also script2Instance.touchytouchy = true; timer += Time.deltaTime; if (timer < timerMax && endParticle == true) { gameObject.GetComponent <Renderer>().enabled = false; endParticle = false; } if (timer >= timerMax) { canMove = true; //gameObject.GetComponent<Renderer>().material.color = new Color(147, 176, 145, 0); //make ball transparent hasArrived = true; } } }