Exemplo n.º 1
0
 public GhostRun(frmPacmanGame frm, PacmanBoard b, GhostColor color)
 {
     this.color = color;
     parentForm = frm;
     board      = b;
     this.Init();
 }
Exemplo n.º 2
0
 public GhostRun(frmPacmanGame frm, PacmanBoard b, GhostColor color, int algorithm, int stage)
 {
     this.color     = color;
     parentForm     = frm;
     board          = b;
     this.algorithm = algorithm;
     this.stage     = stage;
     this.Init();
 }
Exemplo n.º 3
0
        private void changePic(Point P, Direction D, GhostColor color, bool sprite1, GhostState state)
        {
            switch (color)
            {
            case GhostColor.RED:
                if (picRedGhost != null)
                {
                    pnl.Controls.Remove(picRedGhost);
                }
                picRedGhost = new PictureBox();
                picRedGhost.BackgroundImageLayout = ImageLayout.Zoom;
                picRedGhost.Location        = new Point((int)(P.X * cellWidth + 4), (int)(P.Y * cellHeight + 4));
                picRedGhost.Size            = new Size((int)(4 * cellWidth) - 6, (int)(4 * cellHeight) - 6);
                picRedGhost.BackgroundImage = findImage(D, color, sprite1, state);
                pnl.Controls.Add(picRedGhost);
                break;

            case GhostColor.BLUE:
                if (picBlueGhost != null)
                {
                    pnl.Controls.Remove(picBlueGhost);
                }
                picBlueGhost = new PictureBox();
                picBlueGhost.BackgroundImageLayout = ImageLayout.Zoom;
                picBlueGhost.Location        = new Point((int)(P.X * cellWidth + 4), (int)(P.Y * cellHeight + 4));
                picBlueGhost.Size            = new Size((int)(4 * cellWidth) - 6, (int)(4 * cellHeight) - 6);
                picBlueGhost.BackgroundImage = findImage(D, color, sprite1, state);
                pnl.Controls.Add(picBlueGhost);
                break;

            case GhostColor.PINK:
                if (picPinkGhost != null)
                {
                    pnl.Controls.Remove(picPinkGhost);
                }
                picPinkGhost = new PictureBox();
                picPinkGhost.BackgroundImageLayout = ImageLayout.Zoom;
                picPinkGhost.Location        = new Point((int)(P.X * cellWidth + 4), (int)(P.Y * cellHeight + 4));
                picPinkGhost.Size            = new Size((int)(4 * cellWidth) - 6, (int)(4 * cellHeight) - 6);
                picPinkGhost.BackgroundImage = findImage(D, color, sprite1, state);
                pnl.Controls.Add(picPinkGhost);
                break;

            case GhostColor.YELLOW:
                if (picYellowGhost != null)
                {
                    pnl.Controls.Remove(picYellowGhost);
                }
                picYellowGhost = new PictureBox();
                picYellowGhost.BackgroundImageLayout = ImageLayout.Zoom;
                picYellowGhost.Location        = new Point((int)(P.X * cellWidth + 4), (int)(P.Y * cellHeight + 4));
                picYellowGhost.Size            = new Size((int)(4 * cellWidth) - 6, (int)(4 * cellHeight) - 6);
                picYellowGhost.BackgroundImage = findImage(D, color, sprite1, state);
                pnl.Controls.Add(picYellowGhost);
                break;
            }
        }
Exemplo n.º 4
0
        public void SetGhostState(GhostColor color, GhostState state)
        {
            switch (color)
            {
            case GhostColor.RED: RedGhost.gState = state; break;

            case GhostColor.BLUE: BlueGhost.gState = state; break;

            case GhostColor.PINK: PinkGhost.gState = state; break;

            case GhostColor.YELLOW: YellowGhost.gState = state; break;
            }
        }
Exemplo n.º 5
0
        public void setCollision(GhostColor color)
        {
            switch (color)
            {
            case GhostColor.RED:
                redCollision = true;
                break;

            case GhostColor.BLUE:
                blueCollision = true;
                break;

            case GhostColor.PINK:
                pinkCollision = true;
                break;

            case GhostColor.YELLOW:
                yellowCollision = true;
                break;
            }
        }
        public MovingGhost(GhostColor color)
        {
            //Initalizes the instances of ghosts, images and starting positions
            switch (color)
            {
            case GhostColor.Red:
                Position = new Point(22, 8);
                ghostImage[(int)EyePosition.Left]  = Images.redGhost_left;
                ghostImage[(int)EyePosition.Right] = Images.redGhost_right;
                break;

            case GhostColor.Blue:
                Position = new Point(20, 8);
                ghostImage[(int)EyePosition.Left]  = Images.blueGhost_left;
                ghostImage[(int)EyePosition.Right] = Images.blueGhost_right;
                break;

            default:
                break;
            }
            Color = color;
            stepsBeforeChangeDirection = rnd.Next(7);
            currentDirection           = Direction.Up;
        }
