private void OnTriggerExit(Collider other) { if (!other.name.StartsWith("Bottom")) { return; } GameObject parent = other.transform.parent.gameObject; if (parent == null) { return; } GameObject grandparent = parent.transform.parent.gameObject; if (grandparent == null) { return; } BalloonMovement balloon = grandparent.GetComponent <BalloonMovement>(); balloon.multiplier = 1f; }
// Update is called once per frame void Update() { float x = GameObject.FindObjectOfType <BalloonMovement>().transform.position.x; float z = GameObject.FindObjectOfType <BalloonMovement>().transform.position.z; float rot = transform.eulerAngles.y; BalloonMovement balloon = GameObject.FindObjectOfType <BalloonMovement>(); if (x > 0 && z > 0 && GoalAngle == 90) { GoalAngle = 180; balloon.switchControls(); } else if (x <= 0 && z > 0 && GoalAngle == 0) { GoalAngle = 90; balloon.switchControls(); } else if (x <= 0 && z <= 0 && GoalAngle == 270) { GoalAngle = 0; balloon.switchControls(); } else if (x > 0 && z <= 0 && GoalAngle == 180) { GoalAngle = 270; balloon.switchControls(); } float newRot = Mathf.LerpAngle(rot, GoalAngle, Time.deltaTime * speed); transform.rotation = Quaternion.Euler(0, newRot, 0); }
public void SetBalloonfeatures(float _size, float _speed) { for (int i = 0; i < m_balloonPool.Count; i++) { BalloonMovement Temp = m_balloonPool[i].GetComponent <BalloonMovement>(); Temp.SetSize(_size); Temp.SetSpeed(_speed); } }
// Use this for initialization void Start() { control = GameObject.Find("Controller"); controlScript = control.GetComponent <Controller>(); balMove = control.GetComponent <BalloonMovement>(); source = GetComponent <AudioSource>(); collided = false; spriteRender = GetComponent <SpriteRenderer> (); cirCol = GetComponent <CircleCollider2D> (); }
//adjusts balloon speed as it approaches a torch private void OnTriggerStay(Collider other) { if (!other.name.StartsWith("Bottom")) { return; } GameObject parent = other.transform.parent.gameObject; if (parent == null) { return; } GameObject grandparent = parent.transform.parent.gameObject; if (grandparent == null) { return; } BalloonMovement balloon = grandparent.GetComponent <BalloonMovement>(); Vector3 balloonPos = grandparent.transform.position; Vector3 torchPos = lightPoint.position; float dist = (balloonPos - torchPos).magnitude; Debug.Log("dist = " + dist.ToString()); if (dist > collRad) { balloon.multiplier = 1f; } else if (minSpeedRadius < dist && dist < collRad) { float rise = 1f - minSpeed; float run = collRad - minSpeedRadius; float m = rise / run; float y1 = 1f; float x = dist; float x1 = collRad; balloon.multiplier = m * (x - x1 + (y1 / m)); } else if (dist < minSpeedRadius) { balloon.multiplier = minSpeed; } Debug.Log("multiplier = " + balloon.multiplier.ToString()); }
// Update is called once per frame void Update() { if (control == null) { control = GameObject.Find("Controller"); controlScript = control.GetComponent <Controller>(); } if (balMove == null) { balMove = control.GetComponent <BalloonMovement>(); } //Set up variables from playerprefs for the balloon if (!updated) { name = "Row" + row + "Balloon" + index; //Set up correct name for saving purposes if (PlayerPrefs.HasKey(name)) //Load from playerprefs { if (PlayerPrefs.GetInt(name) == 1) { popped = false; turnOn(); } else { popped = true; turnOff(); alreadyOff = true; } updated = true; } else //New game { PlayerPrefs.SetInt(name, 1); popped = false; updated = true; } } if (spriteRender == null || cirCol == null) { spriteRender = GetComponent <SpriteRenderer> (); cirCol = GetComponent <CircleCollider2D> (); } else { if (!alreadyOff) { if (popped) { turnOff(); alreadyOff = true; } } } if (SmScript.gameManager.showingAd) //Stop music playing before an ad { if (source.isPlaying) { source.Stop(); } } }
void Start() { GameEvents.GameEventManager.registerListener(this); balloon = GetComponent<BalloonMovement>(); }