void Update() { if (Random.Range(0, 500) > 499) // 1 in 500 chance of generating a cloud every frame { cloud = new CloudScript(); } }
void Awake() { lastButtonUsedIndex = 1; ev = FindObjectOfType <Enviroment>(); cloudScript = FindObjectOfType <CloudScript>(); skyColors = FindObjectOfType <SkyColors>(); parameters = new Parameters(); ev.isPaused = true; status = Status.Pause; bm_instance = this; }
// Use this for initialization void Start() { //mainCam = GameObject.FindWithTag("MainCamera"); //override cloud spawn range foreach (GameObject cloudGO in cloudPrefabs) { CloudScript cs = cloudGO.GetComponent <CloudScript>(); cs.minY = minY; cs.maxY = maxY; } //Begin SpawnClouds Coroutine StartCoroutine(SpawnClouds()); }
private void OnEnable() { if (CloudScript.CS == null) { CloudScript.CS = this; } else { if (CloudScript.CS != this) { Destroy(this.gameObject); } } DontDestroyOnLoad(this.gameObject); }
public override void OnNotify(Vector3 avgPos) { float speed = cloudEvent.GetLerpSpeed(); rainyDays = FindGameObjectsWithName("RainyDay(Clone)"); //TODO: Move original seed object rather than creating clones? if (rainyDays.Length > 0 && rainyDays[seedIndex] != null) { rainCloudPrefab = (CloudScript)rainyDays[seedIndex].GetComponent(typeof(CloudScript)); endPos = new Vector3(rainCloudPrefab.transform.position.x, 2.61f, rainCloudPrefab.transform.position.z); var seq = LeanTween.sequence(); seq.append(0.5f); // delay everything seq.append(LeanTween.move(this.cloudObj, endPos, speed).setEase(LeanTweenType.easeOutQuad)); // do a tween seq.append(() => { // fire event after tween this.cloudObj.gameObject.SetActive(false); merges += 1; if (merges == 5) { rainCloudPrefab.TriggerCLoudEvent(); seedIndex = rainyDays.Length - 1; merges = 0; } }); seq.append(() => { // fire event after tween if (rainCloudChild.activeState == false) { rainCloudParent.transform.position = endPos; rainCloudParent.transform.position += new Vector3(0, 2f, 0); rainCloudChild.activeState = true; } else { rainCloudChild.cloud.transform.localScale += new Vector3(1f, 1f, 1f); rainCloudChild.cloud.transform.position += new Vector3(0, 1f, 0); } }); } }
private void PoolCloud() { float _cloudHeight = Random.Range(_minHeight, _maxHeight); float _cloudSpeed = Random.Range(_minSpeed, _maxSpeed); Transform _tmpCloud = GetCloudFromPool(); _tmpCloud.position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0)); _tmpCloud.position = new Vector3(_tmpCloud.position.x + _cloudHideCreateOffset, _cloudHeight, 0); _tmpCloud.gameObject.SetActive(true); _cloud = _tmpCloud.GetComponent <CloudScript>(); _cloud.Speed = _cloudSpeed; _cloud.HideOffset = _cloudHideCreateOffset; _lastCloud = _tmpCloud; /// distance between last cloud and next cloud that will be generated _cloudDistance = Random.Range(1f / _maxCount, 1f / _minCount); _cloudDistance *= Screen.width; }
void Start() { ev = FindObjectOfType <Enviroment>(); cloudScript = FindObjectOfType <CloudScript>(); parameters = new Parameters(); }
public void replaceCloud(CloudScript script) { }
Vector3 startPosition; //used to cache the start position of the transform // Use this for initialization void Start() { bounceObject = this; startPosition = bounceObject.transform.position; }