void Formation(PirateGame game) { if (collector.IsAlive()) { if (collector.Capsule == null) { if (!TryPush(collector, game)) { collector.Sail(game.GetMyCapsule()); } } else { if (!TryPush(collector, game)) { collector.Sail(game.GetMyMothership().Location); } } } else { Pirate temp = collector; for (int i = 0; i < 2; i++) { if (bodyGuards[i].IsAlive() && !collector.IsAlive()) { collector = bodyGuards[i]; bodyGuards[i] = temp; break; } } } if (bodyGuards[0].IsAlive()) { if (!TryPush(bodyGuards[0], game)) { bodyGuards[0].Sail(new Location(collector.Location.Row + offsetY, collector.Location.Col - offsetX)); } } if (bodyGuards[1].IsAlive()) { if (!TryPush(bodyGuards[1], game)) { bodyGuards[1].Sail(new Location(collector.Location.Row + offsetY, collector.Location.Col + offsetX)); } } if (tailGuard.IsAlive()) { if (!TryPush(tailGuard, game)) { tailGuard.Sail(new Location(collector.Location.Row + offsetY, collector.Location.Col)); } } }
/* Execute a series of steps */ public void GoTo(PirateGame game, LinkedList <Location> locationList) { if (_traveling) { /* SPirate is currently traveling */ if (_pirate.GetLocation() == _currentMapTarget.Value) { //Pirate reached destination if (_currentMapTarget.Next == null) { _traveling = false; } else { _currentMapTarget = _currentMapTarget.Next; } } else { //Traveling but still hasn't reached destination if (_pirate.IsAlive()) { game.SetSail(_pirate, game.GetSailOptions(_pirate, _currentMapTarget.Value)[0]); } } } else { //Not traveling, insert new list _mapTargetBuffer = locationList; } }