Пример #1
0
        public void Load(IPlayerFactory player, Transform cameraTransform, TaskObject[] tasks, TaskModel taskModel)
        {
            var file = Path.Combine(_path, _FILE_NAME);

            if (!File.Exists(file))
            {
                return;
            }
            var savedData = _data.Load(file);

            var playerTransform = player.GetTransform();

            playerTransform.position        = savedData.PlayerPosition;
            playerTransform.rotation        = savedData.PlayerRotation;
            cameraTransform.rotation        = savedData.CameraRotation;
            playerTransform.gameObject.name = savedData.PlayerName;
            playerTransform.gameObject.SetActive(savedData.IsEnabled);
            taskModel.TasksDone = savedData.DoneTasksAmount;

            for (int i = 0; i < savedData.TasksDone.Length; i++)
            {
                if (tasks[i].IsDone && !savedData.TasksDone[i])
                {
                    taskModel.LoadTask(tasks[i]);
                }
                tasks[i].IsDone = savedData.TasksDone[i];
            }
        }
Пример #2
0
        public void Save(IPlayerFactory player, Transform camera, TaskObject[] tasks, TaskModel taskModel)
        {
            if (!Directory.Exists(Path.Combine(_path)))
            {
                Directory.CreateDirectory(_path);
            }

            var transform = player.GetTransform();

            var tasksDone       = new bool [tasks.Length];
            int doneTasksAmount = taskModel.TasksDone;

            for (int i = 0; i < tasks.Length; i++)
            {
                tasksDone[i] = tasks[i].IsDone;
            }

            var savedData = new SavedData
            {
                PlayerPosition  = transform.position,
                PlayerRotation  = transform.rotation,
                CameraRotation  = camera.rotation,
                PlayerName      = player.GetTransform().transform.name,
                IsEnabled       = player.GetTransform().gameObject.activeSelf,
                TasksDone       = tasksDone,
                DoneTasksAmount = doneTasksAmount,
            };

            _data.Save(savedData, Path.Combine(_path, _FILE_NAME));
        }
Пример #3
0
 public ManagerController()
 {
     this.players = new PlayerRepository();
     this.cards = new CardRepository();
     this.playerFactory = new PlayerFactory();
     this.cardFactory = new CardFactory();
 }
Пример #4
0
 /// <summary>
 /// Creates a new <see cref="JoinGameHandler"/> instance.
 /// </summary>
 /// <param name="logger">Logger.</param>
 /// <param name="database">Database access layer.</param>
 /// <param name="playerFactory">Player factory.</param>
 /// <param name="worldSpawnPacketFactory">World spawn packet factory.</param>
 public JoinGameHandler(ILogger <JoinGameHandler> logger, IRhisisDatabase database, IPlayerFactory playerFactory, IWorldSpawnPacketFactory worldSpawnPacketFactory)
 {
     _logger                  = logger;
     _database                = database;
     _playerFactory           = playerFactory;
     _worldSpawnPacketFactory = worldSpawnPacketFactory;
 }
