Exemplo n.º 1
0
        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]);
                    }
                }
            }
        }
Exemplo n.º 2
0
 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;
         }
     }
 }
Exemplo n.º 3
0
        /// <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;
        }
        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;
        }
Exemplo n.º 5
0
 public override void Play(GameModel gameModel)
 {
     for(int i=0;i<gameModel.RightOfCurrentPlayer.GainedLastTurn.Count;i++)
     {
         gameModel.CurrentPlayer.GainCard(typeof(Silver));
     }
 }
Exemplo n.º 6
0
        public override void Play(GameModel gameModel)
        {
            List<CardModel> cards = gameModel.CurrentPlayer.DrawCards(5);
            if (cards.Count > 0)
            {
                gameModel.CurrentPlayer.RevealCards(cards);

                int lookAtCards = gameModel.CurrentPlayer.Chooser.ChooseOneEffect(EffectChoiceType.DiscardOrPutOnDeck, cards, "Discard them?", choices, choices);
                if (lookAtCards == 0)
                {
                    IEnumerable<CardModel> order = gameModel.CurrentPlayer.Chooser.ChooseOrder(CardOrderType.OrderOnDeck, "Put them back in any order(first on top)", cards);
                    foreach (CardModel card in order.Reverse())
                    {
                        gameModel.CurrentPlayer.Deck.PlaceOnTop(card);
                    }
                }
                else
                {
                    foreach (CardModel card in cards)
                    {
                        gameModel.CurrentPlayer.DiscardCard(card);
                    }
                }
            }
        }
 void setTitle(GameModel game)
 {
     TitleTextScript titleText;
     // set title
     titleText = FindObjectOfType<TitleTextScript>();
     titleText.setTitle ("Turn " + game.turn);
 }
Exemplo n.º 8
0
 public override void OnTrash(GameModel gameModel, Player owner)
 {
     if (gameModel.Trash.Remove(this.ThisAsTrashTarget))
     {
         owner.PutInHand(this.ThisAsTrashTarget);
     }
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        public override void Play(GameModel gameModel)
        {
            Player currentPlayer = gameModel.CurrentPlayer;
            IEnumerable<int> c = currentPlayer.Chooser.ChooseSeveralEffects(EffectChoiceType.Pawn, "Choose 2", 2, 2, choices, choiceDescriptions);
            foreach (int choice in c)
            {
                switch (choice)
                {
                    case 0:
                        currentPlayer.Draw();
                        break;

                    case 1:
                        currentPlayer.AddActionCoin(1);
                        break;

                    case 2:
                        currentPlayer.GainActions(1);
                        break;

                    case 3:
                        currentPlayer.GainBuys(1);
                        break;
                }
            }
        }
Exemplo n.º 11
0
 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach(Player player in attackedPlayers)
     {
         player.HasHauntedWoodsEffect.Add(gameModel.CurrentPlayer);
     }
 }
Exemplo n.º 12
0
 public override void OnBuy(GameModel gameModel)
 {
     foreach(CardModel card in gameModel.CurrentPlayer.Chooser.ChooseSeveralCards(Chooser.CardChoiceType.Trash, "Trash up to 2 cards you have in play", Chooser.ChoiceSource.InPlay, 0, 2, gameModel.CurrentPlayer.Played).ToArray())
     {
         gameModel.CurrentPlayer.Trash(card);
     }
 }
Exemplo n.º 13
0
 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);
         }
     }
 }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player player in attackedPlayers)
     {
         player.GainCard(gameModel.Ruins);
     }
 }
Exemplo n.º 16
0
 public override void Play(GameModel gameModel)
 {
     if (!gameModel.CardModifiers.Any(modifier => modifier.GetType() == typeof(PrincessCardModifier)))
     {
         gameModel.AddCardModifier(new PrincessCardModifier());
     }
 }
Exemplo n.º 17
0
 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player attacked in attackedPlayers)
     {
         this.DoAttack(gameModel.CurrentPlayer, attacked);
     }
 }
