Exemplo n.º 1
0
    public static void ChangeState()      //oyunun ilgili anındaki durumuna göre hedef state'e geiş yapar
    {
        Gamestate _gamestate = GameManager.gameState;

        if (_gamestate.Equals(Gamestate.Wait))
        {
            GameManager.gameState = Gamestate.Play;
        }
        else if (_gamestate.Equals(Gamestate.Play))
        {
            GameManager.gameState = Gamestate.Finish;
        }
        else if (_gamestate.Equals(Gamestate.Finish))
        {
            GameManager.gameState = Gamestate.Wait;
        }
    }
Exemplo n.º 2
0
        //TODO: Check if capital and apply Overtake Enemy
        public async Task AttackTile(int x, int y, bool halfPopulation, string connectionID)
        {
            //Game is not running, should not accept input
            if (!gamestate.Equals(Gamestate.InGame))
            {
                return;
            }

            Faction playerFaction = playerManager.GetFaction(connectionID);

            if (game.GetTileAtPosition(x, y).GetShortType().Equals("C"))
            {
                //Capital Tile => Apply overtake Enemy modifier and end game if needed or disable Faction
                string updatedTiles = game.AttackCapital(x, y, halfPopulation, playerFaction);
                if (updatedTiles != null)
                {
                    await GameHub.Current.Clients.All.SendAsync("Cl_CompressedUpdate", GZIPCompress.Compress(updatedTiles));
                }
                //A Faction won, all others have been eliminated
                if (game.GetAllFactions().Count == 1)
                {
                    await GameHub.Current.Clients.Group(playerFaction.ToString()).SendAsync("Cl_GameEnded", "Your Faction won! You were part of: ");

                    EndGame();
                }
            }
            else if (game.AttackTile(x, y, halfPopulation, playerFaction) && game.GetTileAtPosition(x, y).Coin.Equals(Coin.None))
            {
                //Normal Attack
                Tile t = game.GetTileAtPosition(x, y);
                await GameHub.Current.Clients.All.SendAsync("Cl_TileUpdate", x, y, t.Faction.ToString(), t.Population, t.Coin.ToString());

                await GameHub.Current.Clients.Group(playerFaction.ToString()).SendAsync("Cl_FastTick", game.GetFreePopulationFromFaction(playerFaction));
            }
            else
            {
                //Tile has Coin on it -> Use Coin first
                string updatedTiles = game.AttackTileWithCoin(x, y, playerFaction);
                if (updatedTiles != null)
                {
                    await GameHub.Current.Clients.All.SendAsync("Cl_CompressedUpdate", GZIPCompress.Compress(updatedTiles));
                }
            }
        }