/// <summary>
    /// Adding a new boat (used when purchasing a boat)
    /// </summary>
    /// <param name="boat"></param>
    public void AddNewBoat(Boat boat)
    {
        GameObject   go  = Instantiate(_prefabListItem, transform);
        BoatListItem bli = go.GetComponent <BoatListItem>();

        Debug.Assert(bli != null);
        bli.SetBoat(boat);
    }
 public virtual void UpdateView()
 {
     for (int i = 0; i < transform.childCount; ++i)
     {
         Destroy(transform.GetChild(i).gameObject);
     }
     if (_pc != null)
     {
         foreach (Boat b in _pc.AvailableBoats)
         {
             GameObject   go  = Instantiate(_prefabListItem, transform);
             BoatListItem bli = go.GetComponent <BoatListItem>();
             Debug.Assert(bli != null);
             bli.SetBoat(b);
         }
     }
 }
Beispiel #3
0
    public void UpdateDetails(Zone zone)
    {
        _menuButtonsHandler.OnDisplay();
        DragDropReceptor.SetOpenZone(zone);
        Debug.Log("OPEN COUNT: " + zone.PlacedBoats.Count);
        _dragDropReceptor.DragDropZone = zone;
        _name.text         = zone.Descriptor.ZoneName;
        _health.fillAmount = zone.CurrentHealth / zone.Descriptor.MaxHealth;
        _profit.text       = "Profit: " + zone.Descriptor.RentabilityFactor.ToString();
        _risk.text         = "Danger: " + zone.Descriptor.DangerFactor.ToString();
        _preview.sprite    = zone.Descriptor.ZoneBackground;

        foreach (Transform t in _weatherRoot.transform)
        {
            Destroy(t.gameObject);
        }
        foreach (Weather weather in zone.Descriptor.PossibleWeathers)
        {
            Image weatherBackground = GameObject.Instantiate(_weatherPrefab, _weatherRoot);
            Image weatherSprite     = weatherBackground.rectTransform.GetChild(0).GetComponent <Image>();
            weatherSprite.sprite    = weather.WeatherSprite;
            weatherBackground.color = (zone.CurrentWeather == weather) ? _enabledColor : _disabledColor;
        }

        foreach (Transform t in _boatsRoot.transform)
        {
            Destroy(t.gameObject);
        }
        foreach (Boat b in zone.PlacedBoats)
        {
            BoatListItem db = GameObject.Instantiate(_boatPrefab, _boatsRoot);
            db.SetBoat(b);
        }

        if (_gameInfo.Player.CurrentZone == zone)
        {
            //TODO
            Debug.Log("Bateau du joueur à afficher dans ZoneDetails");
            GameObject.Instantiate(_playerBoatPrefab, _boatsRoot);
        }
    }