Exemplo n.º 18
0
    public MatchManager(GameModel gameModel, TimerQueue timedQ, EventBus eventBus, EventFactory eventFactory, List<string> levelPaths)
    {
      _pointsPerCity = 100;
      _pointsPerRemainingShots = 10;
      _currentLevelIndex = 0;
      _userScore = 0;
      _timerQ = timedQ;
      _gameModel = gameModel;
      _levels = new List<Level>();
      _eventFactory = eventFactory;
      _eventBus = eventBus;

      foreach (string path in levelPaths)
      {
        try
        {
          _levels.Add(new Level(path));
        }
        catch (Exception e)
        {
          Console.WriteLine("ERROR caught exception loading level from path: "+path+e.Message+e.StackTrace);
        }
      }

      //initiaize the first level
      _loadLevel(_levels[0]);
    }
Exemplo n.º 19
0
 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach(Player player in attackedPlayers)
     {
         player.HasMinusOneCoinToken = true;
     }
 }
Exemplo n.º 20
0
 void Awake()
 {
     text = transform.FindChild("Text").gameObject;
     text.GetComponent<MeshRenderer>().sortingOrder
         = GetComponent<SpriteRenderer>().sortingOrder + 1;
     model = GameModel.GetInstance();
 }
Exemplo n.º 21
0
 public override void Play(GameModel gameModel)
 {
     List<CardModel> drawnCards = new List<CardModel>();
     CardModel drawnCard = gameModel.CurrentPlayer.DrawCard();
     while (drawnCard != null && !drawnCard.Is(CardType.Treasure))
     {
         drawnCards.Add(drawnCard);
         drawnCard = gameModel.CurrentPlayer.DrawCard();
     }
     if (drawnCard != null)
     {
         gameModel.TextLog.WriteLine(gameModel.CurrentPlayer.Name + " reveals " + drawnCard.Name);
         int choice = gameModel.CurrentPlayer.Chooser.ChooseOneEffect(EffectChoiceType.TrashForLoan, drawnCard, "Trash it?", choices, choices);
         if (choice == 0)
         {
             gameModel.CurrentPlayer.Trash(drawnCard);
         }
         else
         {
             gameModel.CurrentPlayer.DiscardCard(drawnCard);
         }
     }
     foreach (CardModel card in drawnCards)
     {
         gameModel.CurrentPlayer.DiscardCard(card);
     }
 }
Exemplo n.º 22
0
        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;
        }
 protected void Awake()
 {
     model = GameModel.GetInstance();
     display = GetComponent<ZombieSpriteDisplay>();
     state = GetComponent<AbnormalState>();
     Invoke("Groan", Random.Range(5f, 10f));
 }
Exemplo n.º 24
0
 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);
     }
 }
Exemplo n.º 25
0
 public override void Play(GameModel gameModel)
 {
     if (!gameModel.CardModifiers.OfType<HighwayCardModifier>().Any(m => m.Source == this))
     {
         gameModel.AddCardModifier(new HighwayCardModifier(this));
     }
 }
Exemplo n.º 26
0
 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();
         }
     }
 }
Exemplo n.º 27
0
 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player player in attackedPlayers)
     {
         player.GainCard(typeof(Curse));
     }
 }
Exemplo n.º 28
0
 public override void PlayAttack(GameModel gameModel, IEnumerable<Player> attackedPlayers)
 {
     foreach (Player player in attackedPlayers)
     {
         player.DiscardTo(4);
     }
 }
Exemplo n.º 29
0
        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);
            }
        }
        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;
        }
Exemplo n.º 31
0
 public void DeleteGame(GameModel game)
 {
     GameContext.Remove(game);
     GameContext.SaveChanges();
 }
Exemplo n.º 32
0
 public void AddGame(GameModel game)
 {
     GameContext.Add(game);
     GameContext.SaveChanges();
 }
