// Use this for initialization void Start() { go = GameObject.Find("Master"); music = GameObject.Find("MainMusic"); music.GetComponent<MusicControl>().ChangeMusic("beware_theme"); //Level 10 boss Music mini = endGame = false; levelRunning = true; posx = offset = 0; posy = speed = 2; health = 25; pop = (AudioSource)gameObject.AddComponent<AudioSource>(); userHealthColor = Color.green; screenW = Screen.width; screenH = Screen.height; go.GetComponent<CountPopped>().increaseMaxCustom(health); other = (CountPopped)go.GetComponent(typeof(CountPopped)); SpriteRenderer balloonSR = gameObject.AddComponent<SpriteRenderer>(); Sprite var = Resources.Load<Sprite>("Balloon/Black"); try { balloonSR.sprite = var; } catch (NullReferenceException e) { //Who cares? } balloonColors = new String[8]; balloonColors[0] = "Balloon/Blue"; balloonColors[1] = "Balloon/Green"; balloonColors[2] = "Balloon/Pink"; balloonColors[3] = "Balloon/Red"; balloonColors[4] = "Balloon/Yellow"; balloonColors[5] = "Balloon/Orange"; balloonColors[6] = "Balloon/Purple"; balloonColors[7] = "Balloon/Light-Blue"; healthUserTexture = new Texture2D(2, 2, TextureFormat.ARGB32, false); healthUserTexture.Apply(); }
// Use this for initialization void Start () { int planet = Random.Range(0, 1); int num = Random.Range(1, 12); string zero = ""; go = GameObject.Find("Master"); other = (CountPopped)go.GetComponent(typeof(CountPopped)); other.SetBackNum(num); if (num < 10) { zero = "0"; } if(planet == 1) { this.GetComponent<MeshRenderer>().material = Resources.Load("SkySphere/Materials/With_Planet/Planet_" + zero + num.ToString(), typeof(Material)) as Material; other.SetHasPlanet(true); } else { this.GetComponent<MeshRenderer>().material = Resources.Load("SkySphere/Materials/Without_Planet/Sky_" + zero + num.ToString(), typeof(Material)) as Material; other.SetHasPlanet(false); } }
// Update is called once per frame void Update() { Vector3 targetPosition = new Vector3(posx, posy, posz); Vector3 targetOffset = new Vector3(0, 0, 0); Vector3 currentPosition = this.transform.position; if (UnityEngine.Random.Range(0, (16 - Application.loadedLevel)) == 0) { if (UnityEngine.Random.Range(0, 1) == 0) { targetOffset += new Vector3(10, 0, 0); //right posx = UnityEngine.Random.Range(-4, 4); } else { targetOffset += new Vector3(-10, 0, 0); //left posx = UnityEngine.Random.Range(-4, 4); } } //first, check to see if we're close enough to the target if (Vector3.Distance(currentPosition, targetPosition) > .1f) { Vector3 directionOfTravel = targetPosition - currentPosition + targetOffset; //now normalize the direction, since we only want the direction information directionOfTravel.Normalize(); //scale the movement on each axis by the directionOfTravel vector components this.transform.Translate( (directionOfTravel.x * speed * Time.deltaTime), (directionOfTravel.y * speed * Time.deltaTime), (directionOfTravel.z), Space.World); } if (this.transform.localScale.y > 5f || -GetTheHealth() < 1) //Fail the level { endGame = true; other = (CountPopped)go.GetComponent(typeof(CountPopped)); other.killUser(); levelRunning = false; } if (!mini && !endGame) { this.transform.localScale = new Vector3(this.transform.localScale.x * (1.001F + offset), this.transform.localScale.y * (1.001F + offset), 1); this.transform.GetComponent<SphereCollider>().radius = this.transform.GetComponent<SphereCollider>().radius * (1.0002F + offset); } }