/// <summary> /// 魔炮持续时间 /// </summary> public void UpdateState2() { // 每10帧一个动画 if (_time % 10 == 0) { MovementObjectData data = new MovementObjectData(); data.tf = _movementObjectTfList[_nextMovementIndex]; data.tf.localPosition = new Vector3(0, -336, -2); data.state = 1; data.time = 0; data.duration = 12; _movementDataList.Add(data); _movementCount++; // 计算下一个需要取的下标 _nextMovementIndex = (_nextMovementIndex + 1) % MovementObjectCount; } UpdateSparkWaves(); // 更新物体碰撞器的位置 _colliderRect.SetPosition(Global.PlayerPos.x + _posOffset.x, Global.PlayerPos.y + _posOffset.y); if (_time >= _duration) { // 黑底Sprite消失 _effect.DoFade(20); _curState = 3; _time = 0; _duration = 30; _colliderRect.ClearSelf(); } _time++; }
private void UpdateSparkWaves() { float scale; Transform tf; Vector3 pos; for (int i = 0; i < _movementCount; i++) { MovementObjectData data = _movementDataList[i]; tf = data.tf; if (data.state == 1) { //scale = data.time <= 15 ? 1.5f : (float)data.time / 10; //scale *= 100; scale = Mathf.Lerp(50, 150, (float)data.time / data.duration); tf.localScale = new Vector3(scale, scale, 1); if (data.time >= data.duration) { data.state = 2; } } pos = tf.localPosition; pos.y += MasterSparkWaveSpeedY; if (pos.y >= 300) { // 将scale设置成0当做是隐藏 tf.localScale = new Vector3(0, 0, 1); // 清空 data.tf = null; _movementDataList.RemoveAt(i); _movementCount--; i--; } else { tf.localPosition = pos; data.time++; _movementDataList[i] = data; } } }