Exemplo n.º 33
0
        // set Start Auto Hp/Mp/Exp/Shutdown
        public static void AutoBuff(AccountModel Account, GameModel GameM)
        {
            Function Funcs = Account.Func;
            int      TimeAutoHP = 0, hp = 0, mp = 0, exp = 0;

            try
            {
                while (MAPN.ProcessExists(Account.Pid) && Account.IsAuto)
                {
                    try
                    {
                        TimeAutoHP = Account.AutoInput;
                        if (Account.IsHp)
                        {
                            hp = Account.HpInput;
                            if (Funcs.ReadHp() <= hp)
                            {
                                Funcs.SendKeyQ();
                                Thread.Sleep(10);
                            }
                        }

                        if (Account.IsMp)
                        {
                            mp = Account.MpInput;
                            if (Funcs.ReadMp() <= mp)
                            {
                                Funcs.SendKeyW();
                                Thread.Sleep(10);
                            }
                        }

                        if (Account.IsExP)
                        {
                            exp = Account.ExpInput;
                            if (Funcs.ReadExp() >= exp)
                            {
                                Account.IsAuto = false;
                                GameM.Clients--;
                                Console.Beep();
                                MessageBox.Show(Language.FullExp, Language.Set(Language.NotificationT, Account.Name));
                            }
                        }
                        if (Account.IsShutdown && Account.IsAutoTrain)
                        {
                            if (Funcs.ReadHp() <= Account.HpShutDown)
                            {
                                Account.IsAuto = false;
                                Console.Beep();
                                Console.Beep();
                                Process.GetProcessById(Account.Pid).Kill();
                            }
                        }

                        Thread.Sleep(TimeAutoHP + 10);
                    }
                    catch (ThreadAbortException) { Account.IsAuto = false; break; }
                }
            }
            catch (ThreadAbortException) { Account.IsAuto = false; }
        }
Exemplo n.º 34
0
 public ControlAnt(IGameController gameController, PlayerModel playerModel, GameModel gameModel)
 {
     GameController = gameController;
     PlayerModel    = playerModel;
     GameModel      = gameModel;
 }
Exemplo n.º 35
0
 void UpdateModel()
 {
     gameModel = gameFightController.GetModel();
 }
Exemplo n.º 36
0
 public void RegisterPlayer()
 {
     GameModel.RegisterPlayer(Playername.text, Password.text);
     HidePanels();
     MainGame.SetActive(true);
 }
Exemplo n.º 37
0
 public override void EndTurn(GameModel model)
 {
 }
Exemplo n.º 38
0
 protected void Awake()
 {
     animator = GetComponentInChildren <Animator>();
     model    = GameModel.GetInstance();
     grow     = GetComponent <PlantGrow>();
 }
Exemplo n.º 39
0
        private void CreateWorld(GameState state)
        {
            _model   = new GameModel(state.Size.Item1, state.Size.Item2);
            _players = new ObservableCollection <Player>(state.Players);
            PlayerList.ItemsSource = _players;

            _gameGrid    = new Grid();
            _lineButtons = new List <Button>();
            _squareGrids = new List <Grid>();

            SetRowDefinitions();
            SetColumnsDefinitions();

            var lst = _model.GetAllElements().ToList();

            foreach (var piece in lst)
            {
                var element = GetElementForPiece(piece);
                element.SetValue(Grid.RowProperty, piece.Row);
                element.SetValue(Grid.ColumnProperty, piece.Column);
                element.Tag = piece;
                _gameGrid.Children.Add(element);

                if (element is Button)
                {
                    _lineButtons.Add(element as Button);
                }

                if (piece is Square)
                {
                    var square = piece as Square;
                    square.Completed += SquareCompleted;

                    _squareGrids.Add(element as Grid);
                }
            }

            Board.Children.Clear();
            Board.Children.Add(_gameGrid);

            foreach (var button in _lineButtons)
            {
                SetPieceColor(button);
            }

            foreach (var occupied in state.OccupiedLines)
            {
                var line = _model.GetElementAt(occupied.Row, occupied.Column) as Line;
                if (line != null)
                {
                    line.Occupy(occupied.PlayerId);
                }
                var button = FindButton(occupied.Row, occupied.Column);
                SetPieceColor(button);
                var player = GetPlayer(occupied.PlayerId);
                if (player != null)
                {
                    player.Score++;
                }
            }
        }