Exemplo n.º 7
0
        public IDictionary <Direction, ISprite> getGhostSprite(GhostColor color)
        {
            string resource = $"Sprites.ghost_{color.ToString().ToLower()}.png";

            return(DirectionSprite(resource, GHOST_ANIMATION_FRAMES));
        }
Exemplo n.º 8
0
 public Ghost(GhostColor color, Position pos, int id) : base(id, pos)
 {
     Color = color;
 }
Exemplo n.º 9
0
        private Bitmap findImage(Direction D, GhostColor color, bool sprite1, GhostState state)
        {
            if (state == GhostState.BONUSEND)
            {
                if (sprite1)
                {
                    return(new Bitmap(Properties.Resources.BonusWGhost1));
                }
                else
                {
                    return(new Bitmap(Properties.Resources.BonusWGhost2));
                }
            }
            else if (state == GhostState.BONUS)
            {
                if (sprite1)
                {
                    return(new Bitmap(Properties.Resources.BonusBGhost1));
                }
                else
                {
                    return(new Bitmap(Properties.Resources.BonusBGhost2));
                }
            }
            else if (state == GhostState.EATEN)
            {
                switch (D)
                {
                case Direction.DOWN: return(new Bitmap(Properties.Resources.eyesDown));

                case Direction.UP: return(new Bitmap(Properties.Resources.eyesUp));

                case Direction.RIGHT: return(new Bitmap(Properties.Resources.eyesRight));

                case Direction.LEFT: return(new Bitmap(Properties.Resources.eyesLeft));

                default: return(null);
                }
            }
            else
            {
                switch (color)
                {
                case GhostColor.RED:
                    switch (D)
                    {
                    case Direction.DOWN: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.RedGhostDown1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.RedGhostDown2));
                        }

                    case Direction.UP: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.RedGhostUp1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.RedGhostUp2));
                        }

                    case Direction.RIGHT: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.RedGhostRight1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.RedGhostRight2));
                        }

                    case Direction.LEFT: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.RedGhostLeft1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.RedGhostLeft2));
                        }

                    default: return(null);
                    }

                case GhostColor.BLUE:
                    switch (D)
                    {
                    case Direction.DOWN: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostDown1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostDown2));
                        }

                    case Direction.UP: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostUp1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostUp2));
                        }

                    case Direction.RIGHT: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostRight1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostRight2));
                        }

                    case Direction.LEFT: if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostLeft1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.BlueGhostLeft2));
                        }

                    default: return(null);
                    }

                case GhostColor.PINK:
                    switch (D)
                    {
                    case Direction.DOWN:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostDown1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostDown2));
                        }

                    case Direction.UP:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostUp1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostUp2));
                        }

                    case Direction.RIGHT:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostRight1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostRight2));
                        }

                    case Direction.LEFT:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostLeft1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.PinkGhostLeft2));
                        }

                    default: return(null);
                    }

                case GhostColor.YELLOW:
                    switch (D)
                    {
                    case Direction.DOWN:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostDown1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostDown2));
                        }

                    case Direction.UP:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostUp1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostUp2));
                        }

                    case Direction.RIGHT:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostRight1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostRight2));
                        }

                    case Direction.LEFT:
                        if (sprite1)
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostLeft1));
                        }
                        else
                        {
                            return(new Bitmap(Properties.Resources.YellowGhostLeft2));
                        }

                    default: return(null);
                    }

                default: return(null);
                }
            }
        }
Exemplo n.º 10
0
 public void GhostMove(Point P, Direction D, GhostColor color, bool sprite1, GhostState state)
 {
     pnl.Invoke(new GhostPaint(changePic), P, D, color, sprite1, state);
 }
Exemplo n.º 11
0
 public ServerGhost(GhostColor color, Position pos, int id, Speed speed) : base(color, pos, id)
 {
     Speed = speed;
 }
Exemplo n.º 12
0
    // 何色を生成するか指定できる
    private void Spawn(GhostColor ghostColor)
    {
        GameObject goGhost = Instantiate(spawnGhosts[(int)ghostColor]);

        goGhost.GetComponent <GhostController> ().WarpRandomPos();
    }