Пример #5
0
 public GameFactory(IPlayerFactory playerFactory, IJobFactory jobFactory,
                    IEducationalInstituteFactory educationalInstituteFactory)
 {
     PlayerFactory = playerFactory;
     JobFactory    = jobFactory;
     EducationalInstituteFactory = educationalInstituteFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StandardServer"/> class.
 /// </summary>
 /// <param name="playerFactory">The player factory.</param>
 /// <param name="connectionFactory">The connection factory.</param>
 public StandardServer(
     IPlayerFactory playerFactory,
     IConnectionFactory <StandardServer> connectionFactory)
 {
     this.playerFactory     = playerFactory;
     this.connectionFactory = connectionFactory;
 }
Пример #7
0
 public MapGenerator(
     IMapGenerationConfig config, ICivilizationFactory civFactory, IHexGrid grid,
     IOceanGenerator oceanGenerator, IGridTraversalLogic gridTraversalLogic,
     IStartingUnitPlacementLogic startingUnitPlacementLogic, IPlayerFactory playerFactory,
     IGridPartitionLogic gridPartitionLogic, IWaterRationalizer waterRationalizer,
     IHomelandGenerator homelandGenerator, ITemplateSelectionLogic templateSelectionLogic,
     ICellClimateLogic cellClimateLogic, ISectionSubdivisionLogic subdivisionLogic,
     ICivilizationConfig civConfig, IBrainPile brainPile, IMapComposer mapComposer,
     [Inject(Id = "Coroutine Invoker")] MonoBehaviour coroutineInvoker
     )
 {
     Config                     = config;
     CivFactory                 = civFactory;
     Grid                       = grid;
     OceanGenerator             = oceanGenerator;
     StartingUnitPlacementLogic = startingUnitPlacementLogic;
     PlayerFactory              = playerFactory;
     GridPartitionLogic         = gridPartitionLogic;
     WaterRationalizer          = waterRationalizer;
     HomelandGenerator          = homelandGenerator;
     TemplateSelectionLogic     = templateSelectionLogic;
     CellClimateLogic           = cellClimateLogic;
     SubdivisionLogic           = subdivisionLogic;
     CivConfig                  = civConfig;
     BrainPile                  = brainPile;
     MapComposer                = mapComposer;
     CoroutineInvoker           = coroutineInvoker;
 }
Пример #8
0
        public Form1(IGameFactory gameFactory = null, IPlayerFactory playerFactory = null)
        {
            InitializeComponent();

            GameFactory = gameFactory;
            PlayerFactory = playerFactory;
        }
Пример #9
0
 public ManagerController()
 {
     playerFactory    = new PlayerFactory();
     cardFactory      = new CardFactory();
     playerRepository = new PlayerRepository();
     cardRepository   = new CardRepository();
 }
Пример #10
0
 public ClassChoiceNotifier(ITwitchClient client, IPlayerFactory pf,
                            int classChoiceLevel)
 {
     this.client           = client;
     this.playerFactory    = pf;
     this.classChoiceLevel = classChoiceLevel;
 }
Пример #11
0
 public LocalGameControllerCreator()
 {
     this.playerPool            = new PlayerFactory();
     this.dice                  = new Dice();
     this.gameBoard             = new GameBoard(BoardSizes.Standard);
     this.developmentCardHolder = new DevelopmentCardHolder();
 }
 public PlayerInitialization(IPlayerFactory playerFactory, PlayerData playerData)
 {
     _playerFactory   = playerFactory;
     _player          = _playerFactory.CreatePlayer();
     _playerData      = playerData;
     _player.position = _playerData.Position;
 }
Пример #13
0
        void startPlayback(AudioBufferStream stream)
        {
            stopCurrentItem();
            IPlayer player = new AudioPlayer(new PlayerSettings(stream));

            currentAudioPlayer = player as IAudioPlayer;
            IPlayerFactory savedFactory = g_Player.Factory;

            g_Player.Factory = new PlayerFactory(player);
            isAudioPlaying   = g_Player.Play(AudioPlayer.AIRPLAY_DUMMY_FILE, g_Player.MediaType.Music);
            g_Player.Factory = savedFactory;

            if (!isAudioPlaying)
            {
                currentAudioPlayer = null;
                return;
            }
            //Mediaportal sets the metadata skin properties internally, we overwrite them after a small delay
            ThreadPool.QueueUserWorkItem((o) =>
            {
                Thread.Sleep(SKIN_PROPERTIES_UPDATE_DELAY);
                invoke(delegate()
                {
                    setMetaData();
                    setCover();
                    setDuration();
                }, false);
            });
        }
        public PlayerFactoryShould()
        {
            var mockRacingCardManager = new Mock <IRacingCardManager>();

            _sut = new PlayerFactory(mockRacingCardManager.Object,
                                     _mockPreConditionRaicingCardsFactory.Object);
        }
Пример #15
0
        public void Load()
        {
            playerTypes.Clear();
            players.Clear();
            Type[] types = DllHelper.GetMonoTypes();

            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(PlayerFactoryAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }

                PlayerFactoryAttribute attribute = attrs[0] as PlayerFactoryAttribute;
                if (playerTypes.ContainsKey(attribute.Type))
                {
                    Log.Debug(string.Format("已经存在同类Player Factory: {0}", attribute.Type));
                    throw new Exception(string.Format("已经存在同类Player Factory: {0}", attribute.Type));
                }
                object         o       = Activator.CreateInstance(type);
                IPlayerFactory factory = o as IPlayerFactory;
                if (factory == null)
                {
                    Log.Debug(string.Format("{0} 没有继承 IPlayerFactory", o.GetType().FullName));
                    continue;
                }
                this.playerTypes.Add(attribute.Type, factory);
            }
        }
