Exemplo n.º 1
0
 public void ResetPosition()
 {
     location      = PacForm.coordToPixelCenter(new Point(14, 26));
     location.X   -= PacForm.BoardTileSize * PacForm.SpriteScale / 2;
     direction     = 0;
     nextDirection = 0;
     currentSprite = pacmanSprites[2];
     moving        = false;
     dead          = false;
     keyPressed    = false;
 }
Exemplo n.º 2
0
        void MakeWaypoints()
        {
            PointF way_01 = PacForm.coordToPixelCenter(new Point(14, 14));

            way_01.X -= PacForm.BoardTileSize * PacForm.SpriteScale / 2;
            PointF way_02 = PacForm.coordToPixelCenter(new Point(14, 17));

            way_02.X -= PacForm.BoardTileSize * PacForm.SpriteScale / 2;
            waypoints = new PointF[]
            {
                way_01, way_02
            };
        }
Exemplo n.º 3
0
 public PacMan(PacForm frm)
 {
     lives          = 4;
     direction      = 0;
     nextDirection  = 0;
     deadSpriteLoop = 0;
     spriteLoop     = 0;
     form           = frm;
     dead           = false;
     MakeSprites();
     location      = PacForm.coordToPixelCenter(new Point(14, 26));
     location.X   -= PacForm.BoardTileSize * PacForm.SpriteScale / 2;
     speed         = 1f;
     currentSprite = pacmanSprites[2];
     bonusCounter  = 0;
     InitializeSound();
 }
Exemplo n.º 4
0
 public Blinky(PacForm frm) : base(frm)
 {
     ghostNumber   = 0;
     color         = Color.Red;
     SpriteRight   = 384;
     SpriteRight2  = 386;
     SpriteDown    = 388;
     SpriteDown2   = 390;
     SpriteLeft    = 392;
     SpriteLeft2   = 394;
     SpriteUp      = 396;
     SpriteUp2     = 398;
     home          = PacForm.coordToPixelCenter(new Point(14, 14));
     scatterTarget = new Point(25, 0);
     MakeWaypoints();
     MakeSprites();
     ResetPosition();
 }
Exemplo n.º 5
0
 public Pinky(PacForm frm) : base(frm)
 {
     ghostNumber            = 1;
     color                  = Color.Pink;
     SpriteRight            = 512;
     SpriteRight2           = 514;
     SpriteDown             = 516;
     SpriteDown2            = 518;
     SpriteLeft             = 520;
     SpriteLeft2            = 522;
     SpriteUp               = 524;
     SpriteUp2              = 526;
     home                   = PacForm.coordToPixelCenter(new Point(14, 17));
     scatterTarget          = new Point(2, 0);
     stayAtHomeWayPointUp   = PacForm.coordToPixelCorner(new Point(14, 17));
     stayAtHomeWayPointDown = PacForm.coordToPixelCorner(new Point(14, 18));
     MakeWaypoints();
     MakeSprites();
     ResetPosition();
 }
Exemplo n.º 6
0
 public Inky(PacForm frm) : base(frm)
 {
     ghostNumber            = 2;
     color                  = Color.Aqua;
     SpriteRight            = 528;
     SpriteRight2           = 530;
     SpriteDown             = 532;
     SpriteDown2            = 534;
     SpriteLeft             = 536;
     SpriteLeft2            = 538;
     SpriteUp               = 540;
     SpriteUp2              = 542;
     home                   = PacForm.coordToPixelCenter(new Point(12, 17));
     scatterTarget          = new Point(27, 35);
     stayAtHomeWayPointUp   = PacForm.coordToPixelCorner(new Point(12, 17));
     stayAtHomeWayPointDown = PacForm.coordToPixelCorner(new Point(12, 18));
     MakeWaypoints();
     MakeSprites();
     ResetPosition();
 }
