void Start() { foreach (Transform t in GetComponentsInChildren <Transform>()) { switch (t.name) { case "Particle": Particle = t.gameObject; break; case "Halo": Halo = t.gameObject; break; case "Soul": Soul = t.gameObject; break; default: break; } } originPos = transform.position; originPos_Halo = Halo.transform.position; if (isNone) { Halo.SetActive(false); Particle.SetActive(false); } }
IEnumerator IE_getEnergy() { isNone = true; Halo.SetActive(true); Halo.transform.parent = null; Halo.GetComponent <TrailRenderer>().enabled = true; //第一段动画 { float _time0 = 0; Vector3 _dir = Halo.transform.position - CharacterControl.instance.transform.position; Vector3 _dir_2 = Vector3.Cross(_dir, Vector3.back); _dir.z = 0; Vector3 p1, p2; p1 = Halo.transform.position + _dir * 0.9f; p2 = (CharacterControl.instance.transform.position + Halo.transform.position) / 2.0f + _dir_2 * 0.8f; p1.z = 0; p2.z = 0; while (_time0 < first_animation_duration) { _time0 += Time.deltaTime; float t = _time0 / first_animation_duration; Halo.transform.position = GameFunction.BezierLine(Halo.transform.position, CharacterControl.instance.transform.position + Vector3.up * 1, p1, p2, t); yield return(null); } } //第二段动画 { Energy.SetActive(false); float _time0 = 0; Vector3 originScale_Halo = Halo.transform.localScale; SpriteRenderer SR_BG = BG.GetComponent <SpriteRenderer>(); Color originColor_BG = SR_BG.color; SpriteRenderer SR_Stone = Stone.GetComponent <SpriteRenderer>(); Color originColor_Stone = SR_Stone.color; SpriteRenderer SR_Halo = Halo.GetComponent <SpriteRenderer>(); while (_time0 < second_animation_duration) { _time0 += Time.deltaTime; float t = _time0 / second_animation_duration; Halo.transform.localScale = Vector3.Lerp(originScale_Halo, Vector3.one * 10f, t); SR_Halo.color = Color.Lerp(SR_Halo.color, new Color(1, 1, 1, 0), t); SR_BG.color = Color.Lerp(originColor_BG, Color.black, t); SR_Stone.color = Color.Lerp(originColor_Stone, Color.black, t); yield return(null); } SR_BG.sortingOrder = 0; Stone.SetActive(false); Halo.SetActive(false); Particle.SetActive(false); } Bag.getInstance().AddArmsFragment(1); }
void Start() { foreach (Transform t in GetComponentsInChildren <Transform>()) { switch (t.name) { case "Soul": Soul = t.gameObject; break; case "Halo": Halo = t.gameObject; break; case "Bloom": Bloom = t.gameObject; break; case "Eye": Eye = t.gameObject; break; case "Eye2": Eye2 = t.gameObject; break; case "Particle": Particle = t.gameObject; break; case "Aperture": Aperture = t.gameObject; t.gameObject.SetActive(false); break; default: break; } } animator = GetComponent <Animator>(); originPos = transform.position; if (isNone) { Halo.SetActive(false); Eye.GetComponent <SpriteRenderer>().color = Color.white * 0.3f; Eye2.GetComponent <SpriteRenderer>().color = Color.white * 0.3f; Particle.SetActive(false); this.enabled = false; } }
void Start() { foreach (Transform t in GetComponentsInChildren <Transform>()) { switch (t.name) { case "BG": BG = t.gameObject; break; case "Stone": Stone = t.gameObject; break; case "Halo": Halo = t.gameObject; break; case "Energy": Energy = t.gameObject; break; case "Particle": Particle = t.gameObject; break; default: break; } } if (!isNone) { originPos_Stone = Stone.transform.position; originScale_Stone = Stone.transform.localScale; originPos = transform.position; } else { Particle.SetActive(false); Stone.SetActive(false); BG.GetComponent <SpriteRenderer>().color = Color.black; } Halo.SetActive(false); }
IEnumerator IE_getSoul() { isNone = true; Halo.GetComponent <TrailRenderer>().enabled = true; float _time0 = 0; Vector3 t_originPos_Halo = Halo.transform.position; Vector3 p1, p2; Vector3 _dir = Halo.transform.position - CharacterControl.instance.transform.position; Vector3 _dir_2 = Vector3.Cross(_dir, Vector3.back); _dir.z = 0; _dir_2.z = 0; p1 = Halo.transform.position + _dir * 2f; p2 = (CharacterControl.instance.transform.position + Halo.transform.position) / 2.0f + _dir_2 * 1f; p1.z = 0; p2.z = 0; while (_time0 < animation_duration) { _time0 += Time.deltaTime; float t = _time0 / animation_duration; Halo.transform.position = BezierLine(t_originPos_Halo, CharacterControl.instance.transform.position + Vector3.up, p1, p2, t); yield return(null); } CharacterAttribute.GetInstance().add_HP(CharacterAttribute.GetInstance().MaxHP); _time0 = 0; Soul.SetActive(false); SpriteRenderer t_SR = Halo.GetComponent <SpriteRenderer>(); while (_time0 < duration_expand) { _time0 += Time.deltaTime; float t = _time0 / duration_expand; Halo.transform.localScale = Vector3.Lerp(Halo.transform.localScale, Vector3.one * 6f, t); t_SR.color = Color.Lerp(t_SR.color, new Color(1, 1, 1, 0), t); yield return(null); } Particle.SetActive(false); Halo.SetActive(false); }
IEnumerator IE_getNewSoul() //获得新灵魂动画 { isAnimation = true; CharacterControl.instance.setInputNone(); yield return(new WaitForSeconds(first_animation_waitTime)); animator.enabled = false; Halo.GetComponent <TrailRenderer>().enabled = true; Particle.SetActive(false); Aperture.SetActive(true); { Vector3 targetPos = Halo.transform.position + new Vector3(0, first_animation_height, 0); Vector3 t_originPos = Halo.transform.position; Vector3 t_vec3 = Vector3.zero; SpriteRenderer t_SR = Aperture.GetComponent <SpriteRenderer>(); float _time0 = 0, _time1 = 0; const float Aperture_duration = 0.4f; while (_time0 < first_animation_duration) //第一段动画 { if (_time1 > 0.2f * Aperture_duration) { _time0 += (Time.deltaTime * ((first_animation_duration * 1.6f - _time0) / first_animation_duration)); } _time1 += Time.deltaTime; t_vec3 = Vector3.Lerp(t_originPos, targetPos, _time0 / first_animation_duration); t_vec3.x = Mathf.Sin(_time0 * 3) * 0.7f + originPos.x; Halo.transform.position = t_vec3; if (_time1 < Aperture_duration * 1.1f) //光圈扩大后开始动画 { float timeScale = _time1 / Aperture_duration; Aperture.transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one * 20, timeScale); t_SR.color = Color.Lerp(Color.white, new Color(1, 1, 1, 0), timeScale); } yield return(null); } Aperture.SetActive(false); } //第二段动画 { float _time0 = 0; Vector3 t_originPos = Halo.transform.position; Vector3 p1, p2; Vector3 _dir = Halo.transform.position - CharacterControl.instance.transform.position; Vector3 _dir_2 = Vector3.Cross(_dir, Vector3.back); Halo.GetComponent <TrailRenderer>().time *= 0.3f; _dir.z = 0; _dir_2.z = 0; p1 = Halo.transform.position + _dir * 0.8f; p2 = (CharacterControl.instance.transform.position + Halo.transform.position) / 2.0f + _dir_2 * 0.7f; p1.z = 0; p2.z = 0; while (_time0 < second_animation_duration) { _time0 += (Time.deltaTime * (_time0 + 0.4f * second_animation_duration) / second_animation_duration); float t = _time0 / second_animation_duration; Halo.transform.position = BezierLine(t_originPos, CharacterControl.instance.transform.position + Vector3.up, p1, p2, t); yield return(null); } } //第三段动画 { Soul.SetActive(false); float _time0 = 0; SpriteRenderer t_SR = Halo.GetComponent <SpriteRenderer>(); SpriteRenderer bloom_SR = Bloom.GetComponent <SpriteRenderer>(); while (_time0 < third_animation_duration) { _time0 += Time.deltaTime; float t = _time0 / third_animation_duration; Halo.transform.localScale = Vector3.Lerp(Halo.transform.localScale, Vector3.one * 30f, t); t_SR.color = Color.Lerp(t_SR.color, new Color(1, 1, 1, 0), t); bloom_SR.color = Color.Lerp(bloom_SR.color, new Color(1, 1, 1, 0), t); yield return(null); } Halo.SetActive(false); Eye.GetComponent <SpriteRenderer>().color = Color.white * 0.3f; Eye2.GetComponent <SpriteRenderer>().color = Color.white * 0.3f; } CharacterAttribute.GetInstance().add_MaxHP(1); CharacterControl.instance.getInput(); isAnimation = false; this.enabled = false; isNone = true; }