예제 #1
0
 public void RemoveShipInfo(FleetAccordion fleetAccordion, ShipInfo shipInfo)
 {
     foreach (FleetAccordion accordion in _fleetAccordionList)
     {
         if (accordion == fleetAccordion)
         {
             accordion.RemoveShipInfo(shipInfo);
             break;
         }
     }
     LayoutRebuilder.ForceRebuildLayoutImmediate(_rectTransform);
 }
예제 #2
0
        public void AddShip(Ship ship)
        {
            GameObject shipInfo = Instantiate(ShipInfoPrefab);

            shipInfo.transform.SetParent(transform, false);
            var rectTransform = ((RectTransform)(shipInfo.transform));

            rectTransform.sizeDelta = new Vector2(30, rectTransform.sizeDelta.y);
            ShipInfo info = shipInfo.GetComponent <ShipInfo>();

            info.PopulateShortData(ship);
            ShipList.Add(ship);
        }
예제 #3
0
 public void OnEndDrag(PointerEventData eventData)
 {
     Destroy(_dragDupe.gameObject);
     _dragDupe = null;
     _dragRect = null;
     if (OnShipInfoEndDrag != null)
     {
         if (CurrentlySelected.Any())
         {
             OnShipInfoEndDrag(eventData, CurrentlySelected.Select(si => si.GetComponent <ShipInfo>()));
         }
         else
         {
             OnShipInfoEndDrag(eventData, Enumerable.Repeat(this, 1));
         }
     }
 }
예제 #4
0
 public void PopulateShips(IEnumerable <Ship> ships)
 {
     _shipInfoList = new List <ShipInfo>();
     foreach (Transform child in transform)
     {
         GameObject.Destroy(child.gameObject);
     }
     foreach (Ship ship in ships)
     {
         GameObject shipInfo = Instantiate(ShipInfoPrefab);
         shipInfo.transform.SetParent(transform, false);
         ShipInfo info = shipInfo.GetComponent <ShipInfo>();
         _shipInfoList.Add(info);
         info.PopulateShipData(ship);
         info.OnShipInfoEndDrag += OnShipInfoEndDrag;
         info.OnShipInfoDrag    += OnShipInfoDrag;
     }
 }
예제 #5
0
 public void RemoveShipInfo(ShipInfo shipInfo)
 {
     _shipInfoList.Remove(shipInfo);
     foreach (Transform child in transform)
     {
         if (child == shipInfo.transform)
         {
             GameObject.Destroy(child.gameObject);
             break;
         }
     }
     // because childCount isn't updated until the end of the frame,
     // a child count of 1 means we just emptied the list
     if (_shipInfoList.Count == 0 && OnShipDisplayEmpty != null)
     {
         OnShipDisplayEmpty();
     }
     else
     {
         LayoutRebuilder.ForceRebuildLayoutImmediate(_rectTransform);
     }
 }
예제 #6
0
 public void RemoveShipInfo(ShipInfo shipInfo)
 {
     FleetShipList.RemoveShipInfo(shipInfo);
 }