Esempio n. 1
0
        public void PlayerShoot(Move m)
        {
            Coord checkLocation = m.player.location.Clone();
            Coord transform;

            switch (m.dir)
            {
            case "N":
                transform = Coord.N;
                break;

            case "NE":
                transform = Coord.NE;
                break;

            case "E":
                transform = Coord.E;
                break;

            case "SE":
                transform = Coord.SE;
                break;

            case "S":
                transform = Coord.S;
                break;

            case "SW":
                transform = Coord.SW;
                break;

            case "W":
                transform = Coord.W;
                break;

            case "NW":
                transform = Coord.NW;
                break;

            default:
                transform = null;
                break;
            }

            do
            {
                checkLocation = Coord.Add(checkLocation, transform);
                int pl = WhichPlayerLocation(checkLocation);
                if (pl != -1)
                {
                    if (!supressOutput && !Globals.supressAllOutput)
                    {
                        Console.WriteLine("Shot HIT player " + (pl + 1));
                    }
                    switch (m.target)
                    {
                    case "HEAD":
                        players[pl].health--;
                        if (players[pl].health == 0)
                        {
                            players[pl].health = 3;
                            PlayerToSpawn(players[pl]);
                            m.player.score++;
                        }
                        break;

                    case "LARM":
                        foreach (Move p in players[pl].program)
                        {
                            p.ArmHit(true);
                        }
                        break;

                    case "RARM":
                        foreach (Move p in players[pl].program)
                        {
                            p.ArmHit(false);
                        }
                        break;

                    case "LLEG":
                        foreach (Move p in players[pl].program)
                        {
                            p.LegHit(true);
                        }
                        break;

                    case "RLEG":
                        foreach (Move p in players[pl].program)
                        {
                            p.LegHit(false);
                        }
                        break;

                    case "BODY":
                        Coord pushedLoc = Coord.Add(players[pl].location, transform);
                        if (IsOnBoard(pushedLoc) && !IsPlayerLocation(pushedLoc))
                        {
                            if (IsHoleLocation(pushedLoc))
                            {
                                players[pl].health--;
                                if (players[pl].health <= 0)
                                {
                                    players[pl].health = 3;
                                    players[pl].score--;
                                }
                                PlayerToSpawn(players[pl]);
                                m.player.score++;
                                if (!supressOutput && !Globals.supressAllOutput)
                                {
                                    Console.WriteLine("Player " + (m.player.number + 1) + " fell down a hole!");
                                }
                            }
                            else
                            {
                                players[pl].location = pushedLoc;
                            }
                        }
                        break;
                    }
                    break;
                }
            } while (IsOnBoard(checkLocation));
        }
Esempio n. 2
0
 public bool IsOnBoard(Coord c)
 {
     return((c.x >= 0) && (c.y >= 0) && (c.x < Globals.width) && (c.y < Globals.height));
 }
Esempio n. 3
0
 public void Print()
 {
     if (!Globals.supressAllOutput)
     {
         Console.WriteLine("");
     }
     for (int i = 0; i < Globals.numPlayers; i++)
     {
         if (!Globals.supressAllOutput)
         {
             Console.WriteLine("Player " + (i + 1) + " : Health=" + players[i].health + "   Score=" + players[i].score);
         }
     }
     if (!Globals.supressAllOutput)
     {
         Console.WriteLine("");
     }
     if (!Globals.supressAllOutput)
     {
         Console.Write("╔");
     }
     for (int x = 0; x < Globals.width; x++)
     {
         if (!Globals.supressAllOutput)
         {
             Console.Write("═══");
         }
     }
     if (!Globals.supressAllOutput)
     {
         Console.WriteLine("╗");
     }
     for (int y = Globals.height - 1; y >= 0; y--)
     {
         if (!Globals.supressAllOutput)
         {
             Console.Write("║");
         }
         for (int x = 0; x < Globals.width; x++)
         {
             Coord cell = new Coord(x, y);
             if (IsControlLocation(cell))
             {
                 if (!Globals.supressAllOutput)
                 {
                     Console.Write(" § ");
                 }
                 continue;
             }
             if (cell.IsInArray(holeLocations))
             {
                 if (!Globals.supressAllOutput)
                 {
                     Console.Write(" ▓ ");
                 }
             }
             else
             {
                 int l = WhichPlayerLocation(cell);
                 if (l != -1)
                 {
                     if (!Globals.supressAllOutput)
                     {
                         Console.Write(" " + (l + 1) + " ");
                     }
                 }
                 else
                 {
                     if (!Globals.supressAllOutput)
                     {
                         Console.Write(" · ");                            //×·
                     }
                 }
             }
         }
         if (!Globals.supressAllOutput)
         {
             Console.WriteLine("║");
         }
     }
     if (!Globals.supressAllOutput)
     {
         Console.Write("╚");
     }
     for (int x = 0; x < Globals.width; x++)
     {
         if (!Globals.supressAllOutput)
         {
             Console.Write("═══");
         }
     }
     if (!Globals.supressAllOutput)
     {
         Console.WriteLine("╝");
     }
 }