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];
            }
        }
        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));
        }
Example #3
0
 public ManagerController()
 {
     this.players = new PlayerRepository();
     this.cards = new CardRepository();
     this.playerFactory = new PlayerFactory();
     this.cardFactory = new CardFactory();
 }
Example #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;
 }
Example #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;
 }
 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;
 }
Example #8
0
        public Form1(IGameFactory gameFactory = null, IPlayerFactory playerFactory = null)
        {
            InitializeComponent();

            GameFactory = gameFactory;
            PlayerFactory = playerFactory;
        }
Example #9
0
 public ManagerController()
 {
     playerFactory    = new PlayerFactory();
     cardFactory      = new CardFactory();
     playerRepository = new PlayerRepository();
     cardRepository   = new CardRepository();
 }
Example #10
0
 public ClassChoiceNotifier(ITwitchClient client, IPlayerFactory pf,
                            int classChoiceLevel)
 {
     this.client           = client;
     this.playerFactory    = pf;
     this.classChoiceLevel = classChoiceLevel;
 }
Example #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;
 }
Example #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);
        }
Example #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);
            }
        }
Example #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();
        }
Example #17
0
 public static IEnumerable <IRoundPlayerState> CreateRoundPlayers(this IPlayerFactory playerFactory, IEnumerable <IGamePlayerState> gameStatePlayers)
 {
     foreach (var gameStatePlayer in gameStatePlayers)
     {
         yield return(playerFactory.CreateRoundPlayer(gameStatePlayer));
     }
 }
Example #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;
 }
 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;
 }
Example #20
0
 public GameServer(IGameFactory gameFactory,
                   IPlayerFactory playerFactory,
                   ILogger logger = null)
 {
     this.gameFactory   = gameFactory;
     this.playerFactory = playerFactory;
     this.logger        = logger;
 }
Example #21
0
        public PlayerBaseSimulator(int maxServerCapacity, IPlayerFactory playerFactory, TimeSimulatorTickInfo tickInfo)
        {
            var players = playerFactory.CreatePlayerBase();

            _offlinePlayers.AddRange(players);
            _tickInfo         = tickInfo;
            MaxServerCapacity = maxServerCapacity;
        }
Example #22
0
 public PlayerInitialization(IPlayerFactory factory)
 {
     _player        = factory.Create();
     Transform      = _player.transform;
     SpriteRenderer = _player.GetComponentInChildren <SpriteRenderer>();
     Collider       = _player.GetOrAddComponent <Collider2D>();
     Rigidbody      = _player.GetOrAddComponent <Rigidbody2D>();
 }
Example #23
0
 public PlayerModel(IPlayerFactory playerFactory)
 {
     playerFactory.CreatePlayer();
     _characterController = playerFactory.GetCharacterController();
     _transform           = playerFactory.GetTransform();
     _camera   = playerFactory.GetCamera();
     _animator = playerFactory.GetAnimator();
 }
Example #24
0
 public GameFactory(
     ICardDeckFactory cardDeckFactory,
     IPlayerFactory playerFactory,
     IActionStepper actionStepper)
 {
     _cardDeckFactory = cardDeckFactory;
     _playerFactory   = playerFactory;
 }
 public ManagerController()
 {
     playerRepository = new PlayerRepository();
     cardRepository   = new CardRepository();
     battleField      = new BattleField();
     playerFactory    = new PlayerFactory();
     cardFactory      = new CardFactory();
 }
Example #26
0
 public GameStartService(IRoundFactory roundFactory,
                         IRoundStateFactory roundStateFactory,
                         IPlayerFactory playerFactory)
 {
     _roundFactory      = roundFactory;
     _roundStateFactory = roundStateFactory;
     _playerFactory     = playerFactory;
 }
Example #27
0
 public Factory()
 {
     _grenadeFactory   = new GrenadeFactory();
     _mineFactory      = new MineFactory();
     _characterFactory = new CharacterFactory();
     _playerFactory    = new PlayerFactory();
     _enemyFactory     = new SimpleEnemyFactory();
 }
Example #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;
 }
Example #29
0
 public ManagerController()
 {
     this.cardRepository   = new CardRepository();
     this.playerRepository = new PlayerRepository();
     this.playerFactory    = new PlayerFactory();
     this.cardFactory      = new CardFactory();
     this.battleField      = new BattleField();
 }
        private void NameMethod(IPlayerFactory playerFactory)
        {
            IPlayer player = playerFactory.Create(6, TypePlayer.Mag);

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

            Task.Factory.StartNew(Action);
        }
 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;
 }
Example #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;
 }
Example #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;
		}
Example #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>();
        }
Example #37
0
 // singleton. Dont allow any instance of this class
 private g_Player()
 {
   _factory = new PlayerFactory();
 }
Example #38
0
 public void SetUp()
 {
     PlayerFactory = new PlayerFactory();
 }
Example #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
            }
        }