コード例 #1
0
        public void StoryCardLogicTest()
        {
            StoryCardData target = new StoryCardData();
            var stories = StoryCardData.PopulateStoryCards();
            StateFactory.SetInstance(new StateFactory());
            StateFactory.AddFactory(GameStates.Wait, new WaitFactory());

            var gameTime = new GameTime();
            var player = new Player();
            player.Initialize();
            player.Accept(new Transport(TransportType.Car, String.Empty, int.MaxValue, null, null, 0));
            var world = new List<WorldObject> { new StartingNode(Vector2.Zero), new Spinner(Vector2.Zero) };
            var gameInfo = new GameInfo(world, new[] { player }, 100, GameRuleType.Retirement);
            gameInfo.GetNextPlayer();

            foreach (var story in stories) {
                var performingLogic = story.PureLogic;

                Assert.IsNotNull(performingLogic);
                try {
                    var returnedStates = story.PureLogic.PerformLogic(gameTime, gameInfo);
                } catch (Exception e) {
                    Console.WriteLine(e);
                }

            }
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: AlanFoster/Game-of-Life
 public override void Dispose()
 {
     base.Dispose();
     _fsm.Clear();
     _gameInfo = null;
     _menuManager.Dispose();
 }
コード例 #3
0
 public IGameState[] PerformLogic(GameTime gameTime, GameInfo gameInfo)
 {
     return null;
     if (_startingPlayerCash != _currentPlayer.Cash) {
         _startingPlayerCash = _startingPlayerCash < _currentPlayer.Cash
                                   ? Math.Min(_startingPlayerCash + 123, _currentPlayer.Cash)
                                   : Math.Max(_startingPlayerCash - 123, _currentPlayer.Cash);
         return new IGameState[] { this };
     }
     _updatingCash = false;
     _textColor = Color.White;
     return new IGameState[] { new TimedWait(500) };
 }
コード例 #4
0
ファイル: Level.cs プロジェクト: AlanFoster/Game-of-Life
        public Level(GameInfo gameInfo)
            : base(gameInfo.WorldObjects, Constants.ScreenNames.Level)
        {
            _gameInfo = gameInfo;
            _gameInfo.PanCameraToObject = PanCameraToObject;
            _gameInfo.AddLowPriorityTarget = AddLowPriorityTarget;
            _gameInfo.ClearTargets = ClearTargets;
            gameInfo.Fsm = _fsm = new FSM<IGameState, GameInfo>();

            foreach (var player in gameInfo.PlayerList) {
                player.CashListeners += LoanListener;
            }

            _gameInfo.CreateMessage = CreateHUDMessage;
        }
コード例 #5
0
 public MenuManager(GameInfo gameInfo, GameLayerManager controlManager, Action returnToMainMenu)
 {
     ControlManager = controlManager;
     _gameInfo = gameInfo;
     _returnToMainMenu = returnToMainMenu;
 }
コード例 #6
0
ファイル: TestLevel.cs プロジェクト: AlanFoster/Game-of-Life
 public TestLevel(GameInfo gameInfo)
     : base(gameInfo)
 {
 }
コード例 #7
0
 public GraphicalWidget(GameInfo gameInfo, HUDAlignment hudAlignment, GetText func, Texture2D baseTexture)
     : base(gameInfo, hudAlignment, func)
 {
     BaseTexture = baseTexture;
 }
コード例 #8
0
 public PassportWidget(GameInfo gameInfo, HUDAlignment hudAlignment)
     : base(gameInfo, hudAlignment, i => String.Empty, null)
 {
 }
コード例 #9
0
ファイル: TextWidget.cs プロジェクト: AlanFoster/Game-of-Life
 public TextWidget(GameInfo gameInfo, HUDAlignment hudAlignment, GetText func)
     : base(hudAlignment)
 {
     GameInfo = gameInfo;
     _getTextFunc = func;
 }
コード例 #10
0
ファイル: SetupLevel.cs プロジェクト: AlanFoster/Game-of-Life
        private void WorldReady(List<WorldObject> worldObjects, GameInfoLoader gameInfoLoader)
        {
            if (worldObjects == null) {
                var alert = new Alert(ControlManager.Manager, "That world has become corrupt!\nPlease choose or create a different world", "Invalid world!");
                ControlManager.Add(alert);
                return;
            }

            var playerList = new Player[_playerCount];
            var i = 0;
            foreach (var tabPage in _tabs.TabPages) {
                if (tabPage == _gameInfoTab) continue;
                var player = playerList[i] = _playerObjectEditors[tabPage].CreateInstance();
                player.Cash = Constants.GameRules.StartingCash;
                player.Gender =
                    Constants.DefaultPlayerInfo.NamesAndColors.First(tuple => tuple.Item2 == player.PlayerColor).Item3;
                player.InitializeContent(Content);
                // Give them their basic car transport
                player.SetTransport(TransportType.Car);
                i++;
            }

            var gameInfo = new GameInfo(worldObjects, playerList, gameInfoLoader.AgeCounterTarget, gameInfoLoader.GameRuleType);
            var level = new Level(gameInfo);
            ScreenManager.AddGameLayer(level);
            ScreenManager.SwapScreens(this, level);
        }
コード例 #11
0
 public Leaderboarder(GameInfo gameInfo, HUDAlignment hudAlignment)
     : base(gameInfo, hudAlignment, i => String.Empty, null)
 {
 }
コード例 #12
0
 public AgeCounterWidget(GameInfo gameInfo, HUDAlignment hudAlignment)
     : base(gameInfo, hudAlignment, i => String.Format("Current Years {0}/{1} ", i.AgeCounterCurrent, i.AgeCounterTarget), null)
 {
 }
コード例 #13
0
 public TimedWidget(GameInfo gameInfo, int timer, GetText func, HUDAlignment hudAlignment = HUDAlignment.Center)
     : base(gameInfo, hudAlignment, func)
 {
     _timer = timer;
 }
コード例 #14
0
ファイル: Setup.cs プロジェクト: AlanFoster/Game-of-Life
        private void StartGame()
        {
            var playerList = new Player[playerCount];
            for (var i = 0; i < playerCount; i++) {
                var player = playerList[i] = playerObjectEditors[i].CreateInstance();
                player.InitializeContent(Content);
               Console.WriteLine(playerList[i].ToString());
            }

            var gameInfo = new GameInfo(TheGameOfLife.CreateBasicEmptyWorld(Content), playerList);
            var level = new Level(gameInfo);
            ScreenManager.AddGameLayer(level);
            ScreenManager.SwapScreens(this, level);
        }
コード例 #15
0
        public GameInfo CreateTestWorld(List<WorldObject> worldObjects)
        {
            bool newWorld = false;

            // Create players
            List<Player> playerList = new List<Player>();
            const int playerCount = 2;

            for (int i = 0; i < playerCount; i++) {
                var newPlayer = new Player { Name = Constants.DefaultPlayerInfo.NamesAndColors[i].Item1 };
                newPlayer.InitializeContent(Content);
                newPlayer.Cash = 5000;
                newPlayer.PlayerColor = Constants.DefaultPlayerInfo.NamesAndColors[i].Item2;

                newPlayer.Avatar = Content.Load<Texture2D>(Constants.DefaultPlayerInfo.AvatarImages[i]);

                newPlayer.CareerType = CareerType.CollegeCareer;
                newPlayer.Accept(TransportFactory.GetInstance().GetTransport(TransportType.PlaneCar));
                playerList.Add(newPlayer);

                // Give them all their assets for testing
                if (i != 1) continue;
                {
                    newPlayer.Accept(new Partner());
                    newPlayer.Accept(new Pet());
                    newPlayer.Accept(new PassportStamp(IslandType.Jungle));
                    newPlayer.Accept(new Loan(-4000));
                    newPlayer.Accept(new PassportStamp(IslandType.City));
                    newPlayer.Accept(new PassportStamp(IslandType.Beach));
                    newPlayer.Accept(new PassportStamp(IslandType.Jungle));
                    newPlayer.Accept(new PassportStamp(IslandType.Snow));
                    newPlayer.Accept(new PassportStamp(IslandType.City));
                    newPlayer.Accept(new PassportStamp(IslandType.City));
                    newPlayer.Accept(new Child());
                    newPlayer.Accept(new Child());
                    newPlayer.Accept(new Child());

                    newPlayer.Accept(new Pet());
                    newPlayer.Accept(new Child());
                    newPlayer.Accept(new Loan(-4000));
                    newPlayer.Accept(new Loan(-43450));

                    newPlayer.Accept(new House(12123, "Awesome House", "Images/AlertIcons/House"));
                }

            }

            var gameInfo = new GameInfo(worldObjects == null || newWorld ? CreateBasicEmptyWorld(Content) : worldObjects, playerList.ToArray(), 100, GameRuleType.Passport) { Manager = Manager as CustomManager };
            return gameInfo;
        }
コード例 #16
0
 public void PlayerCashChanged(Player player, int previousCash, GameInfo gameInfo)
 {
     return;
     if (player != _currentPlayer) return;
     _startingPlayerCash = previousCash;
     _textColor = _startingPlayerCash > player.Cash ? Color.Red : Color.Green;
     _updatingCash = true;
     gameInfo.Fsm.LazyPush(this);
 }
コード例 #17
0
 public AvatarWidget(GameInfo gameInfo, HUDAlignment hudAlignment)
     : base(gameInfo, hudAlignment, info => String.Empty, null)
 {
     _textColor = Color.White;
     //_startingPlayerCash = new List<int>();
 }