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


C# GameModel类代码示例

本文整理汇总了C#中GameModel的典型用法代码示例。如果您正苦于以下问题:C# GameModel类的具体用法?C# GameModel怎么用?C# GameModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AllGames

        public List<GameModel> AllGames()
        {
            List<GameModel> ret = new List<GameModel>();

            using (ADayInTheLifeEntities db = new ADayInTheLifeEntities())
            {
                try
                {
                    List<Game> games = db.Games.ToList();

                    foreach(Game g in games)
                    {
                        GameModel gm = new GameModel()
                        {
                            GameId = g.GameId,
                            Players = g.Players,
                            WinCondition1 = g.WinCondition1,
                            WinCondition2 = g.WinCondition2,
                            WinCondition3 = g.WinCondition3,
                            WinCondition4 = g.WinCondition4
                        };

                        ret.Add(gm);
                    }
                }
                catch (Exception e)
                {
                    //TODOL: Log This
                }
            }

            return ret;
        }
开发者ID:slackercoder,项目名称:ADayInTheLife_API_GitHub,代码行数:33,代码来源:GameRepo.cs

示例2: LoadContent

        protected override void LoadContent()
        {
            var device = graphics.GraphicsDevice;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            spaceship = new GameModel(Content.Load<Model>("spaceship"))
            {
                Position = new Vector3(0, 3500, 0),
                Scale = new Vector3(50f),
                BaseRotation = new Vector3(0, MathHelper.Pi, 0),
                Rotation = new Vector3(0, MathHelper.Pi, 0)
            };

            models.Add(spaceship);

            var effect = Content.Load<Effect>("BasicTerrainEffect");
            effect.Parameters["Texture"].SetValue(Content.Load<Texture2D>("grass"));

            ground = new Terrain(
                Content.Load<Texture2D>("heightmap1"),
                effect,
                30, 4800, device
                );

            models.Add(ground);

            camera = new ChaseCamera(
                new Vector3(0, 400, 1500),
                new Vector3(0, 200, 0),
                new Vector3(0, 0, 0),
                GraphicsDevice);
        }
开发者ID:JoseIsac,项目名称:VamosAprenderXNA,代码行数:33,代码来源:Game1.cs

