diff --git a/ColorSwitch.Windows/Content/Content.mgcb b/ColorSwitch.Windows/Content/Content.mgcb
index 9a303ce..75617cd 100644
--- a/ColorSwitch.Windows/Content/Content.mgcb
+++ b/ColorSwitch.Windows/Content/Content.mgcb
@@ -60,6 +60,11 @@
/processorParam:TextureFormat=Compressed
/build:font.spritefont
+#begin Particles/star_death.pex
+/importer:ParticleDesignerImporter
+/processor:ParticleDesignerProcessor
+/build:Particles/star_death.pex
+
#begin Player/player_circle.png
/importer:TextureImporter
/processor:TextureProcessor
diff --git a/ColorSwitch.Windows/Content/Particles/star_death.pex b/ColorSwitch.Windows/Content/Particles/star_death.pex
new file mode 100644
index 0000000..21a8a99
--- /dev/null
+++ b/ColorSwitch.Windows/Content/Particles/star_death.pex
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ColorSwitch.Windows/GameCore/Components/PlayerPhysics.cs b/ColorSwitch.Windows/GameCore/Components/PlayerPhysics.cs
index 3cd2cec..556894e 100644
--- a/ColorSwitch.Windows/GameCore/Components/PlayerPhysics.cs
+++ b/ColorSwitch.Windows/GameCore/Components/PlayerPhysics.cs
@@ -47,7 +47,8 @@ public void HandleTouchableEntities(List touchableEntities) {
}
}
foreach (var touchableEntity in touchableEntities) {
- touchableEntity.SendState(entity);
+ if(touchableEntity.getComponent() != null)
+ touchableEntity.SendState(entity);
}
}
}
diff --git a/ColorSwitch.Windows/GameCore/Entities/Player.cs b/ColorSwitch.Windows/GameCore/Entities/Player.cs
index 8176e33..c03aa49 100644
--- a/ColorSwitch.Windows/GameCore/Entities/Player.cs
+++ b/ColorSwitch.Windows/GameCore/Entities/Player.cs
@@ -26,7 +26,7 @@ public static uint score {
}
private static GameText scoreText;
- public List touchableEntities;
+ public static List touchableEntities;
private bool gameStarted = false;
private Texture2D playerTexture;
diff --git a/ColorSwitch.Windows/GameCore/Entities/Special/Star.cs b/ColorSwitch.Windows/GameCore/Entities/Special/Star.cs
index f686488..9be4899 100644
--- a/ColorSwitch.Windows/GameCore/Entities/Special/Star.cs
+++ b/ColorSwitch.Windows/GameCore/Entities/Special/Star.cs
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Nez;
+using Nez.Particles;
using Nez.Sprites;
using Nez.Tweens;
@@ -10,6 +11,8 @@ public class Star : TouchableEntity {
private Texture2D starTexture;
private Sprite starSprite;
+ private ParticleEmitterConfig particleConfig;
+ private float deathDuration = 0.7f;
public override Vector2 realSize => starTexture.Bounds.Size.ToVector2();
@@ -21,7 +24,10 @@ public override void onAddedToScene() {
addComponent(starSprite);
var collider = new CircleCollider(starTexture.Height / 2);
- addComponent(collider);
+ addComponent(collider);
+
+ particleConfig = scene.content.Load("Particles/star_death");
+ particleConfig.duration = deathDuration;
}
public override void SendState(Entity sender) {
@@ -35,26 +41,38 @@ public override void SendState(Entity sender) {
}
}
- private new void destroy() {
- float duration = 0.7f;
+ private new void destroy() {
+ showScore();
+ spawnParticles();
+ base.destroy();
+ }
+ private void showScore() {
var scoreText = new GameText("+1");
scoreText.position = position;
scene.addEntity(scoreText);
- var moveTween = scoreText.tweenPositionTo(position + new Vector2(0, -40), duration);
+ var moveTween = scoreText.tweenPositionTo(position + new Vector2(0, -40), deathDuration);
moveTween.setEaseType(EaseType.QuadOut);
moveTween.start();
- var opacityTween = new FloatTween(scoreText, 0f, duration - 0.3f);
+ var opacityTween = new FloatTween(scoreText, 0f, deathDuration - 0.3f);
opacityTween.setEaseType(EaseType.QuadOut);
opacityTween.setDelay(0.3f);
- opacityTween.start();
-
- Core.schedule(duration, t => {
+ opacityTween.start();
+
+ Core.schedule(deathDuration, t => {
if (scene != null) scoreText?.destroy();
});
- base.destroy();
+ }
+
+ private void spawnParticles() {
+ var index = Player.touchableEntities.IndexOf(this) + 1;
+ var particles = Player.touchableEntities[index];
+
+ particleConfig.sourcePosition = position;
+ var particleEmitter = particles.addComponent(new ParticleEmitter(particleConfig));
+ particleEmitter.play();
}
}
}
\ No newline at end of file
diff --git a/ColorSwitch.Windows/GameCore/Scenes/GameScene.cs b/ColorSwitch.Windows/GameCore/Scenes/GameScene.cs
index 653be83..2853159 100644
--- a/ColorSwitch.Windows/GameCore/Scenes/GameScene.cs
+++ b/ColorSwitch.Windows/GameCore/Scenes/GameScene.cs
@@ -2,7 +2,6 @@
using ColorSwitch.Windows.GameCore.Entities;
using ColorSwitch.Windows.GameCore.UiLib.Entities;
using Microsoft.Xna.Framework;
-using ColorSwitch.Windows.GameCore.Helpers;
namespace ColorSwitch.Windows.GameCore.Scenes {
public class GameScene : Scene {
@@ -17,7 +16,7 @@ public override void initialize() {
player = new Player();
addEntity(player);
- var entityBuilder = new EntityBuilder(player.touchableEntities);
+ var entityBuilder = new EntityBuilder(Player.touchableEntities);
addEntity(entityBuilder);
Player.score = 0;