private static void AddAnimation(int row, int col, string image) { Sprite s = default(Sprite); Bitmap imgObj = default(Bitmap); imgObj = GameImage(image); imgObj.SetCellDetails(40, 40, 3, 3, 7); AnimationScript animation = default(AnimationScript); animation = SwinGame.LoadAnimationScript("splash.txt"); s = SwinGame.CreateSprite(imgObj, animation); s.X = FIELD_LEFT + col * (CELL_WIDTH + CELL_GAP); s.Y = FIELD_TOP + row * (CELL_HEIGHT + CELL_GAP); s.StartAnimation("splash"); _Animations.Add(s); }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="T:MyGame.CAnimation"/> class. /// </summary> /// <param name="img">The Animation image.</param> /// <param name="anim">The Animation.</param> /// <param name="animScript">The Animation Script containing Animation details.</param> public CAnimation(Bitmap img, Animation anim, AnimationScript animScript) { Img = img; Anim = anim; _animScript = animScript; }
/// <summary> /// Creates an Entity with an Animation component and adds it to the world. /// This is primarily used for Entities which are just animations so they can be processed /// by the Animation Rendering System. /// </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> /// <param name="anim">The name of the animation to be played.</param> /// <param name="img">The Bitmap the animation will operate on.</param> /// <param name="animScript">The animation script containing the animation details.</param> public static void CreateAnimationEntity(float x, float y, Animation anim, Bitmap img, AnimationScript animScript) { //Create Entity and add to world ulong newEntity = _world.NextEntityID; int width = SwinGame.BitmapWidth(img); int height = SwinGame.BitmapHeight(img); //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CPosition(x, y, width, height)); components.Add(new CAnimation(img, anim, animScript)); _world.AddEntity(newEntity, components); }
public CStatusAnimation(Type linkedComponent, float xOffset, float yOffset, Bitmap img, Animation anim, AnimationScript animScript) : base(img, anim, animScript) { _linkedComponent = linkedComponent; _xOffset = xOffset; _yOffset = yOffset; }