• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GameModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Play

 public override void Play(GameModel gameModel)
 {
     CardModel namedCard = gameModel.CurrentPlayer.Chooser.ChooseOneCard(CardChoiceType.NameACardForJourneyman, "Name a card", ChoiceSource.None, gameModel.AllCardsInGame);
     List<CardModel> match = new List<CardModel>();
     List<CardModel> nonMatch = new List<CardModel>();
     CardModel card = gameModel.CurrentPlayer.DrawCard();
     while (card != null)
     {
         if (card.Name == namedCard.Name)
         {
             match.Add(card);
         }
         else
         {
             nonMatch.Add(card);
             if(nonMatch.Count == 3)
             {
                 break;
             }
         }
         card = gameModel.CurrentPlayer.DrawCard();
     }
     foreach (CardModel nonMatched in nonMatch)
     {
         gameModel.CurrentPlayer.PutInHand(nonMatched);
     }
     foreach (CardModel matched in match)
     {
         gameModel.CurrentPlayer.DiscardCard(matched);
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:31,代码来源:Journeyman.cs


示例17: Play

 public override void Play(GameModel gameModel)
 {
     if (!gameModel.CardModifiers.Any(modifier => modifier.GetType() == typeof(PrincessCardModifier)))
     {
         gameModel.AddCardModifier(new PrincessCardModifier());
     }
 }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:7,代码来源:Princess.cs


示例18: PlayAttack

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


示例19: PutGameModel

        public async Task<IHttpActionResult> PutGameModel(int id, GameModel gameModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != gameModel.Id)
            {
                return BadRequest();
            }

            db.Entry(gameModel).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GameModelExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
开发者ID:PascalS86,项目名称:wordclash,代码行数:32,代码来源:GameController.cs


示例20: GameRoom

        public GameRoom(Dictionary<IClientHolder, string> inputClients)
        {
            gameModel = new GameModel(logger);

            foreach(var client in inputClients)
            {
                client.Key.OnGetMessageFromClient += OnGetMessageFromClient;
                clients.Add(client.Key);
                clientNames.Add(client.Value);
            }

            gameContext.StartKyoku += StartKyoku;
            gameContext.Tsumo += Tsumo;
            gameContext.Dahai += Dahai;
            gameContext.Chi += Chi;
            gameContext.Pon += Pon;
            gameContext.Kakan += Kakan;
            gameContext.Daiminkan += Daiminkan;
            gameContext.Ankan += Ankan;
            gameContext.OpenDora += OpenDora;
            gameContext.Rinshan += Rinshan;
            gameContext.Reach += Reach;
            gameContext.ReachDahai += ReachDahai;
            gameContext.ReachAccept += ReachAccept;
            gameContext.Hora += Hora;
            gameContext.Ryukyoku += Ryukyoku;
            gameContext.Endkyoku += EndKyoku;
            gameContext.EndGame += EndGame;
            gameContext.CheckIsRyuKyoku += CheckIsRyukyoku;
            gameContext.CheckIsEndGame += CheckIsEndGame;
        }
开发者ID:rick0000,项目名称:MjModel,代码行数:31,代码来源:GameRoom.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GameNPC类代码示例发布时间:2022-05-24
下一篇:
C# GameMode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap