Exemplo n.º 1
0
        private void Awake()
        {
            _playerAnimatorConfig = Resources.Load <SpriteAnimatorConfig>("PlayerAnimatorConfig");
            _gumboAnimatorConfig  = Resources.Load <SpriteAnimatorConfig>("GumboAnimatorConfig");
            _boxAnimatorConfig    = Resources.Load <SpriteAnimatorConfig>("BoxAnimatorConfig");
            _coinAnimatorConfig   = Resources.Load <SpriteAnimatorConfig>("CoinAnimatorConfig");
            _UIAnimatorConfig     = Resources.Load <UIAnimatorConfig>("UISpriteAnimatorConfig");

            _playerAnimator = new SpriteAnimator(_playerAnimatorConfig);
            _gumboAnimator  = new SpriteAnimator(_gumboAnimatorConfig);
            _boxAnimator    = new SpriteAnimator(_boxAnimatorConfig);
            _coinAnimator   = new SpriteAnimator(_coinAnimatorConfig);
            _UIAnimator     = new SpriteAnimator(_UIAnimatorConfig);

            _playerContactsPuller     = new ContactsPuller(_playerView.Collider2D);
            _playerController         = new PlayerController(_playerView, _playerAnimator, _playerContactsPuller);
            _gunController            = new Gun(_gunView, _bulletView, _playerView);
            _flagController           = new Flag(_playerView, _flagView);
            _UIController             = new UIController(_UIView, _UIAnimator, _UIAnimatorConfig);
            _levelGeneratorController = new LevelGeneratorController(_levelGeneratorView);

            ///
            _levelGeneratorController.Awake();
            ///

            foreach (Transform gumbo in _gumbos.GetComponentInChildren <Transform>())
            {
                _gumboAnimator.StartAnimation(gumbo.gameObject.GetComponent <SpriteRenderer>(), AnimTrack.Run, true, 5);
            }

            foreach (Transform box in _boxes.GetComponentInChildren <Transform>())
            {
                _boxAnimator.StartAnimation(box.gameObject.GetComponent <SpriteRenderer>(), AnimTrack.Idle, true);
            }

            _coinsView = new List <LevelObjectView>(_coins.transform.childCount);
            foreach (Transform coin in _coins.GetComponentInChildren <Transform>())
            {
                _coinsView.Add(coin.gameObject.GetComponent <LevelObjectView>());
                _coinAnimator.StartAnimation(coin.gameObject.GetComponent <SpriteRenderer>(), AnimTrack.Idle, true, 5);
            }
            _coinController = new Coin(_playerView, _coinsView, _coinAnimator, _UIController);
        }
Exemplo n.º 2
0
 public SpriteAnimator(SpriteAnimatorConfig animatorConfig)
 {
     _config = animatorConfig;
 }