|
1 | | -import { Color } from "../../dataStruct/Color"; |
| 1 | +import { Random } from "../../algorithm/random"; |
2 | 2 | import { ProgressNumber } from "../../dataStruct/ProgressNumber"; |
3 | 3 | import { Rectangle } from "../../dataStruct/shape/Rectangle"; |
4 | 4 | import { Vector } from "../../dataStruct/Vector"; |
| 5 | +import { StageStyleManager } from "../../stageStyle/StageStyleManager"; |
5 | 6 | import { Effect } from "../effect"; |
6 | | -import { LineCuttingEffect } from "./LineCuttingEffect"; |
| 7 | +import { ZapLineEffect } from "./ZapLineEffect"; |
7 | 8 |
|
8 | 9 | export class EntityCreateLineEffect extends Effect { |
9 | 10 | constructor( |
10 | 11 | public override timeProgress: ProgressNumber, |
11 | 12 | public rect: Rectangle, |
12 | 13 | ) { |
13 | 14 | super(timeProgress); |
14 | | - const fromColor = new Color(100, 100, 100, 0); |
15 | | - const toColor = new Color(255, 255, 255, 1); |
16 | | - const shiftingLength = 0; |
17 | 15 | // 子特效 |
18 | | - this.subEffects = [ |
19 | | - new LineCuttingEffect( |
20 | | - new ProgressNumber(0, timeProgress.maxValue), |
21 | | - rect.leftTop.add(new Vector(-shiftingLength, -shiftingLength)), |
22 | | - rect.rightTop, |
23 | | - fromColor.clone(), |
24 | | - toColor.clone(), |
25 | | - 10, |
26 | | - ), |
27 | | - new LineCuttingEffect( |
28 | | - new ProgressNumber(0, timeProgress.maxValue), |
29 | | - rect.rightTop.add(new Vector(shiftingLength, -shiftingLength)), |
30 | | - rect.rightBottom, |
31 | | - fromColor.clone(), |
32 | | - toColor.clone(), |
33 | | - 10, |
34 | | - ), |
35 | | - new LineCuttingEffect( |
36 | | - new ProgressNumber(0, timeProgress.maxValue), |
37 | | - rect.rightBottom.add(new Vector(shiftingLength, shiftingLength)), |
38 | | - rect.leftBottom, |
39 | | - fromColor.clone(), |
40 | | - toColor.clone(), |
41 | | - 10, |
42 | | - ), |
43 | | - new LineCuttingEffect( |
44 | | - new ProgressNumber(0, timeProgress.maxValue), |
45 | | - rect.leftBottom.add(new Vector(-shiftingLength, shiftingLength)), |
46 | | - rect.leftTop, |
47 | | - fromColor, |
48 | | - toColor, |
49 | | - 10, |
50 | | - ), |
51 | | - ]; |
| 16 | + this.subEffects = []; |
| 17 | + // 顶部线 |
| 18 | + for (let i = 0; i < 10; i++) { |
| 19 | + const topStartLocation = new Vector( |
| 20 | + Random.randomFloat(this.rect.left, this.rect.right), |
| 21 | + this.rect.top, |
| 22 | + ); |
| 23 | + const topEndLocation = topStartLocation.add( |
| 24 | + topStartLocation.subtract(this.rect.center).multiply(100), |
| 25 | + ); |
| 26 | + const zapLineEffect = new ZapLineEffect( |
| 27 | + topStartLocation, |
| 28 | + topEndLocation, |
| 29 | + 50, |
| 30 | + 20, |
| 31 | + 45, |
| 32 | + StageStyleManager.currentStyle.StageObjectBorderColor, |
| 33 | + this.timeProgress.clone(), |
| 34 | + 2, |
| 35 | + ); |
| 36 | + this.subEffects.push(zapLineEffect); |
| 37 | + } |
| 38 | + // 底部线 |
| 39 | + for (let i = 0; i < 10; i++) { |
| 40 | + const bottomStartLocation = new Vector( |
| 41 | + Random.randomFloat(this.rect.left, this.rect.right), |
| 42 | + this.rect.bottom, |
| 43 | + ); |
| 44 | + const bottomEndLocation = bottomStartLocation.add( |
| 45 | + bottomStartLocation.subtract(this.rect.center).multiply(100), |
| 46 | + ); |
| 47 | + const zapLineEffect = new ZapLineEffect( |
| 48 | + bottomStartLocation, |
| 49 | + bottomEndLocation, |
| 50 | + 50, |
| 51 | + 20, |
| 52 | + 45, |
| 53 | + StageStyleManager.currentStyle.StageObjectBorderColor, |
| 54 | + this.timeProgress.clone(), |
| 55 | + 2, |
| 56 | + ); |
| 57 | + this.subEffects.push(zapLineEffect); |
| 58 | + } |
| 59 | + // 左侧线 |
| 60 | + for (let i = 0; i < 10; i++) { |
| 61 | + const leftStartLocation = new Vector( |
| 62 | + this.rect.left, |
| 63 | + Random.randomFloat(this.rect.top, this.rect.bottom), |
| 64 | + ); |
| 65 | + const leftEndLocation = leftStartLocation.add( |
| 66 | + leftStartLocation.subtract(this.rect.center).multiply(100), |
| 67 | + ); |
| 68 | + const zapLineEffect = new ZapLineEffect( |
| 69 | + leftStartLocation, |
| 70 | + leftEndLocation, |
| 71 | + 50, |
| 72 | + 20, |
| 73 | + 45, |
| 74 | + StageStyleManager.currentStyle.StageObjectBorderColor, |
| 75 | + this.timeProgress.clone(), |
| 76 | + 2, |
| 77 | + ); |
| 78 | + this.subEffects.push(zapLineEffect); |
| 79 | + } |
| 80 | + // 右侧线 |
| 81 | + for (let i = 0; i < 10; i++) { |
| 82 | + const rightStartLocation = new Vector( |
| 83 | + this.rect.right, |
| 84 | + Random.randomFloat(this.rect.top, this.rect.bottom), |
| 85 | + ); |
| 86 | + const rightEndLocation = rightStartLocation.add( |
| 87 | + rightStartLocation.subtract(this.rect.center).multiply(100), |
| 88 | + ); |
| 89 | + const zapLineEffect = new ZapLineEffect( |
| 90 | + rightStartLocation, |
| 91 | + rightEndLocation, |
| 92 | + 50, |
| 93 | + 20, |
| 94 | + 45, |
| 95 | + StageStyleManager.currentStyle.StageObjectBorderColor, |
| 96 | + this.timeProgress.clone(), |
| 97 | + 2, |
| 98 | + ); |
| 99 | + this.subEffects.push(zapLineEffect); |
| 100 | + } |
52 | 101 | } |
53 | 102 |
|
54 | 103 | static from(rectangle: Rectangle): EntityCreateLineEffect { |
|
0 commit comments