static SerializablePortShipList ConvertShipListToStruct(List <Ship> list) { SerializablePortShipList result = new SerializablePortShipList(); int length = list.Count; result.shipNames = new string[length]; result.shipTypes = new string[length]; result.shipCrewCounts = new int[length]; result.shipCrewMaxes = new int[length]; for (int i = 0; i < length; i++) { result.shipNames [i] = list [i].name; result.shipTypes [i] = PrefabUtility.GetPrefabParent(list [i].gameObject).name; result.shipCrewCounts [i] = 2; result.shipCrewMaxes [i] = 3; // Placeholder numbers; TODO: Give ships a max crew number } return(result); }
void TargetUpdateDockedShipList(NetworkConnection target, SerializablePortShipList shipList) { // Delete all items currently in the ship list foreach (ShipListItem menuItem in contentPanel.GetComponentsInChildren <ShipListItem>()) { Destroy(menuItem.gameObject); } // Make ShipListItem prefabs from the serializable list and put them in the ship menu for (int i = 0; i < shipList.shipNames.Length; i++) { GameObject newListItem = Instantiate(listItemPrefab) as GameObject; ShipListItem item = newListItem.GetComponent <ShipListItem> (); item.name.text = shipList.shipNames [i]; item.type.text = shipList.shipTypes [i]; item.crew.text = "Crew: " + shipList.shipCrewCounts [i] + "/" + shipList.shipCrewMaxes [i]; newListItem.transform.parent = contentPanel.transform; newListItem.transform.localScale = Vector3.one; } }