void Update() { SR.color = GameFunction.getColor(SR.color.r, SR.color.g, SR.color.b, Weather.instance.SmoothLerp_LightAlpha(Day_Alpha, Night_Alpha) - deltaMinus); //随时间变化透明度 if (WeatherData.getIntance().currentWeather != lastWeather && WeatherData.getIntance().currentWeather != weather.Sunny && lastWeather == weather.Sunny) //当天气不为晴天的一刻 { deltaMinus = 0; _time0 = 0; } if (WeatherData.getIntance().currentWeather != lastWeather && WeatherData.getIntance().currentWeather == weather.Sunny) //当天气为晴天的一刻 { deltaMinus = 1; _time0 = 0; } if (WeatherData.getIntance().currentWeather != weather.Sunny) { _time0 += Time.deltaTime; deltaMinus = Mathf.Lerp(0, 1, _time0 / (WeatherData.getIntance().Weather_duration * 0.1f)); } if (WeatherData.getIntance().currentWeather == weather.Sunny) { _time0 += Time.deltaTime; deltaMinus = Mathf.Lerp(1, 0, _time0 / (WeatherData.getIntance().Weather_duration * 0.1f)); } GameFunction.m_Color = SR.color; GameFunction.m_Color.a *= (1 + Mathf.Lerp(-0.8f, 0.1f, noiseTex.GetPixel(2, ((int)(Time.time * flashSpeed) + random) % noiseTex.width).r * 0.5f + 0.25f)); SR.color = GameFunction.m_Color; lastWeather = WeatherData.getIntance().currentWeather; }
/// <summary> /// 生成纹理 /// </summary> void GenTexture() { if (Size == 0 || gridSize == 0) { return; } Perlin perlin = new Perlin(gridSize); Texture2D texture = new Texture2D(Size, Size); float a = Size / gridSize; for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { float t = noise(GameFunction.getVector2(i / a, j / a), perlin); t = 0.5f * t + 0.5f; texture.SetPixel(i, j, GameFunction.getColor(t, t, t, 1)); } } texture.Apply(); FileStream fs = new FileStream(Application.dataPath + "/" + textureName + ".jpg", FileMode.Create); byte[] data = texture.EncodeToJPG(); fs.Write(data, 0, data.Length); fs.Flush(); fs.Close(); Debug.Log("生成成功"); }
IEnumerator IE_beBurn() { isBurning = true; Attribute originAttr = ElementTrigger.element; ElementTrigger.element = Attribute.fire; float burnTime = 5; float Timer_1 = 0; //开始 while (Timer_1 < burnTime * 0.1f) { Timer_1 += Time.deltaTime; float t = Timer_1 / (burnTime * 0.1f); //渐变动画 SR.color = Color.Lerp(Color.white, GameFunction.getColor(1, 0.48f, 0.48f, 1), t); yield return(null); } //持续 Timer_1 = 0; while (Timer_1 < burnTime) { Timer_1 += Time.deltaTime; if (ElementTrigger.isContainElement(Attribute.ice) || isInRain) { break; } yield return(null); } //结束 Timer_1 = 0; while (Timer_1 < burnTime * 0.1f) { Timer_1 += Time.deltaTime; float t = Timer_1 / (burnTime * 0.1f); //渐变动画 SR.color = Color.Lerp(GameFunction.getColor(1, 0.48f, 0.48f, 1), Color.white, t); yield return(null); } isBurning = false; ElementTrigger.element = originAttr; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.transform.tag == "arms_player") //被打击增加弹性 { SR.color -= GameFunction.getColor(0, 0.25f, 0.25f, 0); correctSR_Color(); speed *= add_Sccale; animator.SetTrigger("beHit"); if (!b_cooling) { StartCoroutine(cooling()); } } }
IEnumerator halo() { float alpha_start = 0.7f; float duration = 0.28f, _time1 = 0; while (true) { _time1 += Time.deltaTime; Halo.color = GameFunction.getColor(Halo.color.r, Halo.color.g, Halo.color.b, Mathf.Lerp(alpha_start, 1, _time1 / duration)); Halo.gameObject.transform.localScale = Vector3.Lerp(Vector3.one * 3, Vector3.zero, _time1 / duration); _light.range = Mathf.Lerp(light_rest_range, origin_range, _time1 / duration); if (_time1 > duration) { break; } yield return(null); } Rest = false; SR.color = Color.white; }
private void FixedUpdate() { //金光闪闪动画 if (isEnable) { b += Time.deltaTime; a = Mathf.Sin(b * 5); if (a > 0) { bl_SR.transform.localScale = a * originScale_bl; bl_SR.color = GameFunction.getColor(bl_SR.color.r, bl_SR.color.g, bl_SR.color.b, a); } if (last_a > 0 && a < 0) { randomOffset.x = Random.Range(-coin_SR.bounds.extents.x, coin_SR.bounds.extents.x); randomOffset.y = Random.Range(-coin_SR.bounds.extents.y, coin_SR.bounds.extents.y); bl_SR.transform.position = coin_SR.bounds.center + randomOffset; } last_a = a; } }
private void OnCollisionEnter2D(Collision2D collision) { if (!isOther) { bool isColl = true; for (int i = 0; i < collision.contacts.Length; i++) { if (_dir == dir.top) { if (collision.contacts[i].point.y < coll.bounds.center.y) //是否是来自碰撞器顶部 { isColl = false; break; } } if (_dir == dir.left) { if (collision.contacts[i].point.x > coll.bounds.center.x) { isColl = false; break; } } if (_dir == dir.down) { if (collision.contacts[i].point.y > coll.bounds.center.y) { isColl = false; break; } } if (_dir == dir.right) { if (collision.contacts[i].point.x < coll.bounds.center.x) { isColl = false; break; } } } if (isColl) { if (collision.transform.tag == "Player") { animator.SetBool("isPop", true); CharacterControl.instance.bounce(time, speed, _dir); } } } if (isOther) { animator.SetBool("isPop", true); } if (collision.transform.tag == "arms_player") //被打击增加弹性 { SR.color -= GameFunction.getColor(0, 0.25f, 0.25f, 0); correctSR_Color(); Behavior_beAttacked(collision.contacts[0].point, backSpeed); speed *= add_Sccale; animator.SetTrigger("beHit"); if (!b_cooling) { StartCoroutine(cooling()); } } }