Beispiel #1
0
 public void InjectInRoomStates(RoomsStates roomsStates)
 {
     _roomsStates = roomsStates;
 }
        public void Initiate()
        {
            var currentAssemblyName = GetType().GetTypeInfo().Assembly.GetName().Name;

            var gameStates   = _runtime.Container.Resolve <GameStates>();
            var gameTriggers = _runtime.Container.Resolve <GameTriggers>();

            var jsonContentProvider = _runtime.Container.Resolve <IContentProvider>();


            _displayablesRepo = _runtime.Container.Resolve <DisplayablesRepo>();

            _displayablesRepo.AddPopulatedDisplayables(() =>
            {
                var displayables = _runtime.Container.Resolve <GameStatesDisplayables>();
                jsonContentProvider.Populate <GameStatesDisplayables>(displayables, currentAssemblyName);
                return(displayables);
            });

            _displayablesRepo.AddPopulatedDisplayables(() =>
            {
                var displayables = _runtime.Container.Resolve <RoomsDisplayables>();
                jsonContentProvider.Populate <RoomsDisplayables>(displayables, currentAssemblyName);
                return(displayables);
            });

            _displayablesRepo.AddPopulatedDisplayables(() =>
            {
                var displayables = _runtime.Container.Resolve <DefaultsDisplayables>();
                jsonContentProvider.Populate <DefaultsDisplayables>(displayables, currentAssemblyName);
                return(displayables);
            });

            _displayablesRepo.AddPopulatedDisplayables(() =>
            {
                var displayables = _runtime.Container.Resolve <ItemsDisplayables>();
                jsonContentProvider.Populate <ItemsDisplayables>(displayables, currentAssemblyName);
                return(displayables);
            });


            InitializeMachine <GameMachine>(
                gameStates.Fetch <GameStates.Inactive>(),
                gameStates.Fetch <GameStates.Error>(),
                gameStates,
                gameTriggers,
                _displayablesRepo.GetADisplayables <GameStatesDisplayables>());


            _initializedMachines.Single(m => m.GetType() == typeof(GameMachine))
            .Get()
            .TryFire(gameTriggers.Fetch <GameTriggers.Begin>());


            _roomsStates   = _runtime.Container.Resolve <RoomsStates>();
            _roomsTriggers = _runtime.Container.Resolve <RoomsTriggers>();


            var playerConf = _runtime.Container.Resolve <PlayerConf>();

            jsonContentProvider.Populate <RoomsStates>(_roomsStates, currentAssemblyName);
            jsonContentProvider.Populate <PlayerConf>(playerConf, currentAssemblyName);


            InitializeMachine <RoomMachine>(
                _roomsStates.rooms.Single(r => r.id == playerConf.spawnRoom),
                _roomsStates.rooms.Single(r => r.id == "ERROR"),
                _roomsStates,
                _roomsTriggers,
                _displayablesRepo.GetADisplayables <RoomsDisplayables>());


            /*
             * _initializedMachines.Single(m => m.GetType() == typeof(RoomMachine))
             *  .Get()
             *  .TryFire(roomsTriggers.Fetch<RoomsTriggers.South>());
             *
             * _initializedMachines.Single(m => m.GetType() == typeof(RoomMachine))
             *  .Get()
             *  .TryFire(roomsTriggers.Fetch<RoomsTriggers.East>());
             *
             * _initializedMachines.Single(m => m.GetType() == typeof(RoomMachine))
             *  .Get()
             *  .TryFire(roomsTriggers.Fetch<RoomsTriggers.South>());
             *
             * _initializedMachines.Single(m => m.GetType() == typeof(RoomMachine))
             *  .Get()
             *  .TryFire(roomsTriggers.Fetch<RoomsTriggers.North>());
             */
        }