// Start is called before the first frame update void Start() { Character Player1 = Character1.GetComponent <Character>(); Character Player2 = Character2.GetComponent <Character>(); Character Player3 = Character3.GetComponent <Character>(); Character Player4 = Character4.GetComponent <Character>(); Enemy Enemy1 = EnemyBattler.GetComponent <Enemy>(); //Jag vet inget mer effektivt sätt att samla allt i en Public lista än det här CharacterList.Add(Player1); CharacterList.Add(Player2); CharacterList.Add(Player3); CharacterList.Add(Player4); EnemyList.Add(Enemy1); PositionList.Add(Character1); PositionList.Add(Character2); PositionList.Add(Character3); PositionList.Add(Character4); attackButton.onClick.AddListener(Attack); skillButton.onClick.AddListener(Skills); personaButton.onClick.AddListener(Personas); guardButton.onClick.AddListener(Guard); cancel.onClick.AddListener(Cancel); dataHandler = dataHandlerOBJ.GetComponent <Ownership>(); }
void Start() { GameObject tempObj = GameObject.Find("Character"); scriptInstance = tempObj.GetComponent <Character3>(); GameObject tempObj2 = GameObject.Find("Sphere"); scriptCantouch = tempObj2.GetComponent <NewBehaviourScript3>(); }
// 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 <NewBehaviourScript3>(); GameObject tempObj2 = GameObject.Find("Character"); scriptInstance5 = tempObj2.GetComponent <Character3>(); 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 <Character3>(); GameObject tempObj2 = GameObject.Find("Timer"); scriptInstance7 = tempObj2.GetComponent <TimerCrazy>(); MusicSource3.clip = clip3; }
private void Update() { //if moveontonextround=true then i=0 GameObject tempObj = GameObject.Find("Character"); script2Instance = tempObj.GetComponent <Character3>(); if (script2Instance.MoveOnToNextRound == true) { i = 0.0f; x = 0; m = 0; hasArrived = false; canMove = false; secondround = true; timer = 0f; moves123 += 0.2f; PlayerPrefs.SetFloat("moves123", moves123); movementDuration -= 0.05f; Debug.Log(movementDuration); if (movementDuration <= 0.6f) { movementDuration = 0.6f; } PlayerPrefs.SetFloat("movementDuration", movementDuration); VenomSpell.Stop(); endParticle = true; if (moves123 < 0) { randomO = 1; vertical = true; Debug.Log(randomO); } if (moves123 >= 1) { 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 <Light>().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] = 3 - newPosition[2]; //convert to negative coordinates arrayList.Add(newPosition); } if (randomO == 1) { Vector3 newPosition; newPosition = gameObject.transform.position; newPosition[0] = 3 - 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; gameObject.GetComponent <Light>().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; } } }