public CandyAttributesComponent(Coordinate coord, Candy properties) { this.Coordinate = coord; this.Type = properties.Type; this.Color = properties.Color; }
public static Entity CreateCandy(Scene scene, Vector2 localPosition, CandyTypes candyType, CandyColors candyColor) { var candyEntity = scene.EntityManager.Instantiate(WaveContent.Prefabs.Gameplay.Candy); candyEntity.IsSerializable = false; var transform = candyEntity.FindComponent <Transform2D>(); transform.LocalPosition = localPosition; var spriteAtlas = candyEntity.FindComponent <SpriteAtlas>(); spriteAtlas.TextureName = candyTextures[candyType][candyColor]; var animation2D = candyEntity.FindChild("Particles").FindComponent <Animation2D>(); switch (candyColor) { case CandyColors.Red: animation2D.CurrentAnimation = "ExplosionPink"; break; case CandyColors.Yellow: case CandyColors.Green: animation2D.CurrentAnimation = "ExplosionGreen"; break; case CandyColors.Blue: animation2D.CurrentAnimation = "ExplosionBlue"; break; default: throw new InvalidOperationException("Invalid candy color"); } return(candyEntity); }