Example #1
0
 public void Reset()
 {
     Layer = 0;
     ID    = 0;
     if (Screen != null)
     {
         UnityEngine.GameObject.Destroy(Screen.gameObject);
     }
     Screen = null;
 }
Example #2
0
        public void Run()
        {
            if (_filter.IsEmpty())
            {
                return;
            }

            foreach (var i in _filter)
            {
                _screenFound = false;

                foreach (var j in _screens)
                {
                    if (_screens.Get1[j].Layer == _filter.Get1[i].Layer)
                    {
                        if (_screens.Get1[j].ID == _filter.Get1[i].ID)
                        {
                            _screens.Get1[j].Active = true;
                            _screens.Get1[j].Screen.Show();
                            _screenFound = true;
                        }
                        else if (_screens.Get1[j].Active)
                        {
                            _screens.Get1[j].Active = false;
                            _screens.Get1[j].Screen.Hide();
                        }
                    }
                }

                // spawn screen
                if (!_screenFound)
                {
                    ECSUIScreen screen = GameObject.Instantiate(_screensCollection.GetScreen(_filter.Get1[i].ID, _filter.Get1[i].Layer), _screensRoot)
                                         .Init(_world, _filter.Get1[i].ID, _filter.Get1[i].Layer);
                    UIScreen entity = _world.NewEntity().Set <UIScreen>();
                    entity.ID     = _filter.Get1[i].ID;
                    entity.Layer  = _filter.Get1[i].Layer;
                    entity.Active = true;
                    entity.Screen = screen;
                    screen.Show();
                    _world.NewEntity().Set <Modules.CoreGame.UIUpdate>();
                }

                _filter.Entities[i].Destroy(); // cleanup
            }
        }