Exemplo n.º 40
0
 public GameController(GameDifficulty difficulty, PlayerType enemyType)
 {
     gm            = new GameModel(new Player(PlayerType.Human, "X"), new Player(enemyType, "O"), difficulty);
     currentPlayer = gm.CurrentPlayer;
 }
        public LevelSelectionState(GameModel gameModel)
            : base(gameModel)
        {
            _font = _content.Load <SpriteFont>("Fonts/Font");

            _player = new Player(_content.Load <Texture2D>("Player/boy"))
            {
                Layer    = 1.0f,
                Position = new Vector2(50, 500),
            };

            var levelModel1 = new LevelModel()
            {
                Name = "Mountains",
                ScrollingBackgrounds = new List <ScrollingBackground>()
                {
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Trees"), _player, 60f)
                    {
                        Layer = 0.99f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Floor"), _player, 60f)
                    {
                        Layer = 0.9f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Hills_Front"), _player, 40f)
                    {
                        Layer = 0.8f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Hills_Middle"), _player, 30f)
                    {
                        Layer = 0.79f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Clouds_Fast"), _player, 25f, true)
                    {
                        Layer = 0.78f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Hills_Back"), _player, 0f)
                    {
                        Layer = 0.77f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Clouds_Slow"), _player, 10f, true)
                    {
                        Layer = 0.7f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Sky"), _player, 0f)
                    {
                        Layer = 0.1f,
                    },
                },
            };

            var levelModel2 = new LevelModel()
            {
                Name = "Snowy Mountains",
                ScrollingBackgrounds = new List <ScrollingBackground>()
                {
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Trees"), _player, 60f)
                    {
                        Layer = 0.99f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Floor"), _player, 60f)
                    {
                        Layer = 0.9f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Hills_Front"), _player, 40f)
                    {
                        Layer = 0.8f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Hills_Middle"), _player, 30f)
                    {
                        Layer = 0.79f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Clouds_Fast"), _player, 25f, true)
                    {
                        Layer = 0.78f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Hills_Back"), _player, 0f)
                    {
                        Layer = 0.77f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Clouds_Slow"), _player, 10f, true)
                    {
                        Layer = 0.7f,
                    },
                    new ScrollingBackground(_content.Load <Texture2D>("ScrollingBackgrounds/Sky"), _player, 0f)
                    {
                        Layer = 0.1f,
                    },
                },
            };

            _components = new List <LevelSelector>()
            {
                new LevelSelector(_player, levelModel1)
                {
                    Scale    = 0.25f,
                    Position = new Vector2(50, 50),
                },
                new LevelSelector(_player, levelModel2)
                {
                    Scale    = 0.25f,
                    Position = new Vector2(420, 50),
                },
            };
        }
Exemplo n.º 42
0
        public void GameStart(GameModel game, PlayerModel firstPlayer, PlayerModel secondPlayer, List <UserCardGroupDetailModel> firstCardGroup, List <UserCardGroupDetailModel> secondCardGroup, string firstUserProfession, string secondUserProfession)
        {
            #region 加载玩家卡组
            UserContext firstUser = new UserContext
            {
                UserCode     = firstPlayer.UserCode,
                Player       = firstPlayer,
                IsActivation = true,
                IsFirst      = true,
                AllCards     = new List <Card>()
            };
            List <Card> lstCardLib = _gameCache.GetAllCard();

            int cardInGameIndex = 0;
            foreach (var cg in firstCardGroup)
            {
                Card libCard = lstCardLib.First(c => c.CardCode == cg.CardCode);
                var  card    = Activator.CreateInstance(libCard.GetType()) as Card;
                card.CardInGameCode    = cardInGameIndex.ToString();
                card.IsFirstPlayerCard = true;
                firstUser.AllCards.Add(card);
                cardInGameIndex++;
            }

            UserContext secondUser = new UserContext
            {
                UserCode     = secondPlayer.UserCode,
                Player       = secondPlayer,
                IsActivation = true,
                IsFirst      = false,
                AllCards     = new List <Card>()
            };
            secondCardGroup.ForEach(delegate(UserCardGroupDetailModel detail)
            {
                Card libCard           = lstCardLib.First(c => c.CardCode == detail.CardCode);
                var card               = Activator.CreateInstance(libCard.GetType()) as Card;
                card.CardInGameCode    = cardInGameIndex.ToString();
                card.IsFirstPlayerCard = false;
                secondUser.AllCards.Add(card);
                cardInGameIndex++;
            });

            //secondUser.StockCards = secondUser.AllCards;


            GameContext = new GameContext
            {
                Players         = new List <UserContext>(),
                DeskCards       = null,
                GameCode        = game.GameCode,
                CurrentTurnCode = game.CurrentTurnCode,
                NextTurnCode    = game.NextTurnCode,
                GameStatus      = GameStatus.进行中,
                GameCache       = _gameCache
            };
            GameContext.Players.Add(firstUser);
            GameContext.Players.Add(secondUser);
            #endregion

            #region 初始化开场选牌
            int        firstPickUpCount = 4;
            List <int> lstRndIndex      = RandomUtil.CreateRandomInt(0, GameContext.Players.First(c => c.IsFirst).AllCards.Count - 1, firstPickUpCount);
            for (int i = 0; i < lstRndIndex.Count; i++)
            {
                if (i < lstRndIndex.Count - 1)
                {
                    //lstFirstPickUpCard.Add(GameContext.Players.First(c => c.IsFirst).AllCards[lstRndIndex[i]]);
                    GameContext.Players.First(c => c.IsFirst).AllCards[lstRndIndex[i]].CardLocation = CardLocation.InitCard;
                }
                //lstSecondPickUpCard.Add(GameContext.Players.First(c => c.IsFirst == false).AllCards[lstRndIndex[i]]);
                GameContext.Players.First(c => c.IsFirst == false).AllCards[lstRndIndex[i]].CardLocation = CardLocation.InitCard;
            }

            BaseHero firstHero = null, secondHero = null;
            switch (firstUserProfession)
            {
            case "Druid": firstHero = new Druid(); break;

            case "Hunter": firstHero = new Hunter(); break;

            case "Mage": firstHero = new Mage(); break;

            case "Paladin": firstHero = new Paladin(); break;

            case "Priest": firstHero = new Priest(); break;

            case "Rogue": firstHero = new Rogue(); break;

            case "Shaman": firstHero = new Shaman(); break;

            case "Warlock": firstHero = new Warlock(); break;

            case "Warrior": firstHero = new Warrior(); break;
            }
            switch (secondUserProfession)
            {
            case "Druid": secondHero = new Druid(); break;

            case "Hunter": secondHero = new Hunter(); break;

            case "Mage": secondHero = new Mage(); break;

            case "Paladin": secondHero = new Paladin(); break;

            case "Priest": secondHero = new Priest(); break;

            case "Rogue": secondHero = new Rogue(); break;

            case "Shaman": secondHero = new Shaman(); break;

            case "Warlock": secondHero = new Warlock(); break;

            case "Warrior": secondHero = new Warrior(); break;
            }

            cardInGameIndex++;
            firstHero.CardLocation      = CardLocation.场上;
            firstHero.CardInGameCode    = cardInGameIndex.ToString();
            firstHero.DeskIndex         = 0;
            firstHero.IsFirstPlayerCard = true;
            firstUser.AllCards.Add(firstHero);

            cardInGameIndex++;
            secondHero.CardLocation      = CardLocation.场上;
            secondHero.CardInGameCode    = cardInGameIndex.ToString();
            secondHero.DeskIndex         = 8;
            secondHero.IsFirstPlayerCard = false;
            secondUser.AllCards.Add(secondHero);

            GameContext.DeskCards = new DeskBoard()
            {
                firstHero, null, null, null, null, null, null, null, secondHero, null, null, null, null, null, null, null
            };
            #endregion

            GameContext.Settlement();
            _gameCache.SetContext(GameContext);
        }
Exemplo n.º 43
0
 public void SubScore()
 {
     GameModel.GetGameModel().SubScore();
 }
Exemplo n.º 44
0
 public int GetScore()
 {
     return(GameModel.GetGameModel().Score);
 }
Exemplo n.º 45
0
 void Awake()
 {
     _model         = GameModel.GetInstance();
     Time.timeScale = 1;
 }
Exemplo n.º 46
0
 public void AddScore()
 {
     GameModel.GetGameModel().AddScore();
 }
Exemplo n.º 47
0
 public void setGameModel(GameModel model)
 {
     gameModel = model;
 }
Exemplo n.º 48
0
 public virtual void OnAdd(GameModel mod, int bx, int by)
 {
     owner = mod;
     blockPos.Set(bx, by);
 }
Exemplo n.º 49
0
 public PackmanController(GameModel gameModel)
 {
     this.gameModel = gameModel;
 }
Exemplo n.º 50
0
 public void Init(GameModel model)
 {
     _model = model;
 }
Exemplo n.º 51
0
 void Init(GameModel model)
 {
     CollsionArea.enabled = false;
     _model = model;
 }
Exemplo n.º 52
0
 void Start()
 {
     GameModel.LoadInventoryItems();
 }
Exemplo n.º 53
0
 /// <summary>
 /// Called when a new GameModel is created, aka when things like Monkey Knowledge are applied to towers
 /// <br/>
 /// Equivalent to a HarmonyPostFix on GameModel_CreatedModded
 /// </summary>
 public virtual void OnNewGameModel(GameModel result, List <ModModel> mods)
 {
 }
Exemplo n.º 54
0
 /// <summary>
 /// Called when Game.instance.model is not null
 /// </summary>
 public virtual void OnGameModelLoaded(GameModel model)
 {
 }
Exemplo n.º 55
0
 public GameDetailMainViewModel(GameModel model)
 {
     GameModel = model;
 }
Exemplo n.º 56
0
 /// <summary>
 /// Called when a new GameModel is created, aka when things like Monkey Knowledge are applied to towers
 /// <br/>
 /// Equivalent to a HarmonyPostFix on GameModel_CreatedModded
 /// </summary>
 public virtual void OnNewGameModel(GameModel result)
 {
 }
Exemplo n.º 57
0
 public void Init()
 {
     _universeConfig = GameConfig.Get <UniverseConfig>();
     GameModel.HandleGet <PlanetModel>(OnPlanetModel);
 }
Exemplo n.º 58
0
 void Start()
 {
     model = GameModel.Instance;
 }
Exemplo n.º 59
0
 void Awake()
 {
     text = transform.Find("Text").gameObject;
     text.GetComponent <MeshRenderer>().sortingOrder = 10001;
     model = GameModel.GetInstance();
 }
Exemplo n.º 60
0
        public static void StartAuto(GameModel GameM, AccountModel iAccount, LoginModel LoginM)
        {
            try
            {
                if (!LoginM.Login)
                {
                    iAccount.IsAuto = false;
                    MessageBox.Show(Language.KichAccount, Language.Notification, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch { return; }

            try
            {
                if (iAccount.IsAuto)
                {
                    GameM.Clients = GetNumberClient(GameM) - 1;

                    if (LoginM.RegClient <= 0)
                    {
                        iAccount.IsAuto = false;
                        MessageBox.Show(Language.ZeroClients, Language.Notification, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (GameM.Clients < LoginM.RegClient)
                    {
                        if (iAccount.Name == Language.NA)
                        {
                            MessageBox.Show(Language.NullChar, Language.Notification, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                            iAccount.IsAuto = false;
                            return;
                        }

                        GameM.Clients++;

                        if (iAccount.IsAutoBuff)
                        {
                            BuffSkill(iAccount, false);
                        }

                        iAccount.TAuto = new Thread(delegate() { AutoBuff(iAccount, GameM); })
                        {
                            IsBackground = true
                        };
                        iAccount.TAuto.Start();

                        iAccount.TAutoTrain = new Thread(delegate() { StartAll(iAccount); })
                        {
                            IsBackground = true
                        };
                        iAccount.TAutoTrain.Start();
                    }
                    else
                    {
                        ReturnAll(iAccount, GameM);
                        MessageBox.Show(Language.UserClients, Language.Notification);
                        return;
                    }
                }
                else
                {
                    ReturnAll(iAccount, GameM);
                }
            }
            catch
            {
                iAccount.IsAuto = false;
            }
        }