Пример #16
0
        public PlaybackService(ITrackRepository trackRepository, IQueuedTrackRepository queuedTrackRepository, IEqualizerService equalizerService)
        {
            this.trackRepository       = trackRepository;
            this.queuedTrackRepository = queuedTrackRepository;
            this.equalizerService      = equalizerService;

            this.context = SynchronizationContext.Current;

            // Initialize the PlayerFactory
            this.playerFactory = new PlayerFactory();

            // Set up timers
            this.progressTimer.Interval = TimeSpan.FromSeconds(this.progressTimeoutSeconds).TotalMilliseconds;
            this.progressTimer.Elapsed += new ElapsedEventHandler(this.ProgressTimeoutHandler);

            this.saveQueuedTracksTimer.Interval = TimeSpan.FromSeconds(this.saveQueuedTracksTimeoutSeconds).TotalMilliseconds;
            this.saveQueuedTracksTimer.Elapsed += new ElapsedEventHandler(this.SaveQueuedTracksTimeoutHandler);

            this.saveTrackStatisticsTimer.Interval = TimeSpan.FromSeconds(this.saveTrackStatisticsTimeoutSeconds).TotalMilliseconds;
            this.saveTrackStatisticsTimer.Elapsed += new ElapsedEventHandler(this.SaveTrackStatisticsHandler);

            // Equalizer
            this.SetIsEqualizerEnabled(XmlSettingsClient.Instance.Get <bool>("Equalizer", "IsEnabled"));

            // Queued tracks
            this.GetSavedQueuedTracksAsync();
        }
Пример #17
0
 public static IEnumerable <IRoundPlayerState> CreateRoundPlayers(this IPlayerFactory playerFactory, IEnumerable <IGamePlayerState> gameStatePlayers)
 {
     foreach (var gameStatePlayer in gameStatePlayers)
     {
         yield return(playerFactory.CreateRoundPlayer(gameStatePlayer));
     }
 }
Пример #18
0
 public LoginCommandsModule(IActionFactory actionFactory,
                            ITribeManager tribeManager,
                            IDbManager dbManager,
                            ILocker locker,
                            IWorld world,
                            Procedure procedure,
                            ICityFactory cityFactory,
                            ILocationStrategyFactory locationStrategyFactory,
                            IBarbarianTribeManager barbarianTribeManager,
                            CallbackProcedure callbackProcedure,
                            IChannel channel,
                            IThemeManager themeManager,
                            IPlayerFactory playerFactory,
                            ILoginHandler loginHandler)
 {
     this.actionFactory           = actionFactory;
     this.tribeManager            = tribeManager;
     this.dbManager               = dbManager;
     this.locker                  = locker;
     this.world                   = world;
     this.procedure               = procedure;
     this.callbackProcedure       = callbackProcedure;
     this.channel                 = channel;
     this.themeManager            = themeManager;
     this.playerFactory           = playerFactory;
     this.loginHandler            = loginHandler;
     this.cityFactory             = cityFactory;
     this.locationStrategyFactory = locationStrategyFactory;
     this.barbarianTribeManager   = barbarianTribeManager;
 }
Пример #19
0
 public ManagerController(IPlayerRepository playerRepository, IPlayerFactory playerFactory, ICardRepository cardRepository, ICardFactory cardFactory, IBattleField battleField)
 {
     this.playerRepository = playerRepository;
     this.playerFactory    = playerFactory;
     this.cardRepository   = cardRepository;
     this.cardFactory      = cardFactory;
     this.battleField      = battleField;
 }