示例3: Play

 public override void Play(GameModel gameModel)
 {
     if (!gameModel.CardModifiers.OfType<HighwayCardModifier>().Any(m => m.Source == this))
     {
         gameModel.AddCardModifier(new HighwayCardModifier(this));
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:7,代码来源:Highway.cs

示例4: PlayAttack

 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player player in attackedPlayers)
     {
         CardModel topCard = player.DrawCard();
         if (topCard != null)
         {
             if (topCard.Is(CardType.Victory))
             {
                 player.GainCard(typeof(Curse));
             }
             else
             {
                 gameModel.TextLog.WriteLine(player.Name + " reveals a " + topCard.Name + ".");
                 int choice = gameModel.CurrentPlayer.Chooser.ChooseOneEffect(EffectChoiceType.GainForJester, topCard, "Who gains a copy?", choices, choices);
                 if (choice == 0)
                 {
                     gameModel.CurrentPlayer.GainCard(topCard.GetType());
                 }
                 else
                 {
                     player.GainCard(topCard.GetType());
                 }
             }
             player.DiscardCard(topCard);
         }
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:28,代码来源:Jester.cs

示例5: PlayAttack

 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach(Player player in attackedPlayers)
     {
         player.HasHauntedWoodsEffect.Add(gameModel.CurrentPlayer);
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:7,代码来源:HauntedWoods.cs

示例6: PlayAttack

 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player attacked in attackedPlayers)
     {
         this.DoAttack(gameModel.CurrentPlayer, attacked);
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:7,代码来源:NobleBrigand.cs

示例7: PlayAttack

 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player player in attackedPlayers)
     {
         player.GainCard(gameModel.Ruins);
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:7,代码来源:Marauder.cs

示例8: BeforePlay

 public override void BeforePlay(GameModel gameModel)
 {
     if (this.mimic == null)
     {
         CardModel target = null;
         if (this.forceMimic != null)
         {
             target = this.forceMimic;
         }
         else
         {
             Pile pile = gameModel.CurrentPlayer.Chooser.ChooseOnePile(CardChoiceType.BandOfMisfits, "Play Band of Misfits as...", gameModel.SupplyPiles.Where(p => p.GetCost() < gameModel.GetCost(this) && !p.CostsPotion && p.Count > 0 && p.Card.Is(CardType.Action)));
             if (pile != null)
             {
                 target = (CardModel)Activator.CreateInstance(pile.TopCard.GetType());
             }
         }
         if (target != null)
         {
             this.mimic = target;
             if (this.lockCount > 0)
             {
                 this.forceMimic = target;
             }
             this.SetMimic();
         }
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:28,代码来源:BandOfMisfits.cs

示例9: PlayAttack

 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player player in attackedPlayers)
     {
         player.GainCard(typeof(Curse));
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:7,代码来源:Witch.cs

示例10: GenerateGameCode

        /// <summary>
        /// Generates the javascript code for the game described in the specified model.
        /// </summary>
        /// <param name="model">The model that describes the game.</param>
        public string GenerateGameCode(GameModel model)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            UpdateModules(model.Units);
            UpdateModules(model);

            var unitModules = new ModuleCollection();
            foreach (var unit in model.Units)
            {
                unitModules = new ModuleCollection(unitModules.Union(unit.Modules, Module.Comparer));
            }

            string background = model.Background.GenerateCode();
            string modules = unitModules.GenerateUnitModulesCode() + "\n" + model.Modules.GenerateGameModulesCode();
            string unitConstructors = GenerateUnitConstructors();
            string units = unitConstructors + model.Units.GenerateCollectionCode((unit) => unit.GenerateCode());
            string bindings = model.KeyBindings.GenerateCollectionCode((binding) => binding.GenerateCode());

            string game = Regex.Replace(gameTemplate, BackgroundPlaceholder, background, RegexOptions.None);
            game = Regex.Replace(game, ModulesPlaceholder, modules, RegexOptions.None);
            game = Regex.Replace(game, UnitsPlaceholder, units, RegexOptions.None);
            game = Regex.Replace(game, KeyBindingsPlaceholder, bindings, RegexOptions.None);

            return game;
        }
开发者ID:CreatingGenres,项目名称:GameMaker,代码行数:33,代码来源:JsGenerator.cs

示例11: Play

        public override void Play(GameModel gameModel)
        {
            List<CardModel> drawn = new List<CardModel>();
            List<CardModel> setAside = new List<CardModel>();
            do
            {
                CardModel card = gameModel.CurrentPlayer.DrawCard();
                if (card == null)
                {
                    break;
                }
                if (card.Is(CardType.Treasure))
                {
                    drawn.Add(card);
                }
                else
                {
                    setAside.Add(card);
                }
            } while (drawn.Count < 2);

            foreach(CardModel card in drawn)
            {
                gameModel.CurrentPlayer.PutInHand(card);
            }
            foreach (CardModel card in setAside)
            {
                gameModel.CurrentPlayer.DiscardCard(card);
            }
        }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:30,代码来源:Adventurer.cs

示例12: Play

        public override void Play(GameModel gameModel)
        {
            this.returnedCard = null;
            Player player = gameModel.CurrentPlayer;
            CardModel choice = player.Chooser.ChooseOneCard(CardChoiceType.Ambassador, "Choose a card to return to the supply", Chooser.ChoiceSource.FromHand, player.Hand);
            if (choice != null)
            {
                Pile supply = gameModel.SupplyPiles.Where(pile => pile.Card.Name == choice.Name).FirstOrDefault();
                if (supply != null)
                {
                    List<CardModel> toReturn = new List<CardModel>(player.Hand.Where(card => card.Name == choice.Name).Take(2));
                    this.returnedCard = choice.GetType();
                    string[] choices = new string[toReturn.Count + 1];
                    for (int i = 0; i < choices.Length; i++)
                    {
                        choices[i] = i.ToString();
                    }
                    int trashChoice = player.Chooser.ChooseOneEffect(EffectChoiceType.AmbassadorCount, choice, "Return how many to supply?", choices, choices);

                    for (int i = 0; i < trashChoice; i++)
                    {
                        player.RemoveFromHand(toReturn[i]);
                        supply.PutCardOnPile(toReturn[i]);
                    }
                }
            }
        }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:27,代码来源:Ambassador.cs

示例13: Play

 public override void Play(GameModel gameModel)
 {
     IEnumerable<int> c = gameModel.CurrentPlayer.Chooser.ChooseSeveralEffects(EffectChoiceType.TrustySteed, "Choose two:", 2, 2, choices, choiceDescriptions);
     foreach (int choice in c)
     {
         switch (choice)
         {
             case 0:
                 gameModel.CurrentPlayer.Draw();
                 gameModel.CurrentPlayer.Draw();
                 break;
             case 1:
                 gameModel.CurrentPlayer.AddActionCoin(2);
                 break;
             case 2:
                 gameModel.CurrentPlayer.GainActions(2);
                 break;
             case 3:
                 for (int i = 0; i < 4; i++)
                 {
                     gameModel.CurrentPlayer.GainCard(typeof(Silver));
                 }
                 gameModel.CurrentPlayer.PutDeckInDiscard();
                 break;
         }
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:27,代码来源:TrustySteed.cs

示例14: GameById

        public GameModel GameById(int id)
        {
            GameModel ret = new GameModel();

            using (ADayInTheLifeEntities db = new ADayInTheLifeEntities())
            {
                try
                {
                    Game game = db.Games.Where(o => o.GameId == id).FirstOrDefault();

                    if (game == null)
                    {
                        throw new Exception(String.Format("Issue: Game {0} cannot be found", id));
                    }

                    ret = new GameModel()
                    {
                        GameId = game.GameId,
                        Players = game.Players,
                        WinCondition1 = game.WinCondition1,
                        WinCondition2 = game.WinCondition2,
                        WinCondition3 = game.WinCondition3,
                        WinCondition4 = game.WinCondition4
                    };
                }
                catch (Exception e)
                {
                    //TODO: Log This.
                }
            }
            return ret;
        }
开发者ID:slackercoder,项目名称:ADayInTheLife_API_GitHub,代码行数:32,代码来源:GameRepo.cs

示例15: PlayAttack

 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach(Player player in attackedPlayers)
     {
         player.HasMinusOneCoinToken = true;
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:7,代码来源:Relic.cs


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