Advertisement
CmdEngineer

Untitled

Feb 7th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. private bool TryPush(Pirate pirate, PirateGame game)
  2.         {
  3.             foreach (Pirate enemy in game.GetEnemyLivingPirates())/* the list of all enemeis */
  4.             {
  5.                 if (pirate.CanPush(enemy)) /* if the pirate can push */
  6.                 {
  7.                     /* Push enemy! */
  8.                     int x = enemy.GetLocation().Row;
  9.                     int y = enemy.GetLocation().Col;
  10.                     int top = enemy.GetLocation().Distance(new Location(x, 0));
  11.                     int left = enemy.GetLocation().Distance(new Location(0, y));
  12.                     int right = enemy.GetLocation().Distance(new Location(6400, y));
  13.                     int bottom = enemy.GetLocation().Distance(new Location(x, 6400));
  14.                     Location loc = game.GetMyMothership().GetLocation();
  15.                    
  16.                     if(top < left && top < right && top < bottom)
  17.                     {
  18.                         loc = new Location(x, 0);
  19.                     }
  20.                     else if(left < top && left < right && left < bottom)
  21.                     {
  22.                         loc = new Location(0, y);
  23.                     }
  24.                     else if(right < top && right < left && right < bottom)
  25.                     {
  26.                         loc = new Location(6400, y);
  27.                     }
  28.                     else if(bottom < top && bottom < left && bottom < right)
  29.                     {
  30.                         loc = new Location(x, 6400);
  31.                     }
  32.                     pirate.Push(enemy, (MapObject)loc);
  33.                    
  34.  
  35.                     /* Did push */
  36.                     return true;
  37.                 }
  38.             }
  39.  
  40.             /* Didn't push. */
  41.             return false;
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement