void Start() { SR = this.GetComponent <SpriteRenderer>(); lastWeather = WeatherData.getIntance().currentWeather; random = Random.Range(0, 1000); noiseTex = ResourcesManagement.getInstance().getResources <Texture2D>("noise_readable"); }
IEnumerator IE_destory(GameObject Door1) { Door_1 t_Door_1 = Door1.GetComponent <Door_1>(); const float duration = 2f; float timer = 0; while (timer < duration) { timer += Time.deltaTime; float t = timer / duration; transform.position = Vector3.Lerp(transform.position, t_Door_1.Stone_trans.position + Vector3.back * 0.1f, t * 0.8f); effect.localScale = Vector3.Lerp(effect.localScale, Vector3.zero, t); yield return(null); } Instantiate(ResourcesManagement.getInstance().getResources <GameObject>("Effect_expand"), position: transform.position, rotation: Quaternion.Euler(Vector3.zero)); //特效 t_Door_1.Unlock(); //解锁 CharacterControl.instance.isGetDoor1_Key = false; Destroy(this.gameObject); }
/// <summary> /// 燃烧 /// </summary> /// <returns>null</returns> IEnumerator IE_burn() { GameFunction.t_Vector3 = transform.position; GameFunction.t_Vector3.z -= 0.01f; GameObject fire = Instantiate(ResourcesManagement.getInstance().getResources <GameObject>("Fire"), position: GameFunction.t_Vector3, rotation: Quaternion.Euler(Vector3.zero)) as GameObject; Bounds bounds_fire = fire.GetComponentInChildren <BoxCollider2D>().bounds; Vector3 originScale_fire; //适应图片比例 float scale_x = SR.bounds.size.x / bounds_fire.size.x; float scale_y = SR.bounds.size.y * 0.6f / bounds_fire.size.y; GameFunction.t_Vector3.x = scale_x * fire.transform.localScale.x; GameFunction.t_Vector3.y = scale_y * fire.transform.localScale.y; GameFunction.t_Vector3.z = transform.localScale.z; originScale_fire = GameFunction.t_Vector3; const float time_show = 0.4f; const float time_end = 0.2f; float timer = 0; //出现 while (timer < time_show) { timer += Time.deltaTime; float t = timer / time_show; fire.transform.localScale = Vector3.Lerp(Vector3.zero, originScale_fire, t); yield return(null); } timer = 0; MaterialPropertyBlock MB = new MaterialPropertyBlock(); bool isExtinguish = false; SR.GetPropertyBlock(MB); MB.SetColor("_BurnColor", burnColor); //燃烧持续 while (timer < burnTime) { timer += Time.deltaTime; burnedTime += Time.deltaTime; MB.SetFloat("_BurnScale", Mathf.Lerp(0, maxBurnScale, burnedTime / burnTime)); SR.SetPropertyBlock(MB); //熄灭 if (elementTrigger.isContainElement(Attribute.ice) || isInRain) { isExtinguish = true; break; } yield return(null); } timer = 0; //结束 while (timer < time_end) { timer += Time.deltaTime; float t = timer / time_end; fire.transform.localScale = Vector3.Lerp(originScale_fire, Vector3.zero, t); if (isExtinguish) { MB.SetColor("_BurnColor", Color.Lerp(burnColor, unBurnColor, t)); SR.SetPropertyBlock(MB); } yield return(null); } Instantiate(ResourcesManagement.getInstance().getResources <GameObject>("Smoke"), position: fire.transform.position, rotation: Quaternion.Euler(Vector3.zero)); if (isExtinguish) { Destroy(fire); fire = null; yield return(new WaitForSeconds(0.3f)); isBurn = false; } else { Destroy(this.gameObject); Destroy(fire); fire = null; } }