Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool TryPush(Pirate pirate, PirateGame game)
- {
- foreach (Pirate enemy in game.GetEnemyLivingPirates())/* the list of all enemeis */
- {
- if (pirate.CanPush(enemy)) /* if the pirate can push */
- {
- /* Push enemy! */
- int x = enemy.GetLocation().Row;
- int y = enemy.GetLocation().Col;
- int top = enemy.GetLocation().Distance(new Location(x, 0));
- int left = enemy.GetLocation().Distance(new Location(0, y));
- int right = enemy.GetLocation().Distance(new Location(6400, y));
- int bottom = enemy.GetLocation().Distance(new Location(x, 6400));
- Location loc = game.GetMyMothership().GetLocation();
- if(top < left && top < right && top < bottom)
- {
- loc = new Location(x, 0);
- }
- else if(left < top && left < right && left < bottom)
- {
- loc = new Location(0, y);
- }
- else if(right < top && right < left && right < bottom)
- {
- loc = new Location(6400, y);
- }
- else if(bottom < top && bottom < left && bottom < right)
- {
- loc = new Location(x, 6400);
- }
- pirate.Push(enemy, (MapObject)loc);
- /* Did push */
- return true;
- }
- }
- /* Didn't push. */
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement