Ejemplo n.º 1
0
Archivo: PowerUp.cs Proyecto: JueZ/ITP
        public PowerUp(PowerUpKind kind, Guid guid = new Guid())
        {
            this._PowerUpLocation = new List <int[]>();
            _kind = kind;

            var guidIsEmpty = guid == Guid.Empty;

            if (guidIsEmpty)
            {
                this._guid = Guid.NewGuid();
            }
            else
            {
                this._guid = guid;
            }



            if (Game.getRandomNumber(1, 3) % 2 == 0)
            {
                _movePowerUpX = true;
            }
            else
            {
                _movePowerUpX = false;
            }

            if (Game.getRandomNumber(1, 3) % 2 == 0)
            {
                _movePowerUpY = true;
            }
            else
            {
                _movePowerUpY = false;
            }

            startX = Game.getRandomNumber(5, Game.Instance.getFieldX() - 5);
            startY = Game.getRandomNumber(5, Game.Instance.getFieldY() - 5);

            if (kind == PowerUpKind.goldenApple || kind == PowerUpKind.deleteAllSnakes || kind == PowerUpKind.rabies)
            {
                this._PowerUpLocation.Add(new int[2] {
                    startX, startY
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX, startY + 1
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX + 1, startY + 1
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX + 1, startY
                });
            }
            else
            {
                // frame of PowerUps
                this._PowerUpLocation.Add(new int[2] {
                    startX, startY
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX, startY + 1
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX, startY + 2
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX, startY + 3
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX, startY + 4
                });

                this._PowerUpLocation.Add(new int[2] {
                    startX - 1, startY + 4
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 2, startY + 4
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 3, startY + 4
                });

                this._PowerUpLocation.Add(new int[2] {
                    startX - 4, startY
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 4, startY + 1
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 4, startY + 2
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 4, startY + 3
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 4, startY + 4
                });

                this._PowerUpLocation.Add(new int[2] {
                    startX - 1, startY
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 2, startY
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 3, startY
                });

                // inside of PowerUps
                this._PowerUpLocation.Add(new int[2] {
                    startX - 1, startY + 1
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 2, startY + 1
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 3, startY + 1
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 1, startY + 2
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 2, startY + 2
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 3, startY + 2
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 1, startY + 3
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 2, startY + 3
                });
                this._PowerUpLocation.Add(new int[2] {
                    startX - 3, startY + 3
                });
            }
        }
Ejemplo n.º 2
0
 public PowerUp(PowerUpKind k, int p)
 {
     kind  = k;
     price = p;
 }
Ejemplo n.º 3
0
Archivo: PowerUp.cs Proyecto: JueZ/ITP
        public PowerUp(PowerUpKind kind, Guid guid = new Guid())
        {
            this._PowerUpLocation = new List<int[]>();
            _kind = kind;

            var guidIsEmpty = guid == Guid.Empty;
            if (guidIsEmpty)
                this._guid = Guid.NewGuid();
            else
                this._guid = guid;

            if(Game.getRandomNumber(1,3) % 2 == 0)
                _movePowerUpX = true;
            else
                _movePowerUpX = false;

            if (Game.getRandomNumber(1, 3) % 2 == 0)
                _movePowerUpY = true;
            else
                _movePowerUpY = false;

            startX = Game.getRandomNumber(5, Game.Instance.getFieldX() - 5);
            startY = Game.getRandomNumber(5, Game.Instance.getFieldY() - 5);

            if (kind == PowerUpKind.goldenApple || kind == PowerUpKind.deleteAllSnakes || kind == PowerUpKind.rabies)
            {
                this._PowerUpLocation.Add(new int[2] { startX, startY });
                this._PowerUpLocation.Add(new int[2] { startX, startY + 1 });
                this._PowerUpLocation.Add(new int[2] { startX + 1, startY +1 });
                this._PowerUpLocation.Add(new int[2] { startX + 1, startY });
            }
            else
            {

                // frame of PowerUps
                this._PowerUpLocation.Add(new int[2] { startX, startY });
                this._PowerUpLocation.Add(new int[2] { startX, startY + 1 });
                this._PowerUpLocation.Add(new int[2] { startX, startY + 2 });
                this._PowerUpLocation.Add(new int[2] { startX, startY + 3 });
                this._PowerUpLocation.Add(new int[2] { startX, startY + 4 });

                this._PowerUpLocation.Add(new int[2] { startX - 1, startY + 4 });
                this._PowerUpLocation.Add(new int[2] { startX - 2, startY + 4 });
                this._PowerUpLocation.Add(new int[2] { startX - 3, startY + 4 });

                this._PowerUpLocation.Add(new int[2] { startX - 4, startY });
                this._PowerUpLocation.Add(new int[2] { startX - 4, startY + 1 });
                this._PowerUpLocation.Add(new int[2] { startX - 4, startY + 2 });
                this._PowerUpLocation.Add(new int[2] { startX - 4, startY + 3 });
                this._PowerUpLocation.Add(new int[2] { startX - 4, startY + 4 });

                this._PowerUpLocation.Add(new int[2] { startX - 1, startY });
                this._PowerUpLocation.Add(new int[2] { startX - 2, startY });
                this._PowerUpLocation.Add(new int[2] { startX - 3, startY });

                // inside of PowerUps
                this._PowerUpLocation.Add(new int[2] { startX - 1, startY + 1 });
                this._PowerUpLocation.Add(new int[2] { startX - 2, startY + 1 });
                this._PowerUpLocation.Add(new int[2] { startX - 3, startY + 1 });
                this._PowerUpLocation.Add(new int[2] { startX - 1, startY + 2 });
                this._PowerUpLocation.Add(new int[2] { startX - 2, startY + 2 });
                this._PowerUpLocation.Add(new int[2] { startX - 3, startY + 2 });
                this._PowerUpLocation.Add(new int[2] { startX - 1, startY + 3 });
                this._PowerUpLocation.Add(new int[2] { startX - 2, startY + 3 });
                this._PowerUpLocation.Add(new int[2] { startX - 3, startY + 3 });
            }
        }