Пример #20
0
 public GameServer(IGameFactory gameFactory,
                   IPlayerFactory playerFactory,
                   ILogger logger = null)
 {
     this.gameFactory   = gameFactory;
     this.playerFactory = playerFactory;
     this.logger        = logger;
 }
Пример #21
0
        public PlayerBaseSimulator(int maxServerCapacity, IPlayerFactory playerFactory, TimeSimulatorTickInfo tickInfo)
        {
            var players = playerFactory.CreatePlayerBase();

            _offlinePlayers.AddRange(players);
            _tickInfo         = tickInfo;
            MaxServerCapacity = maxServerCapacity;
        }
Пример #22
0
 public PlayerInitialization(IPlayerFactory factory)
 {
     _player        = factory.Create();
     Transform      = _player.transform;
     SpriteRenderer = _player.GetComponentInChildren <SpriteRenderer>();
     Collider       = _player.GetOrAddComponent <Collider2D>();
     Rigidbody      = _player.GetOrAddComponent <Rigidbody2D>();
 }
Пример #23
0
 public PlayerModel(IPlayerFactory playerFactory)
 {
     playerFactory.CreatePlayer();
     _characterController = playerFactory.GetCharacterController();
     _transform           = playerFactory.GetTransform();
     _camera   = playerFactory.GetCamera();
     _animator = playerFactory.GetAnimator();
 }
Пример #24
0
 public GameFactory(
     ICardDeckFactory cardDeckFactory,
     IPlayerFactory playerFactory,
     IActionStepper actionStepper)
 {
     _cardDeckFactory = cardDeckFactory;
     _playerFactory   = playerFactory;
 }
Пример #25
0
 public ManagerController()
 {
     playerRepository = new PlayerRepository();
     cardRepository   = new CardRepository();
     battleField      = new BattleField();
     playerFactory    = new PlayerFactory();
     cardFactory      = new CardFactory();
 }
Пример #26
0
 public GameStartService(IRoundFactory roundFactory,
                         IRoundStateFactory roundStateFactory,
                         IPlayerFactory playerFactory)
 {
     _roundFactory      = roundFactory;
     _roundStateFactory = roundStateFactory;
     _playerFactory     = playerFactory;
 }
Пример #27
0
 public Factory()
 {
     _grenadeFactory   = new GrenadeFactory();
     _mineFactory      = new MineFactory();
     _characterFactory = new CharacterFactory();
     _playerFactory    = new PlayerFactory();
     _enemyFactory     = new SimpleEnemyFactory();
 }
Пример #28
0
 public PlayerService(Game game, IInputService inputService, IAudioService audioService, IPlayerFactory playerFactory, ITerrainService terrainService)
     : base(game)
 {
     this.inputService = inputService;
     this.audioService = audioService;
     this.playerFactory = playerFactory;
     this.terrainService = terrainService;
 }
Пример #29
0
 public ManagerController()
 {
     this.cardRepository   = new CardRepository();
     this.playerRepository = new PlayerRepository();
     this.playerFactory    = new PlayerFactory();
     this.cardFactory      = new CardFactory();
     this.battleField      = new BattleField();
 }
Пример #30
0
        private void NameMethod(IPlayerFactory playerFactory)
        {
            IPlayer player = playerFactory.Create(6, TypePlayer.Mag);

            IPlayer player3 = Player.Factory.Create(6, TypePlayer.Player);

            Task.Factory.StartNew(Action);
        }
