예제 #1
0
        public Game1(
            IGameSetup gameSetup,
            IDeltaTimeCalculator deltaTimeCalculator,
            IGameCollection <Entity> entityList,
            IGameCollection <Player> playerList,
            IGameCollection <Bullet> bulletList,
            IPlayerActionManager playerActionManager,
            IBulletMovementManger bulletMovementManger)
        {
            this.gameSetup           = gameSetup;
            graphics                 = new GraphicsDeviceManager(this);
            Content.RootDirectory    = "Content";
            this.deltaTimeCalculator = deltaTimeCalculator;

            // Assets
            assetLoader = new AssetLoader(Content);

            // Collections
            this.entityList = entityList;
            this.playerList = playerList;
            this.bulletList = bulletList;

            // Rendering
            renderingManager = new RenderingManager(assetLoader);

            // Game setup
            playerList.AddListRange(this.gameSetup.SetUpPlayers());
            this.playerActionManager  = playerActionManager;
            this.bulletMovementManger = bulletMovementManger;

            // Window size
            graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
        }
예제 #2
0
        public async void Play(Player player)
        {
            IPlayerActionStrategy strategy = strategies.FirstOrDefault(x => x.ShouldPlay(player));

            if (strategy != null)
            {
                IEnumerable <PlayerAction> playerActions = strategy.Play(player);

                foreach (var playerAction in playerActions)
                {
                    await Task.Delay(gameState.SimulateDelay);

                    IPlayerActionManager manager = managers.First(x => x.ShouldManage(playerAction, player));
                    manager.Manage(playerAction, player);
                }
            }
        }
        public static WeightedStat Stat(IPlayerActionManager manager, float weight, string subject, string obj)
        {
            IPlayerStatManager statManager = PlayerActions.StatManager(manager);

            return(new WeightedStat(statManager, 1, statManager.GetSummaryString));
        }