예제 #1
0
        public void Initialize(Vector2 center, int top, int bottom, int left, int right, Texture2D eTexture, Texture2D cTexture)
        {
            this.top = top;
            this.bottom = bottom;
            this.left = left;
            this.right = right;
            this.center = center;
            this.eTexture = eTexture;
            int frameTime = DynUtils.explosionTime / 4 ;
            this.cTexture = cTexture;
            active = true;

            bool looping = false;

            //We add animations for each direction
            for (int i = 1; i <= right; ++i)
            {
                DynCAnimation a = new DynCAnimation();
                if (i == right)
                    a.Initialize(eTexture, new Vector2(center.X + 16 * i, center.Y), 16, 16, 4, frameTime, looping, 3);
                else
                    a.Initialize(eTexture, new Vector2(center.X + 16 * i, center.Y), 16, 16, 4, frameTime, looping, 1);
                animations.Add(a);
            }

            for (int i = 1; i <= left; ++i)
            {
                DynCAnimation a = new DynCAnimation();
                if (i == left)
                    a.Initialize(eTexture, new Vector2(center.X - 16 * i, center.Y), 16, 16, 4, frameTime, looping, 5);
                else
                    a.Initialize(eTexture, new Vector2(center.X - 16 * i, center.Y), 16, 16, 4, frameTime, looping, 1);
                animations.Add(a);
            }

            for (int i = 1; i <= top; ++i)
            {
                DynCAnimation a = new DynCAnimation();
                if (i == top)
                    a.Initialize(eTexture, new Vector2(center.X, center.Y - 16 * i), 16, 16, 4, frameTime, looping, 2);
                else
                    a.Initialize(eTexture, new Vector2(center.X, center.Y - 16 * i), 16, 16, 4, frameTime, looping);
                animations.Add(a);
            }

            for (int i = 1; i <= bottom; ++i)
            {
                DynCAnimation a = new DynCAnimation();
                if (i == bottom)
                    a.Initialize(eTexture, new Vector2(center.X, center.Y + 16 * i), 16, 16, 4, frameTime, looping, 4);
                else
                    a.Initialize(eTexture, new Vector2(center.X, center.Y + 16 * i), 16, 16, 4, frameTime, looping);
                animations.Add(a);
            }

            DynCAnimation e = new DynCAnimation();
            frameTime = DynUtils.explosionTime / 9;
            e.Initialize(cTexture, center, 16, 16, 9, frameTime, false);
            animations.Add(e);
        }
예제 #2
0
 public void Initialize(Texture2D texture, Vector2 position, DynUtils.ObjectType type)
 {
     animation = new DynCAnimation();
     animation.Initialize(texture, position, 16, 16, 2, 250, true);
     if (type == DynUtils.ObjectType.ExplosionBonus || type == DynUtils.ObjectType.BombBonus)
         this.type = type;
     active = true;
 }
예제 #3
0
        public void Initialize(Texture2D playerTexture, Texture2D deathTexture, Vector2 playerPosition, int playerId)
        {
            position = playerPosition;
            this.playerID = playerId;
            alive = true;
            playerKeys = new PlayerKeys();
            this.deathTexture = deathTexture;

            distTraveled = 0;

            animation = new DynCAnimation();
            animation.Initialize(playerTexture, position, 23, 23, 3, 400, true);
        }
예제 #4
0
파일: DynBomb.cs 프로젝트: Zimnx/DynaBomber
 public void Initialize(int ownerId, int size, Vector2 pos, Texture2D texture, Texture2D explosionTexture)
 {
     this.OwnerId = ownerId;
     this.explosionSize = size;
     this.position = pos;
     this.texture = texture;
     this.explosionTexture = explosionTexture;
     exploded = false;
     running = false;
     lifeTime = 3000;
     active = true;
     playerGotOff = false;
     animation = new DynCAnimation();
     animation.Initialize(this.texture, position, 16, 16, 3, 200, true);
 }
예제 #5
0
 public void Initialize(Vector2 pos, Texture2D deathTexture, Texture2D monsterTexture, int ID, bool ghost = false)
 {
     alive = true;
     position = pos;
     this.deathTexture = deathTexture;
     this.monsterTexture = monsterTexture;
     possibleMoves = new Vector2[]
     {
         new Vector2(0,1),
         new Vector2(0,-1),
         new Vector2(-1,0),
         new Vector2(1,0)
     };
     lastMove = possibleMoves[DynUtils.Rand(0, 3)];
     animation = new DynCAnimation();
     animation.Initialize(monsterTexture, position, 16, 16, 3, 400, true);
     this.ghost = ghost;
     monsterID = ID;
     changeDirIn = DynUtils.Rand(3, 8);
 }
예제 #6
0
 void die()
 {
     if (alive)
     {
         alive = false;
         animation = new DynCAnimation();
         animation.Initialize(deathTexture, position, 16, 16, 6, 400, false);
     }
 }
예제 #7
0
 void die()
 {
     if (alive) //Once we die (and only once) we switch to death animation
     {
         alive = false;
         animation = new DynCAnimation();
         animation.Initialize(deathTexture, position, 24, 24, 7, 300, false);
     }
 }
예제 #8
0
        public void ExplodeBomb(DynBomb b)
        {
            int power = b.explosionSize;
            int[] Erange = { 0, 0, 0, 0 };  // explosion range in each direction     :
                                            //up,down,left,right
            bool[] Dir = { false, false, false, false }; // already hit wall in each direction

            Vector2 center = DynUtils.GetTileCoords(b.position);

            SetTile((int)center.X, (int)center.Y, TileType.EMPTY);

            for (int k = 1; k <= power; ++k)
            {
                Vector2[] vectors =
                {
                    new Vector2(center.X, center.Y-k),
                    new Vector2(center.X, center.Y + k),
                    new Vector2(center.X - k, center.Y),
                    new Vector2(center.X + k, center.Y)
                };
                int index = 0;
                foreach (Vector2 v in vectors)
                {
                    if (!Dir[index] && v.X >= 0 && v.Y >= 0 && v.X <= sizeX - 1 && v.Y <= sizeY - 1)
                    {
                        if (Tiles[(int)v.X, (int)v.Y] == TileType.EMPTY)
                            Erange[index]++;
                        else
                        {
                            Dir[index] = true;
                            if (Tiles[(int)v.X, (int)v.Y] != TileType.IMMOVABLE)
                            {
                                DynCAnimation wallExplosion = new DynCAnimation();
                                int frameTime = (DynUtils.explosionTime) / 7;
                                wallExplosion.Initialize(wallExplosionTexture, new Vector2(v.X * 16 + 8, v.Y * 16 + 8), 16, 16, 7, frameTime, false);
                                wallExplosionList.Add(wallExplosion);
                                Erange[index]++;
                            }
                        }
                    }
                    index++;
                }
            }
            DynExplosion explosion = new DynExplosion();
            explosion.Initialize(b.position, Erange[0], Erange[1], Erange[2], Erange[3], explosionTexture, b.explosionTexture);
            explosionList.Add(explosion);
        }