Пример #31
0
 public PlayerCreator(IPlayerFactory playerFactory, IEngineFactory engineFactory, IArmourFactory armourFactory, IWeaponFactory weaponFactory, ISpaceshipFactory spaceshipFactory, IBulletFactory bulletFactory)
 {
     this.playerFactory    = playerFactory;
     this.engineFactory    = engineFactory;
     this.armourFactory    = armourFactory;
     this.weaponFactory    = weaponFactory;
     this.spaceshipFactory = spaceshipFactory;
     this.bulletFactory    = bulletFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StandardServer"/> class.
 /// </summary>
 /// <param name="playerFactory">The player factory.</param>
 /// <param name="connectionFactory">The connection factory.</param>
 /// <param name="serverConfiguration">The server configuration.</param>
 public StandardServer(
     IPlayerFactory playerFactory,
     IConnectionFactory <StandardServer> connectionFactory,
     IServerConfiguration serverConfiguration)
     : base(serverConfiguration)
 {
     this.playerFactory     = playerFactory;
     this.connectionFactory = connectionFactory;
 }
Пример #33
0
 public PongGame(IGameInitializer gameInitializer, IPlayerInitializer playerInitializer,
     IPlayerFactory playerFactory, IBallFactory ballFactory, IBallInitializer ballInitializer)
 {
     this.gameInitializer = gameInitializer;
     this.playerInitializer = playerInitializer;
     this.playerFactory = playerFactory;
     this.ballFactory = ballFactory;
     this.ballInitializer = ballInitializer;
     Running = true;
 }
Пример #34
0
		public TicTacToeGame (IReader reader, IDisplayer displayer, IBoardFormatter formatter, IPlayerFactory player_factory, IRoundFactory round_factory, Game game, IGameRepository game_repository)
		{
			_game = game;
			_reader = reader;
			_displayer = displayer;
			_formatter = formatter;
			_player_factory = player_factory;
			_round_factory = round_factory;
			_game_repository = game_repository;
		}
Пример #35
0
		public TicTacToeRunner (IReader reader, IDisplayer displayer, IBoardFormatter formatter, IPlayerFactory player_factory, IRoundFactory round_factory, IGameFactory game_factory, IGameRepository game_repository)
		{
			_reader = reader;
			_displayer = displayer;
			_game_repository = game_repository;
			_game_factory = game_factory;
			_formatter = formatter;
			_round_factory = round_factory;
			_player_factory = player_factory;

			//on charge la partie dans le repo
			_game_model = _game_repository.Load();

			if(_game_model == null)
				_game_model = game_factory.Create (NUMBER_ROUND);
			
			_game = new TicTacToeGame (_reader, _displayer, formatter, player_factory, round_factory, _game_model, _game_repository);
		}
        public void CreateFactoryWithNames(IEnumerable<string> names)
        {
            IKernel kernel = new StandardKernel(new MonopolyBindings(names));

            factory = kernel.Get<IPlayerFactory>();
        }
Пример #37
0
 // singleton. Dont allow any instance of this class
 private g_Player()
 {
   _factory = new PlayerFactory();
 }
Пример #38
0
 public void SetUp()
 {
     PlayerFactory = new PlayerFactory();
 }
Пример #39
0
        private void ComposeServices()
        {
            this.terrainService = new TerrainService(
                this);

            this.headUpDisplayService = new HeadUpDisplayService(
                this);

            this.audioService = new AudioService(
                this);

            this.enemyFactory = new EnemyFactory(
                this,
                terrainService);

            this.enemyService = new EnemyService(
                this,
                enemyFactory);

            this.playerFactory = new PlayerFactory(
                this);

            this.inputService = new InputService(
                this);

            this.playerService = new PlayerService(
                this,
                inputService,
                audioService,
                playerFactory,
                terrainService);

            this.collisionDetectionService = new CollisionDetectionService(
                this,
                playerService,
                enemyService,
                terrainService);

            this.gameController = new GameController(
                this,
                collisionDetectionService,
                playerService,
                enemyService,
                inputService,
                headUpDisplayService,
                terrainService,
                audioService);

            try
            {
                var consoleAssembly = Assembly.Load("SpaceFighter.Console");
                var consoleServiceType = consoleAssembly.GetType("SpaceFighter.Console.ConsoleService");
                var consoleService = Activator.CreateInstance(consoleServiceType, this);

                this.Components.Add(consoleService as IGameComponent);
            }
            catch(FileNotFoundException)
            {
                // No console support available
            }
        }