当前位置: 首页>>代码示例>>C#>>正文


C# Player.Accept方法代码示例

本文整理汇总了C#中Player.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# Player.Accept方法的具体用法?C# Player.Accept怎么用?C# Player.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player.Accept方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CarSizeTest

        public void CarSizeTest()
        {
            Player player = new Player();
            player.Initialize();
            const int carSize = 5;
            Transport car = new Transport(TransportType.Car, String.Empty, 100, null, null, 10000);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(car));
            Asset wife = new Partner();
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(wife));
            Asset[] carTravellers = {
                                       new Child(),
                                       new Pet()
                                   };

            // Start from 1 as we already added wife asset
            for (var i = 1; i < player.CarSize; i++) {
                Assert.AreEqual(AssetResponse.AddedSuccessfully,
                                player.Accept(carTravellers[RandomHelper.Next(0, carTravellers.Length)]));
            }

            Assert.AreEqual(player.CarSize, player.Assets[AssetType.Transportable].Count);

            for (var i = 0; i < player.CarSize; i++) {
                Assert.AreEqual(AssetResponse.CarFull,
                                player.Accept(carTravellers[RandomHelper.Next(0, carTravellers.Length)]));
            }
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:27,代码来源:PlayerTest.cs

示例2: StoryCardLogicTest

        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);
                }

            }
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:27,代码来源:StoryCardDataTest.cs

示例3: TakeLoan

 public TakeLoan(Player player, int newCash)
 {
     Player = player;
     LoanRequired = 0 - newCash;
     Loan = new Loan(-LoanRequired);
     player.Accept(Loan);
     player.Cash += LoanRequired;
 }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:8,代码来源:TakeLoan.cs

示例4: CarTest

        public void CarTest()
        {
            Player player = new Player();
            player.Initialize();
            const int carSize = 5;
            const int carValue = 123111;
            Transport car = new Transport(TransportType.Car, String.Empty, 100, null, null, carValue);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(car));

            Assert.AreEqual(carValue, player.TotalValue);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(car));
            Assert.AreEqual(carValue, player.TotalValue);

            const int secondCarValue = 1000;
            Transport car2 = new Transport(TransportType.Car, String.Empty, 100, null, null, secondCarValue);

            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(car2));

            Assert.AreEqual(secondCarValue, player.TotalValue);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(car2));
            Assert.AreEqual(secondCarValue, player.TotalValue);
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:22,代码来源:PlayerTest.cs

示例5: WiveTest

        public void WiveTest()
        {
            Player player = new Player();
            player.Initialize();
            Transport worthlessCar = new Transport(TransportType.Car, String.Empty, 100, null, null, 0);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(worthlessCar));

            Asset wive = new Partner();

            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(wive));
            Assert.AreEqual(AssetResponse.HasPartnerAlready, player.Accept(wive));
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:12,代码来源:PlayerTest.cs

示例6: TotalValueTest

        public void TotalValueTest()
        {
            int playerCash = RandomHelper.Next(0, 500000);
            int houseValue = RandomHelper.Next(0, 500000);
            int peopleValue = Constants.GameRules.TransportableValue;
            int carValue = RandomHelper.Next(0, 500000);

            Player player = new Player();
            player.Initialize();
            player.Cash += playerCash;

            Transport car = new Transport(TransportType.Car, String.Empty, 100, null, null, carValue);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(car));
            Assert.AreEqual(playerCash + carValue, player.TotalValue);

            Assert.AreEqual(playerCash, player.Cash);

            Asset asset1 = new House(houseValue, "testing house", String.Empty);
            Asset asset2 = new Partner();

            // make sure the player can afford the house
            player.Cash += asset1.Value;
            Assert.AreEqual(playerCash + houseValue, player.Cash);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(asset1));
            Assert.AreEqual(playerCash + houseValue + carValue, player.TotalValue);

            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(asset2));

            Assert.AreEqual( playerCash + houseValue + peopleValue + carValue, player.TotalValue);
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:30,代码来源:PlayerTest.cs

示例7: PassportStampTest

        public void PassportStampTest()
        {
            Player player = new Player();
            player.Initialize();

            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(new PassportStamp(IslandType.Beach)));
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(new PassportStamp(IslandType.Beach)));
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(new PassportStamp(IslandType.City)));
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(new PassportStamp(IslandType.Jungle)));
            Assert.AreEqual(AssetResponse.CollectedAllPassportStamps, player.Accept(new PassportStamp(IslandType.Snow)));
            Assert.AreEqual(AssetResponse.CollectedAllPassportStamps, player.Accept(new PassportStamp(IslandType.City)));
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:12,代码来源:PlayerTest.cs

示例8: CashTest

        public void CashTest()
        {
            const int cash = 12312;
            Vector2 location = Vector2.Zero;

            Player player = new Player();
            player.Initialize();
            player.Cash += cash;
            Transport worthlessCar = new Transport(TransportType.Car, String.Empty, 100, null, null, 0);
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(worthlessCar));

            Asset asset1 = new House(15212, "testing house", String.Empty);
            Asset asset2 = new Partner();

            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(asset1));
            Assert.AreEqual(AssetResponse.AddedSuccessfully, player.Accept(asset2));

            int expected = cash;
            int actual;
            player.Cash = expected;
            actual = player.Cash;
            Assert.AreEqual(expected, actual);
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:23,代码来源:PlayerTest.cs

示例9: CreateTestWorld

        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;
        }
开发者ID:AlanFoster,项目名称:Game-of-Life,代码行数:50,代码来源:TheGameOfLife.cs


注:本文中的Player.Accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。