예제 #1
0
 protected virtual void OnDestroy()
 {
     if (_rangeRenderer != null)
     {
         _rangeRenderer.VisibleProperty.ClearBinding();
         _rangeRenderer.RangeProperty.ClearBinding();
         _rangeRenderer = null;
     }
     if (_towerRendererBinding != null)
     {
         _towerRendererBinding.SpriteProperty.ClearBinding();
         _towerRendererBinding = null;
     }
 }
예제 #2
0
        protected virtual void Start()
        {
            var tower = GetComponent <TTower>();

            _towerModel = tower.Model;
            _towerModel.LevelProperty.PropertyChanged += LevelOnPropertyChanged;

            ViewModel.OnLevelChange(_towerModel.Levels[_towerModel.LevelProperty.GetValue()]);

            _rangeRenderer = GetComponentInChildren <RangeRenderer>();
            _rangeRenderer.VisibleProperty.Bind(BindingType.OneWay, ViewModel.VisibleProperty);
            _rangeRenderer.RangeProperty.Bind(BindingType.OneWay, ViewModel.RangeProperty);

            _towerRendererBinding = tower.TowerTransform.gameObject.GetComponent <SpriteRendererBinding>();
            _towerRendererBinding.SpriteProperty.Bind(BindingType.OneWay, ViewModel.TowerSpriteProperty);
        }