/// <summary> /// Adds an Ice Spike status animation linked to the Entity's position. /// </summary> /// <param name="statusAnims">The Entity's list of Status Animations.</param> /// <param name="pos">The Entity's position.</param> private void HandleFreezeEffect(CStatusAnimations statusAnims, CPosition pos) { CStatusAnimation newStatusAnim; Bitmap bmp; Animation anim; AnimationScript animScript; float xOffset; float yOffset; if (pos.Width <= 21) { bmp = SwinGame.BitmapNamed("SmallIceSpike"); } else { bmp = SwinGame.BitmapNamed("BigIceSpike"); } xOffset = (pos.Width / 2) - (bmp.CellWidth / 2); yOffset = pos.Height - bmp.CellHeight; anim = SwinGame.CreateAnimation("Freeze", SwinGame.AnimationScriptNamed("IceSpikeAnim")); animScript = SwinGame.AnimationScriptNamed("IceSpikeAnim"); newStatusAnim = new CStatusAnimation(typeof(CFrozen), xOffset, yOffset, bmp, anim, animScript); statusAnims.Anims.Add(newStatusAnim); }
/// <summary> /// Adds a Poison Cloud status animation linked to the Entity's position. /// </summary> /// <param name="statusAnims">The Entity's list of Status Animations.</param> /// <param name="pos">The Entity's position.</param> private void HandlePoisonEffect(CStatusAnimations statusAnims, CPosition pos) { CStatusAnimation newStatusAnim; Bitmap bmp; Animation anim; AnimationScript animScript; float xOffset; float yOffset; if (pos.Width <= 21) { bmp = SwinGame.BitmapNamed("SmallPoisonCloud"); } else { bmp = SwinGame.BitmapNamed("BigPoisonCloud"); } xOffset = (pos.Width / 2) - (bmp.CellWidth / 2); yOffset = 0; anim = SwinGame.CreateAnimation("Poison", SwinGame.AnimationScriptNamed("PoisonZoneAnim")); animScript = SwinGame.AnimationScriptNamed("PoisonZoneAnim"); newStatusAnim = new CStatusAnimation(typeof(CPoison), xOffset, yOffset, bmp, anim, animScript); statusAnims.Anims.Add(newStatusAnim); }
/// <summary> /// Creates an Entity with all Components of a Freeze Zone and adds it to the World. /// This Entity represents the Freeze Zone created when a Freezing Bullet reaches its target. /// </summary> /// <param name="pos">The position the Freeze Zone occupies.</param> public static void CreateFreezeZone(CPosition pos) { //Create Entity and add to world. ulong newEntity = _world.NextEntityID; /// <summary> /// Adjust position for Sprite size so Freeze Zone spawns at centre of bullet. /// </summary> float atX = pos.X - (FREEZE_ZONE_SIZE / 2); float atY = pos.Y - (FREEZE_ZONE_SIZE / 2); /// <summary> /// Creates a new Entity with just an Animation component to be processed by the Animation Rendering System. /// </summary> Bitmap bmp = SwinGame.BitmapNamed("FreezingBulletSplash"); Animation anim = SwinGame.CreateAnimation("Splash", SwinGame.AnimationScriptNamed("FreezingBulletSplashAnim")); AnimationScript animScript = SwinGame.AnimationScriptNamed("FreezingBulletSplashAnim"); CreateAnimationEntity(atX, atY, anim, bmp, animScript); //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CPlayerTeam()); components.Add(new CPosition(pos.Centre.X - (FREEZE_ZONE_SIZE / 2), pos.Centre.Y - (FREEZE_ZONE_SIZE / 2), FREEZE_ZONE_SIZE)); components.Add(new CCollidable()); components.Add(new CAppliesDebuff()); components.Add(new CFrozen(FREEZING_BULLET_FREEZE_DURATION, 0)); _world.AddEntity(newEntity, components); }
/// <summary> /// Creates an Entity with all Components of a Battering Ram unit for the Enemy team and adds it to the World. /// The unit represents the large units holding Battering Rams which attack the Player's Castle. /// </summary> /// <param name="x">The x coordinate where the Entity will be created.</param> /// <param name="y">The y coordinate where the Entity will be created.</param> public static void CreateBatteringRam(float x, float y) { //Create Entity and add to world. ulong newEntity = _world.NextEntityID; //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CEnemyTeam()); components.Add(new CStatusAnimations()); components.Add(new CPosition(x, y, BATTERING_RAM_WIDTH, BATTERING_RAM_HEIGHT)); components.Add(new CVelocity(-BATTERING_RAM_SPEED, 0, BATTERING_RAM_SPEED)); components.Add(new CHealth(BATTERING_RAM_HP)); components.Add(new CAI(BATTERING_RAM_RANGE, BATTERING_RAM_COOLDOWN, AttackType.Melee, PlayerSystem.PLAYER_ENTITY_ID)); //Belongs to the Enemy team - targets the Castle by default components.Add(new CDamage(BATTERING_RAM_DAMAGE)); components.Add(new CLoot(BATTERING_RAM_LOOT_VALUE)); components.Add(new CCollidable()); /// <summary> /// Details for Animation Component. /// </summary> Bitmap bmp = SwinGame.BitmapNamed("BatteringRam"); Animation anim = SwinGame.CreateAnimation("Walk", SwinGame.AnimationScriptNamed("BatteringRamAnims")); AnimationScript animScript = SwinGame.AnimationScriptNamed("BatteringRamAnims"); components.Add(new CAnimation(bmp, anim, animScript)); _world.AddEntity(newEntity, components); }
/// <summary> /// Creates an Entity with all Components of an Archer for the Enemy team and adds it to the World. /// This represents the unit holding a bow which attacks the Player's Castle. /// </summary> /// <param name="x">The x coordinate where the Entity will be created.</param> /// <param name="y">The y coordinate where the Entity will be created.</param> public static void CreateEnemyArcher(float x, float y) { //Create Entity and add to World. ulong newEntity = _world.NextEntityID; //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CEnemyTeam()); components.Add(new CStatusAnimations()); components.Add(new CPosition(x, y, ARCHER_WIDTH, ARCHER_HEIGHT)); components.Add(new CVelocity(-ENEMY_ARCHER_SPEED, 0, ENEMY_ARCHER_SPEED)); //Is created moving towards the castle. components.Add(new CHealth(ENEMY_ARCHER_HP)); components.Add(new CAI(ENEMY_ARCHER_RANGE, ENEMY_ARCHER_COOLDOWN, AttackType.Bow, PlayerSystem.PLAYER_ENTITY_ID)); //Belongs to the Enemy team - attacks the Castle by default. components.Add(new CBow(ENEMY_ARROW_SPEED, ENEMY_ARROW_DAMAGE)); components.Add(new CLoot(ENEMY_ARCHER_LOOT_VALUE)); components.Add(new CCollidable()); /// <summary> /// Details for Animation Component. /// </summary> Bitmap bmp = SwinGame.BitmapNamed("ArcherMan"); Animation anim = SwinGame.CreateAnimation("Walk", SwinGame.AnimationScriptNamed("ArcherManAnims")); AnimationScript animScript = SwinGame.AnimationScriptNamed("ArcherManAnims"); components.Add(new CAnimation(bmp, anim, animScript)); _world.AddEntity(newEntity, components); }
/// <summary> /// Creates an Entity with all Components of a Sword Man and adds it to the World. /// This represents the unit holding a sword in the game which attacks the Player's Castle. /// </summary> /// <param name="x">The x coordinate where the Entity will be created.</param> /// <param name="y">The y coordinate where the Entity will be created.</param> public static void CreateSwordMan(float x, float y) { //Create Entity and add to world ulong newEntity = _world.NextEntityID; //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CEnemyTeam()); components.Add(new CStatusAnimations()); components.Add(new CPosition(x, y, SWORD_MAN_WIDTH, SWORD_MAN_HEIGHT)); components.Add(new CVelocity(-SWORD_MAN_SPEED, 0, SWORD_MAN_SPEED)); //Is created moving towards the Castle. components.Add(new CHealth(SWORD_MAN_HP)); components.Add(new CAI(SWORD_MAN_RANGE, SWORD_MAN_COOLDOWN, AttackType.Melee, PlayerSystem.PLAYER_ENTITY_ID)); //Sword Men are on Enemy team and target the Castle by default components.Add(new CDamage(SWORD_MAN_DAMAGE)); components.Add(new CLoot(SWORD_MAN_LOOT_VALUE)); components.Add(new CCollidable()); /// <summary> /// Details for Animation Component. /// </summary> Bitmap bmp = SwinGame.BitmapNamed("SwordMan"); Animation anim = SwinGame.CreateAnimation("Walk", SwinGame.AnimationScriptNamed("SwordManAnims")); AnimationScript animScript = SwinGame.AnimationScriptNamed("SwordManAnims"); components.Add(new CAnimation(bmp, anim, animScript)); _world.AddEntity(newEntity, components); }
/// <summary> /// Creates an Entity with all the Components of a Poison Zone and adds it to the World. /// This Entity represents the Poison Zone the Player can create in the game. /// </summary> /// <param name="x">The x coordinate the Entity will be created at.</param> /// <param name="y">The y coordinate the Entity will be created at.</param> public static void CreatePoisonZone(float x, float y) { //Create Entity and add to world ulong newEntity = _world.NextEntityID; //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CPlayerTeam()); components.Add(new CPosition(x - (POISON_ZONE_SIZE / 2), y - (POISON_ZONE_SIZE / 2), POISON_ZONE_SIZE)); components.Add(new CPoison(POISON_ZONE_STRENGTH, POISON_ZONE_POISON_DURATION, 0)); components.Add(new CLifetime(POISON_ZONE_LIFETIME)); components.Add(new CAppliesDebuff()); components.Add(new CCollidable()); Bitmap bmp = SwinGame.BitmapNamed("PoisonZone"); Animation anim = SwinGame.CreateAnimation("Poison", SwinGame.AnimationScriptNamed("PoisonZoneAnim")); AnimationScript animScript = SwinGame.AnimationScriptNamed("PoisonZoneAnim"); components.Add(new CAnimation(bmp, anim, animScript)); _world.AddEntity(newEntity, components); }
/// <summary> /// Creates an Entity with all Components for an Explosion Man and adds it to the World. /// This Entity represents the exploding wizard the Player can purchase. /// </summary> public static void CreateExplosionMan() { //Create Entity and add to world ulong newEntity = _world.NextEntityID; /// <summary> /// Identifies the most populated Enemy Spatial Hash Cell. The Explosion man /// will be spawned at the centre of this cell. /// </summary> CollisionCheckSystem collChkSys = World.GetSystem <CollisionCheckSystem>(); int mostPopulatedCell = collChkSys.EnemyCells.Aggregate((l, r) => l.Value.Count > r.Value.Count ? l : r).Key; Point2D pos = collChkSys.CentreOfCell(mostPopulatedCell); /// <summary> /// Adjust position for Sprite size so Explosion Man spawns at centre. /// </summary> float atX = pos.X - (EXPLOSION_MAN_SIZE / 2); float atY = pos.Y - (EXPLOSION_MAN_SIZE / 2); /// <summary> /// Animation details for Animation component. /// </summary> Bitmap bmp = SwinGame.BitmapNamed("ExplosionMan"); Animation anim = SwinGame.CreateAnimation("Spawn", SwinGame.AnimationScriptNamed("ExplosionAnim")); AnimationScript animScript = SwinGame.AnimationScriptNamed("ExplosionAnim"); //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CPlayerTeam()); components.Add(new CPosition(atX, atY, EXPLOSION_MAN_SIZE)); components.Add(new CAnimation(bmp, anim, animScript)); components.Add(new CExplosionMan(mostPopulatedCell)); _world.AddEntity(newEntity, components); }
/// <summary> /// Creates an Entity with all Components of an Archer for the Player team and adds it to the World. /// This represents the unit holding a bow which the Player can buy to defend the Castle. /// </summary> /// <param name="x">The x coordinate where the Entity will be created.</param> /// <param name="y">The y coordinate where the Entity will be created.</param> public static void CreatePlayerArcher(float x, float y) { //Create Entity and add to world ulong newEntity = _world.NextEntityID; //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CPlayerTeam()); components.Add(new CPosition(x, y, ARCHER_WIDTH, ARCHER_HEIGHT)); components.Add(new CAI(PLAYER_ARCHER_RANGE, PLAYER_ARCHER_COOLDOWN, AttackType.Bow)); components.Add(new CBow(PLAYER_ARROW_SPEED, PLAYER_ARROW_DAMAGE)); /// <summary> /// Details for Animation Component. /// </summary> Bitmap bmp = SwinGame.BitmapNamed("PlayerArcher"); Animation anim = SwinGame.CreateAnimation("Still", SwinGame.AnimationScriptNamed("ArcherManAnims")); AnimationScript animScript = SwinGame.AnimationScriptNamed("ArcherManAnims"); components.Add(new CAnimation(bmp, anim, animScript)); _world.AddEntity(newEntity, components); }