public void Extend(IContext context) { IMediatorMap mediatorMap = context.injector.GetInstance <IMediatorMap> (); IEventCommandMap commandMap = context.injector.GetInstance <IEventCommandMap> (); // Sound context.injector.Map <ISoundModel>().ToSingleton <SoundModel>(); commandMap.Map(SoundEvent.Type.PLAY_SOUND_EFFECT).ToCommand <PlaySoundCommand>(); commandMap.Map(SoundEvent.Type.PLAY_MUSIC_TRACK).ToCommand <PlaySoundCommand>(); commandMap.Map(SoundEvent.Type.STOP_MUSIC_TRACK).ToCommand <PlaySoundCommand>(); commandMap.Map(SoundEvent.Type.STOP_SOUND_EFFECTS).ToCommand <PlaySoundCommand>(); commandMap.Map(SoundVolumeEvent.Type.SET_MUSIC_VOLUME).ToCommand <SetSoundVolumeCommand>(); commandMap.Map(SoundVolumeEvent.Type.SET_SOUND_EFFECTS_VOLUME).ToCommand <SetSoundVolumeCommand>(); mediatorMap.Map(typeof(SoundLoaderView)).ToMediator(typeof(SoundLoaderMediator)); mediatorMap.Map(typeof(ISoundSetView)).ToMediator(typeof(SoundSetMediator)); mediatorMap.Map(typeof(ISoundView)).ToMediator(typeof(SoundMediator)); soundFX = new GameObject("SoundFX"); soundMusic = new GameObject("SoundMusic"); soundFX.hideFlags = soundMusic.hideFlags = HideFlags.HideInHierarchy; GameObject.DontDestroyOnLoad(soundFX); GameObject.DontDestroyOnLoad(soundMusic); context.injector.Map <GameObject>(SoundKeys.GAMEOBJECT_EFFECTS).ToValue(soundFX); context.injector.Map <GameObject>(SoundKeys.GAMEOBJECT_MUSIC).ToValue(soundMusic); context.AfterDestroying(Cleanup); }
public void Configure() { eventCommandMap.Map(ClickCountEvent.Type.INCREMENT).ToCommand <IncrementClickCounterCommand>(); mediatorMap.Map <ButtonView> ().ToMediator <ButtonMediator> (); mediatorMap.Map <ClickCountView> ().ToMediator <ClickCountMediator> (); injector.Map <IClickCountModel> ().ToSingleton <ClickCountModel> (); }
public void Configure() { mediatorMap.Map <IDisplayScoreView>().ToMediator <DisplayScoreMediator>(); mediatorMap.Map <ISetScoreView>().ToMediator <SetScoreMediator>(); commandMap.Map(ScoreEvent.Type.SET_SCORE).ToCommand <SetScoreCommand>(); commandMap.Map(ScoreEvent.Type.ADD_TO_SCORE).ToCommand <AddToScoreCommand>(); commandMap.Map(RequestScoreEvent.Type.REQUEST).ToCommand <RequestScoreCommand>(); }
public void Configure() { eventCommandMap.Map(ClickCountEvent.Type.INCREMENT).ToCommand <IncrementClickCounterCommand>(); mediatorMap.Map <ButtonView> ().ToMediator <ButtonMediator> (); mediatorMap.Map <ClickCountView> ().ToMediator <ClickCountMediator> (); injector.Map <IClickCountModel> ().ToSingleton <ClickCountModel> (); context.AfterInitializing(StartApplication); }
private void Awake() { _injector = new Injector(); _directCommand = new DirectCommand(_injector); _eventDispatcher = new EventDispatcher(); _eventCommandMap = new EventCommandMap(_eventDispatcher, _injector); _viewFactory = new ViewFactory(); _mediatorMap = new MediatorMap(_viewFactory, _injector); _entityDatabase = new EntityDatabase(); _systemMap = new SystemMap(_entityDatabase); _updater = new Updater(); _injector.Inject(_directCommand); _injector.Inject(_eventDispatcher); _injector.Inject(_entityDatabase); _injector.Inject(_mediatorMap); _injector.Inject <IUpdater>(_updater); // systems _systemMap.Add(new PlayerMovementSystem()); _systemMap.Add(new PlayerShootingSystem()); _systemMap.Add(new CameraFollowSystem()); _systemMap.Add(new EnemySpawnerSystem()); _systemMap.Add(new EnemyMovementSystem()); _systemMap.Add(new EnemyDamageSystem()); _systemMap.Add(new EnemyAttackSystem()); _systemMap.Add(new PlayerDamageSystem()); _systemMap.Add(new EnemySinkingSystem()); // injection _injector.Inject <IGameData>(gameData); _injector.Inject(new AudioModel()); _injector.Inject(new PlayerHealthModel()); _injector.Inject(new ScoreModel()); // view factory _viewFactory.Register(damageView, false); _viewFactory.Register(gameOverView, false); _viewFactory.Register(healthView, false); _viewFactory.Register(pauseView, false); _viewFactory.Register(scoreView, false); // mediator _mediatorMap.Map <DamageMediator>(ViewType.Damage); _mediatorMap.Map <GameOverMediator>(ViewType.GameOver); _mediatorMap.Map <HealthMediator>(ViewType.Health); _mediatorMap.Map <PauseMediator>(ViewType.Pause); _mediatorMap.Map <ScoreMediator>(ViewType.Score); // event command _eventCommandMap.Map(GameEvent.GameOverComplete, new RestartCommand()); }
public void Configure() { mediatorMap.Map <ILanguageView>().ToMediator <LanguageMediator>(); mediatorMap.Map <ICurrentLanguageView>().ToMediator <CurrentLanguageMediator>(); mediatorMap.Map <IChangeLanguageView>().ToMediator <ChangeLanguageMediator>(); commandMap.Map(LanguageRequestEvent.Type.REQUEST_CONTENT).ToCommand <RequestTextCommand>(); commandMap.Map(LanguageRequestEvent.Type.REQUEST_CURRENT_LANGUAGE).ToCommand <RequestTextCommand>(); commandMap.Map(LanguageEvent.Type.CHANGE_LANGUAGE).ToCommand <ChangeLanguageCommand>(); commandMap.Map(LanguageEvent.Type.CHANGE_LANGUAGE).ToCommand <SaveLanguageCommand>(); string language; if (saveService.LanguageName == null) { language = Enum.GetName(typeof(SystemLanguage), Application.systemLanguage); logger.Info("Setting System Language: {0}", language); } else { language = saveService.LanguageName; logger.Info("Loading Saved Language: {0}", language); } model.SetCurrentLanguage(language); }
public void Configure() { mediatorMap.Map <IHighscoreView>().ToMediator <HighscoreMediator>(); commandMap.Map(ScoreEvent.Type.SCORE_CHANGED).ToCommand <SetHighscoreCommand>(); commandMap.Map(HighscoreRequestEvent.Type.REQUEST).ToCommand <HighscoreRequestCommand>(); }
public void Configure() { mediatorMap.Map <ISendMessageView>().ToMediator <SendMessageMediator>(); mediatorMap.Map <IReceiveMessageView>().ToMediator <ReceiveMessageMediator>(); }
public void Configure() { mediatorMap.Map <DetectSceneChangeView>().ToMediator <DetectSceneChangeMediator>(); context.AfterInitializing(FireInitialCommand); }