Exemplo n.º 7
0
 public Clyde(PacForm frm) : base(frm)
 {
     ghostNumber            = 3;
     color                  = Color.Orange;
     SpriteRight            = 576;
     SpriteRight2           = 578;
     SpriteDown             = 580;
     SpriteDown2            = 582;
     SpriteLeft             = 584;
     SpriteLeft2            = 586;
     SpriteUp               = 588;
     SpriteUp2              = 590;
     home                   = PacForm.coordToPixelCenter(new Point(15, 17));
     scatterTarget          = new Point(0, 35);
     stayAtHomeWayPointUp   = PacForm.coordToPixelCorner(new Point(16, 17));
     stayAtHomeWayPointDown = PacForm.coordToPixelCorner(new Point(16, 18));
     MakeWaypoints();
     MakeSprites();
     ResetPosition();
 }
Exemplo n.º 8
0
        //Ghosts leave the ghost house at the start of round
        //Привиди залишають свою домівку на початку раунду
        public void ExitHouse()
        {
            location.X = (float)Math.Round(location.X);
            location.Y = (float)Math.Round(location.Y);
            PointF exitPoint = PacForm.coordToPixelCenter(new Point(14, 14));

            exitPoint.X -= PacForm.BoardTileSize * PacForm.SpriteScale / 4;
            if (location.X > exitPoint.X)
            {
                location.X -= 1; direction = 1;
            }
            else if (location.X < exitPoint.X)
            {
                location.X += 1; direction = 3;
            }
            else if (location.X == exitPoint.X && location.Y > exitPoint.Y)
            {
                location.Y -= 1; direction = 0;
            }
            else if (location.X == exitPoint.X && location.Y < exitPoint.Y)
            {
                location.Y += 1; direction = 2;
            }
            if (location == exitPoint)
            {
                exited = true;
                int dir = random.Next(0, 2);
                if (dir > 0)
                {
                    direction = 1;
                }
                else
                {
                    direction = 3;
                }
            }
        }
Exemplo n.º 9
0
        //Usual movement. Звичайний рух
        void NormalMovement()
        {
            switch (direction)
            {
            case 0:
                PacManCollision();
                location = new PointF(location.X, location.Y -= speed);
                if (location.Y % PacForm.boardUnitSize < PacForm.unitCenter)
                {
                    if (reverseDirection)
                    {
                        reverseDirection = false;
                        ReverseDirection();
                    }
                    else
                    {
                        direction  = nextDirection;
                        location.X = PacForm.coordToPixelCenter(PacForm.pixelToCoord(location)).X;
                    }
                }
                PacManCollision();
                break;

            case 1:
                PacManCollision();
                location = new PointF(location.X -= speed, location.Y);
                if (location.X % PacForm.boardUnitSize < PacForm.unitCenter)
                {
                    if (reverseDirection)
                    {
                        reverseDirection = false;
                        ReverseDirection();
                    }
                    else
                    {
                        direction  = nextDirection;
                        location.Y = PacForm.coordToPixelCenter(PacForm.pixelToCoord(location)).Y;
                    }
                }
                PacManCollision();
                break;

            case 2:
                PacManCollision();
                location = new PointF(location.X, location.Y += speed);
                if (location.Y % PacForm.boardUnitSize > PacForm.unitCenter)
                {
                    if (reverseDirection)
                    {
                        reverseDirection = false;
                        ReverseDirection();
                    }
                    else
                    {
                        direction  = nextDirection;
                        location.X = PacForm.coordToPixelCenter(PacForm.pixelToCoord(location)).X;
                    }
                }
                PacManCollision();
                break;

            case 3:
                PacManCollision();
                location = new PointF(location.X += speed, location.Y);
                if (location.X % PacForm.boardUnitSize > PacForm.unitCenter)
                {
                    if (reverseDirection)
                    {
                        reverseDirection = false;
                        ReverseDirection();
                    }
                    else
                    {
                        direction  = nextDirection;
                        location.Y = PacForm.coordToPixelCenter(PacForm.pixelToCoord(location)).Y;
                    }
                }
                PacManCollision();
                break;
            }

            if (location.X < 0)
            {
                location = new PointF(location.X + form.board.boardPBSize.Width, location.Y);
            }
            if (location.X >= form.board.boardPBSize.Width)
            {
                location = new PointF(location.X - form.board.boardPBSize.Width, location.Y);
            }
        }