本文整理汇总了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;
}
示例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);
}
示例3: Play
public override void Play(GameModel gameModel)
{
if (!gameModel.CardModifiers.OfType<HighwayCardModifier>().Any(m => m.Source == this))
{
gameModel.AddCardModifier(new HighwayCardModifier(this));
}
}
示例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);
}
}
}
示例5: PlayAttack
public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
{
foreach(Player player in attackedPlayers)
{
player.HasHauntedWoodsEffect.Add(gameModel.CurrentPlayer);
}
}
示例6: PlayAttack
public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
{
foreach (Player attacked in attackedPlayers)
{
this.DoAttack(gameModel.CurrentPlayer, attacked);
}
}
示例7: PlayAttack
public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
{
foreach (Player player in attackedPlayers)
{
player.GainCard(gameModel.Ruins);
}
}
示例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();
}
}
}
示例9: PlayAttack
public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
{
foreach (Player player in attackedPlayers)
{
player.GainCard(typeof(Curse));
}
}
示例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;
}
示例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);
}
}
示例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]);
}
}
}
}
示例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;
}
}
}
示例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;
}
示例15: PlayAttack
public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
{
foreach(Player player in attackedPlayers)
{
player.HasMinusOneCoinToken = true;
}
}