public static UIElement Shape(this ObjectCategory self) { Canvas shape; switch (self) { case ObjectCategory.ThunderstruckTree: shape = new Thunderstruck(); break; case ObjectCategory.HarvestableTree: shape = new Tree(false); break; case ObjectCategory.FruitedTree: shape = new Tree(true); break; //case ObjectCategory.Uprootable: shape = new Up(); break; case ObjectCategory.ScarecrowGarden: shape = new Garden(); break; case ObjectCategory.SmallHousing: shape = new SmallHouse(); break; case ObjectCategory.Farmhouse: shape = new Farmhouse(); break; case ObjectCategory.LargeHousing: shape = new LargeHouse(); break; case ObjectCategory.HarvestablePlant: shape = new Leaf(); break; case ObjectCategory.ScarecrowFarm: shape = new Farm(); break; case ObjectCategory.HousingWorkbench: shape = new HousingWorkbench(); break; case ObjectCategory.FriendlyPlayer: shape = new PlayerShape(true); break; case ObjectCategory.EnemyPlayer: shape = new PlayerShape(false); break; case ObjectCategory.FriendlyClipper: shape = new Clipper(true); break; case ObjectCategory.EnemyClipper: shape = new Clipper(false); break; case ObjectCategory.FriendlyMerchantShip: shape = new MerchantShip(true); break; case ObjectCategory.EnemyMerchantShip: shape = new MerchantShip(false); break; case ObjectCategory.FriendlyFishingBoat: shape = new FishingShip(true); break; case ObjectCategory.EnemyFishingBoat: shape = new FishingShip(false); break; case ObjectCategory.FriendlyGalleon: shape = new Galleon(true); break; case ObjectCategory.EnemyGalleon: shape = new Galleon(false); break; case ObjectCategory.FriendlyNPC: shape = new NpcShape(true); break; case ObjectCategory.TradePack: shape = new TradePack(); break; case ObjectCategory.Treasure: shape = new Treasure(); break; case ObjectCategory.FishSchool: shape = new Fish(); break; case ObjectCategory.EnemyNPC: shape = new NpcShape(false); break; default: Ellipse dot = DrawSimpleDot(); dot.Fill = self.Color(); return dot; } //need to flip the shape because our canvas is inverted (due to game coordinate system) return Flip(shape); }
/// <summary> /// Attacks the target ship. The attack is instantaneous, because you don't actually have to get near /// the target, your cannons have a very long range. /// The success of your attack depends the number of cannons you have, the number of shields the target has, /// and the distance between you (cannons become less effective over long distances). /// If your attack succeeds, your crew uses shuttles to bring in as much loot from the target ship as they /// can fit in your cargo hold. You cannot take money from the target and their ship can continue its journey. /// If your attack fails, then the target cannot shoot back (because his shields are overloaded and interfere /// with his targeting computer), so you get away unharmed, but you lost time while others were busy making profit! /// </summary> public static async Task <string> RaidAsync(MerchantShip target) { try { await client.RaidAsync(CommandedShip, target.TransponderCode); return(string.Empty); } catch (Exception ex) { return(ex.Message); } }
public void Setup(HexGrid hexGrid, SetupData setupData, WorldController worldController) { CreateWater(setupData); CreateMap(hexGrid, setupData, worldController); //Add temporary ship to do pathfinding and finding harbors MerchantShip setupShip = Instantiate(merchantShip.gameObject).GetComponent <MerchantShip>(); hexGrid.AddUnit(setupShip, worldController.HarborCells[0], false); for (int i = 0; i < worldController.MerchantRoutes.Length; i++) { int tries = 0; //Find harbors for route HexCell startHarbor = Utility.ReturnRandomElementWithCondition(worldController.HarborCells, (h) => h.Unit != null); setupShip.Location = startHarbor; int numberOfHarbors = Random.Range(setupData.routeMinStops, setupData.routeMaxStops + 1); List <HexCell> harbors = new List <HexCell>(numberOfHarbors); harbors.Add(startHarbor); for (int j = 1; j < numberOfHarbors; j++) { HexCell foundHarbor = worldController.GetRandomHarborWithinRange(setupShip, setupData.routeMinLength, setupData.routeMaxLength); if (foundHarbor == null) { break; } harbors.Add(foundHarbor); } if (harbors.Count < 2) { Debug.Log("Did not find enough harbors to add to route, trying with a differnt start harbor"); i--; tries++; if (tries < setupData.routes * 2) { break; } else { continue; } } //Create route between harbors worldController.MerchantRoutes[i] = new Route(harbors.ToArray()); } //Remove Temporary Ship hexGrid.RemoveUnit(setupShip); }
//Creates an AI controlled merchant player with a ship and adds it to controllers private void CreateMerchantPlayer(Route route) { MerchantShip newShip = Instantiate(merchantShip); newShip.transform.SetParent(shipParent); newShip.Setup(route); //Delegates newShip.OnShipBoarded += worldUIView.OpenBoardingView; newShip.OnShipInspected += worldUIView.OpenInspectView; hexGrid.AddUnit(newShip, route.GetSpawnableLocation(), HexDirectionExtension.ReturnRandomDirection(), false); Player newMerchantPlayer = new Player(newShip, null, false); MapTurnSystem.instance.AddPlayerToTurnOrder(newMerchantPlayer); }