Exemplo n.º 1
0
 Directions CheckDirections(person ghost)
 {
     if (ghost.moving == Directions.up)
     {
         if (maze[ghost.y - 1][ghost.x] == ' ')
         {
             return(ghost.moving);
         }
         else
         {
             if (maze[ghost.y][ghost.x - 1] == ' ')
             {
                 return(Directions.left);
             }
             else
             {
                 return(Directions.right);
             }
         }
     }
     else if (ghost.moving == Directions.right)
     {
         if (ghost.x == 27 || maze[ghost.y][ghost.x + 1] == ' ')
         {
             return(ghost.moving);
         }
         else
         {
             if (maze[ghost.y - 1][ghost.x] == ' ')
             {
                 return(Directions.up);
             }
             else
             {
                 return(Directions.down);
             }
         }
     }
     else if (ghost.moving == Directions.down)
     {
         if (maze[ghost.y + 1][ghost.x] == ' ')
         {
             return(ghost.moving);
         }
         else
         {
             if (maze[ghost.y][ghost.x - 1] == ' ')
             {
                 return(Directions.left);
             }
             else
             {
                 return(Directions.right);
             }
         }
     }
     else
     {
         if (ghost.x == 0 || maze[ghost.y][ghost.x - 1] == ' ')
         {
             return(ghost.moving);
         }
         else
         {
             if (maze[ghost.y - 1][ghost.x] == ' ')
             {
                 return(Directions.up);
             }
             else
             {
                 return(Directions.down);
             }
         }
     }
 }
Exemplo n.º 2
0
        private void MovePerson(ref person temp)
        {
            if (temp.moving == Directions.up && (map[temp.y - 1][temp.x] == '0' || map[temp.y - 1][temp.x] == ' ' || map[temp.y - 1][temp.x] == '5' || map[temp.y - 1][temp.x] == '2'))
            {
                temp.y -= 1;
            }
            else if (temp.moving == Directions.down && (map[temp.y + 1][temp.x] == '0' || map[temp.y + 1][temp.x] == ' ' || map[temp.y + 1][temp.x] == '5' || (!temp.pacman && map[temp.y + 1][temp.x] == '2')))
            {
                temp.y += 1;
            }
            else if (temp.moving == Directions.left && (temp.x == 0 || (map[temp.y][temp.x - 1] == '4' || map[temp.y][temp.x - 1] == '0' || map[temp.y][temp.x - 1] == ' ' || map[temp.y][temp.x - 1] == '5')))
            {
                temp.x -= 1;
                if (temp.x == -1)
                {
                    temp.x = 27;
                }
            }
            else if (temp.moving == Directions.right && (temp.x == 27 || (map[temp.y][temp.x + 1] == '4' || map[temp.y][temp.x + 1] == '0' || map[temp.y][temp.x + 1] == ' ' || map[temp.y][temp.x + 1] == '5')))
            {
                temp.x += 1;
                if (temp.x == 28)
                {
                    temp.x = 0;
                }
            }
            if (temp.pacman && (map[temp.y][temp.x] == '0'))
            {
                score      += 50;
                label2.Text = Convert.ToString(score);
                dotsLeft--;
                map[temp.y][temp.x] = ' ';
                label5.Text         = Convert.ToString((decimal)scared * timer4.Interval / 1000);
                label5.Show();
                timer2.Stop();
                timer3.Stop();
                timer4.Start();
                scared        = 20;
                pink.moving   = (Directions)(((int)pink.moving + 2) % 2);
                orange.moving = (Directions)(((int)orange.moving + 2) % 2);
                blue.moving   = (Directions)(((int)blue.moving + 2) % 2);
                red.moving    = (Directions)(((int)red.moving + 2) % 2);
                nextKill      = 1;

                red.scared    = true;
                blue.scared   = true;
                pink.scared   = true;
                orange.scared = true;
            }
            if (temp.pacman && map[temp.y][temp.x] == '5')
            {
                score += 10;
                dotsLeft--;
                label2.Text         = Convert.ToString(score);
                map[temp.y][temp.x] = ' ';
            }
            if (temp.pacman && map[temp.y][temp.x] == '4')
            {
                score              += BonusScores[Math.Min(level - 1, 7)];
                label2.Text         = Convert.ToString(score);
                map[temp.y][temp.x] = ' ';
            }
            if (dotsLeft == 0)
            {
                NextLevel();
            }
            if (dotsLeft == 174 || dotsLeft == 74)
            {
                map[17][14] = '4';
                timer6.Start();
            }
        }
Exemplo n.º 3
0
 Directions RandomDirection(person ghost)
 {
     if (ghost.moving == Directions.up)
     {
         List <Directions> options = new List <Directions>();
         if (maze[ghost.y - 1][ghost.x] == ' ')
         {
             options.Add(Directions.up);
         }
         if (maze[ghost.y][(ghost.x + 1) % 28] == ' ')
         {
             options.Add(Directions.right);
         }
         if (maze[ghost.y][ghost.x - 1 >= 0?ghost.x - 1:27] == ' ')
         {
             options.Add(Directions.left);
         }
         return(options[thing.Next(options.Count)]);
     }
     else if (ghost.moving == Directions.down)
     {
         List <Directions> options = new List <Directions>();
         if (maze[ghost.y + 1][ghost.x] == ' ')
         {
             options.Add(Directions.down);
         }
         if (maze[ghost.y][(ghost.x + 1) % 28] == ' ')
         {
             options.Add(Directions.right);
         }
         if (maze[ghost.y][ghost.x - 1 >= 0 ? ghost.x - 1 : 27] == ' ')
         {
             options.Add(Directions.left);
         }
         return(options[thing.Next(options.Count)]);
     }
     else if (ghost.moving == Directions.left)
     {
         List <Directions> options = new List <Directions>();
         if (maze[ghost.y - 1][ghost.x] == ' ')
         {
             options.Add(Directions.up);
         }
         if (maze[ghost.y + 1][ghost.x] == ' ')
         {
             options.Add(Directions.down);
         }
         if (maze[ghost.y][ghost.x - 1 >= 0 ? ghost.x - 1 : 27] == ' ')
         {
             options.Add(Directions.left);
         }
         return(options[thing.Next(options.Count)]);
     }
     else
     {
         List <Directions> options = new List <Directions>();
         if (maze[ghost.y - 1][ghost.x] == ' ')
         {
             options.Add(Directions.up);
         }
         if (maze[ghost.y][(ghost.x + 1) % 28] == ' ')
         {
             options.Add(Directions.right);
         }
         if (maze[ghost.y + 1][ghost.x] == ' ')
         {
             options.Add(Directions.down);
         }
         return(options[thing.Next(options.Count)]);
     }
 }
Exemplo n.º 4
0
 Directions ReturnToBase(person ghost)
 {
     return(FindMove(ghost, 14, 14));
 }
Exemplo n.º 5
0
        private void Table1Add(int i)
        {
            person p1 = new person(table[i].Name, table[i].Adress, table[i].Job, table[i].Education, table[i].Rank, table[i].DateRank, table[i].Post, table[i].Unit, table[i].ServiceForm, table[i].ServicePeriod, table[i].Character);

            table1.Add(p1);
        }