///
<summary>
///
显示风中粒子
///
</summary>
///
<param name="role">
所修饰角色
</param>
///
<param name="equipType">
所参照的装备
</param>
///
<param name="particleType">
粒子类型
</param>
///
<param name="color">
颜色
</param>
///
<param name="amount">
量
</param>
public
void
ShowWindParticles(Hero role, EquipTypes equipType, ParticleTypes particleType, Color color,
double
amount) {
int
distance
=
0
;
double
speed
=
0
;
if
(role.Action
==
Actions.Stop) {
distance
=
40
;
speed
=
RandomSeed.Next(
2000
,
3000
)
*
0.01
;
}
else
{
distance
=
40
;
speed
=
RandomSeed.Next(
1000
,
1500
)
*
0.01
;
}
int
halfDistance
=
distance
/
2
;
int
obliqueDistance
=
distance
*
2
/
3
;
string
particleName
=
string
.Empty;
switch
(particleType) {
case
ParticleTypes.Normal:
particleName
=
"
Particle
"
;
break
;
case
ParticleTypes.Smoke:
particleName
=
"
Smoke
"
;
break
;
case
ParticleTypes.Ice:
particleName
=
"
Ice
"
;
break
;
case
ParticleTypes.Spark:
particleName
=
"
Spark
"
;
break
;
}
Dispatcher.BeginInvoke(
delegate
{
ObjectBase equip
=
role.EquipEntity(equipType);
WriteableBitmap writeableBitmap
=
new
WriteableBitmap(equip,
null
);
lock
(writeableBitmap) {
writeableBitmap.Invalidate();
int
z
=
0
;
if
(equipType
==
EquipTypes.Weapon) {
z
=
role.Z
+
equip.Z;
}
else
{
z
=
(role.Direction
==
Directions.North
||
role.Direction
==
Directions.NorthEast
||
role.Direction
==
Directions.NorthWest)
?
role.Z : role.Z
-
20
;
}
Point position
=
equipType
==
EquipTypes.Overall
?
role.Center : equip.Position;
Point2D destination
=
new
Point2D();
MonoChrome monoChrome
=
new
MonoChrome() { FilterColor
=
color };
switch
(role.Direction) {
case
Directions.North:
destination.X
=
0
; destination.Y
=
RandomSeed.Next(halfDistance, distance);
break
;
case
Directions.NorthEast:
destination.X
=
-
RandomSeed.Next(halfDistance, obliqueDistance); destination.Y
=
RandomSeed.Next(halfDistance, obliqueDistance);
break
;
case
Directions.East:
destination.X
=
-
RandomSeed.Next(halfDistance, distance); destination.Y
=
0
;
break
;
case
Directions.SouthEast:
destination.X
=
-
RandomSeed.Next(halfDistance, obliqueDistance); destination.Y
=
-
RandomSeed.Next(halfDistance, obliqueDistance);
break
;
case
Directions.South:
destination.X
=
0
; destination.Y
=
-
RandomSeed.Next(halfDistance, distance);
break
;
case
Directions.SouthWest:
destination.X
=
RandomSeed.Next(halfDistance, obliqueDistance); destination.Y
=
-
RandomSeed.Next(halfDistance, obliqueDistance);
break
;
case
Directions.West:
destination.X
=
RandomSeed.Next(halfDistance, distance); destination.Y
=
0
;
break
;
case
Directions.NorthWest:
destination.X
=
RandomSeed.Next(halfDistance, obliqueDistance); destination.Y
=
RandomSeed.Next(halfDistance, obliqueDistance);
break
;
}
for
(
int
i
=
0
; i
<
amount; i
++
) {
int
x
=
RandomSeed.Next(
0
, writeableBitmap.PixelWidth);
int
y
=
RandomSeed.Next(
0
, writeableBitmap.PixelHeight);
byte
[] bytes
=
BitConverter.GetBytes(writeableBitmap.Pixels[writeableBitmap.PixelWidth
*
y
+
x]);
if
(bytes[
3
]
!=
0
) {
Particle particle
=
new
Particle() { Effect
=
monoChrome, Z
=
z, Source
=
GlobalMethod.GetProjectImage(
string
.Format(
"
UI/{0}{1}.png
"
, particleName, RandomSeed.Next(
0
,
3
))) };
space.Children.Add(particle);
EventHandler handler
=
null
;
particle.Disposed
+=
handler
=
(s, e)
=>
{
Particle p
=
s
as
Particle;
p.Disposed
-=
handler;
space.Children.Remove(p);
};
particle.Move(
new
Point(role.Position.X
-
position.X
+
x, role.Position.Y
-
position.Y
+
y),
new
Point(role.Position.X
-
position.X
+
x
+
destination.X, role.Position.Y
-
position.Y
+
y
+
destination.Y), speed, MoveModes.Opacity);
}
}
}
});
}