Пример #1
0
    public Singleton(
        DiContainer container,
        GameStateMachine <JamStateType> gsMachine,
        SessionFlags pSessionFlags,
        [Inject(Id = GameInstaller.GLOBAL_DISPATCHER)]
        IEventDispatcher eventDispatcher,
        GameConfig pGameConfig,
        NetworkManager pNetworkManager,
        GuiManager guiManager,
        ParticleGOD pparticleGod,
        AudioSystem pAudioSystem)
    {
        diContainer            = container;
        sessionFlags           = pSessionFlags;
        gameConfig             = pGameConfig;
        gameStateMachine       = gsMachine;
        notificationDispatcher = eventDispatcher;
        networkManager         = pNetworkManager;
        gui         = guiManager;
        particleGod = pparticleGod;
        audioSystem = pAudioSystem;

        _initialize();
        _instance = this;
    }
    public void Init(Hashtable changeStateData)
    {
        _gameMode = GameMode.COMBAT;

        _playerCombatSystem = _diContainer.Resolve<PlayerCombatSystem>();
        _buildSystem = _diContainer.Resolve<BuildingSystem>();
        _inventorySystem = _diContainer.Resolve<InventorySystem>();
        _enemySystem = _diContainer.Resolve<EnemySystem>();
        _lootSystem = _diContainer.Resolve<LootSystem>();
        _particleGod = _diContainer.Resolve<ParticleGOD>();
        _monsterGenerator = _diContainer.Resolve<MonsterGenerator>();
        
        Singleton.instance.audioSystem.GenerateAudioLookupForLevel();
        _particleGod.InitParticlePool();

        //HUD
        _hudController = new HUDController(_gameConfig.playerConfig,_gameConfig.hudConfig);
        _hudController.Start(() =>
        {
            _monsterGenerator.Init(_hudController, _playerCombatSystem);
        });

        _playerCombatSystem.Init(_hudController);
        _buildSystem.Init();
        _enemySystem.Init();
        _lootSystem.Init();
        _inventorySystem.Init();

        // Get CombatPlayerView
        //_playerCombatSystem.isEnabled = true;
        _dispatcher.AddListener(GameplayEventType.DAMAGE_TAKEN, onDamageTaken);
        _dispatcher.AddListener(GameplayEventType.GAME_COMPLETE, onGameComplete);
        _dispatcher.AddListener(GameplayEventType.GAME_RETRY, onGameRetry);
    }