Beispiel #1
0
    public void showDescriptionButton(Rect buttonRect, Rect descRect, GameDescription desc, ButtonDelegate buttonDelegate, Object delegateData, int indice)
    {
        showButton(buttonRect, "", style, buttonDelegate, delegateData);
        fontInResolution = textFont("[F ButtonFontSmallSmall]", "[F ButtonFontMidle]", "[F ButtonFontBig]", "[F ButtonFontBig32]");

        if (!desc.empty && !desc.corrupt)
        {
            //show button behind text
            showButton(buttonRect, "", style, buttonDelegate, delegateData);

            //show description
            Rect townNameRect = new Rect(descRect);

            //float yDiff = (0.00005357f)*(float)Screen.height + (-0.02714f);
            //yDiff = Mathf.Max(yDiff,0.0f);
            //townNameRect.y+=yDiff;
            string text = "[HA C]" + fontInResolution + desc.town + "\n[HA C][c F8A81CFF]LVL: [c FFFFFFFF]" + desc.level.ToString() + "  " + "[c F8A81CFF]EXP: [c FFFFFFFF]" + desc.experience.ToString() + fontInResolution;

            GuiUtils.showLabelFormat(townNameRect, text, labelStyle, new string[] { "ButtonFontSmallSmall", "ButtonFontMidle", "ButtonFontBig", "ButtonFontBig32" });
        }
        else if (desc.empty)
        {
            style.font = styleInResolution(style, buttonFont, buttonMidle, buttonBig, buttonBigXXL);
            showButton(buttonRect, emptyText.text, style, buttonDelegate, delegateData);
        }
        else if (desc.corrupt)
        {
            style.font = styleInResolution(style, buttonFont, buttonMidle, buttonBig, buttonBigXXL);
            showButton(buttonRect, "-" + corruptFileText.text + "-", style, buttonDelegate, delegateData);
        }
    }
        public static async Task SendGameConfigToServer(AppDataContext appDataContext)
        {
            GameDescription gameDescription = appDataContext.GetGameConfig().gameDescription;

            JsonObject json      = WebService.ToJson(gameDescription, appDataContext.DeckRating.Value);
            string     parameter = json.Stringify();

            var fullUrl = new System.Text.StringBuilder();

            fullUrl.Append(WebService.webUrl);
            fullUrl.Append("?action=RECORD&values=");
            fullUrl.Append(parameter.Replace(" ", "%20"));

            try
            {
                using (var client = new Windows.Web.Http.HttpClient())
                    using (var request = new Windows.Web.Http.HttpRequestMessage())
                    {
                        request.RequestUri = new System.Uri(fullUrl.ToString());
                        using (Windows.Web.Http.HttpResponseMessage responseMessage = await client.SendRequestAsync(request).AsTask())
                        {
                            if (responseMessage.IsSuccessStatusCode)
                            {
                                string strResult = await responseMessage.Content.ReadAsStringAsync().AsTask();

                                System.Diagnostics.Debug.WriteLine("RECORD Reponse from server:");
                                System.Diagnostics.Debug.WriteLine(strResult);
                            }
                        }
                    }
            }
            catch (System.Exception)
            { }
        }
Beispiel #3
0
        public override void OnShow()
        {
            base.OnShow();
            // вывод списка игроков
            List <GameDescription> gameDescriptions = ConnectionManager.Instance.GetGameList();

            if (gameDescriptions == null)
            {
                return;
            }

            GameDescription gameDescription = gameDescriptions.FirstOrDefault(description => GameId == description.GameId);

            // todo переписать
            if (gameDescription != null)
            {
                _players = gameDescription.Players;
            }

            // todo ?
            if (_players == null)
            {
                return;
            }

            foreach (var player in _players)
            {
                _playersList.Items.Add(player.Name);
            }
        }
Beispiel #4
0
 private void btCreate_OnClick(object sender, EventArgs e)
 {
     try
     {
         var newGame = new CreateGameDialog();
         if (newGame.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         _activeGame = _service.CreateGame(newGame.Mode, newGame.MaxPlayers,
                                           newGame.Tile, 1);                                                                                                                      //заглушка "1" вместо получения количества команд
         if (_activeGame != null)
         {
             Mode = Modes.Created;
         }
         else
         {
             Trace.WriteLine("Cli: CreateGame: can't create");
         }
     }
     catch (Exception exc)
     {
         Trace.WriteLine("Cli: CreateGame: " + exc);
     }
 }
Beispiel #5
0
        public GameSession(TileSet tileSet, int maxPlayersAllowed,
                           GameMode gameType, int gameID, int teams)
        {
            //	SessionTeamsList = new TeamsList();

            for (int i = 1; i <= teams; i++)
            {
                _sessionTeamsList.Teams.Add(new Team(i));
            }

            IsStarted = false;
            GameLevel = new GameLevel(Constants.LEVEL_WIDTH, Constants.LEVEL_HEIGHT, tileSet);

            var playerNames = new List <string>();

            _gameObjects = new List <AGameObject>();
            _newObjects  = new List <AGameObject>();

            LocalGameDescription = new GameDescription(playerNames, maxPlayersAllowed, gameType, gameID, tileSet, teams);
            if (gameType == GameMode.Deathmatch)
            {
                _spiderFactory = new DeathmatchSpiderFactory(GameLevel);
            }
            else
            {
                _spiderFactory = new DefaultSpiderFactory(GameLevel);
            }
            _bonusFactory = new BonusFactory();
            _wallFactory  = new WallFactory(GameLevel);
        }
Beispiel #6
0
    public static void fillGameDescription(int index, ref GameDescription gameDescription)
    {
        #if WRITE_SAVEGAMES
        string path = getSaveGameSlotFilePath(index);

        Debug.Log("loading file:" + path);
        XmlDocument xmlDoc = getXmlDocFromFile(path);
        if (xmlDoc == null)
        {
            gameDescription.empty   = false;
            gameDescription.corrupt = true;
            return;
        }

        XmlNodeList stats = xmlDoc.GetElementsByTagName("Stats");
        //XmlNodeList inventory = xmlDoc.GetElementsByTagName("Inventory");
        XmlNodeList quests     = xmlDoc.GetElementsByTagName("Quests");
        XmlNodeList navigation = xmlDoc.GetElementsByTagName("Navigation");

        gameDescription.empty      = false;
        gameDescription.town       = Game.getTownNiceName(navigation.Item(0).Attributes.GetNamedItem("town").InnerXml);
        gameDescription.experience = Int32.Parse(stats.Item(0).Attributes.GetNamedItem("experience").InnerXml);
        gameDescription.level      = Int32.Parse(stats.Item(0).Attributes.GetNamedItem("level").InnerXml);

        if (((XmlElement)quests[0]).GetElementsByTagName("Quest") != null)
        {
            gameDescription.nQuests = ((XmlElement)quests[0]).GetElementsByTagName("Quest").Count;
        }
        #endif
    }
Beispiel #7
0
        /// <summary>
        /// Добавляем игрока в текущую игру.
        /// </summary>
        public bool JoinGame(GameDescription game, MainSkyShootService player)
        {
            GameSession session = _gameSessions.Find(curGame => curGame.LocalGameDescription.GameId == game.GameId);

            SessionTable.Add(player.Id, session);
            return(session.AddPlayer(player));
        }
    private void AddGameButton(GameDescription game)
    {
        var go      = Instantiate(gameButtonPrefab, buttonContainer.transform);
        var handler = go.GetComponent <LobbyGameButtonHandler>();

        handler.Initialize(game, this);
    }
    public Unit player;     //temporally

    public void initialize(string gameName)
    {
        gameDesc = new GameDescription(gameName);
        player   = new Warrior();
        player.isPlayerControl = true;
        startLevel(gameDesc.startLevelName);
        selectLevel(curLevelName);
    }
    public void ReplaceGameDescription(GameDescription newValue)
    {
        var index     = GameComponentsLookup.GameDescription;
        var component = CreateComponent <GameDescriptionComponent>(index);

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Beispiel #11
0
 private void btLeave_OnClick(object sender, EventArgs e)
 {
     _service.LeaveGame();
     lstbGames.ClearSelected();
     RefreshClick(sender, e);
     _activeGame = null;
     Mode        = Modes.Choosing;
 }
Beispiel #12
0
 public static GameListItemViewModel ToGameDescriptionListItemViewModel(this GameDescription gameDescription)
 {
     if (gameDescription == null)
     {
         return(null);
     }
     return(new GameListItemViewModel {
         Id = gameDescription.Id, Name = gameDescription.Name
     });
 }
Beispiel #13
0
 public void PopulateFromGameDescription(GameDescription gameDescription)
 {
     this.currentDeck.PopulateCards(gameDescription.kingdomPiles.Select(c => DominionCard.Create(c)));
     if (gameDescription.baneCard != null)
     {
         this.baneCard.PopulateBaneCard(DominionCard.Create(gameDescription.baneCard));
     }
     this.eventCards.PopulateCards(gameDescription.events.Select(c => DominionCard.Create(c)));
     this.UseShelters.Value       = gameDescription.useShelters;
     this.UseColonyPlatinum.Value = gameDescription.useColonyAndPlatinum;
 }
        public int CreateGame(GameModes mode, int maxPlayers, MapSet mapType)
        {
            _currentGameId = _globalGameID;
            var gameDescription = new GameDescription(new List <Player> {
                Player
            }, maxPlayers, _globalGameID++, mapType, mode);

            GamesList.Add(gameDescription);

            return(gameDescription.GameId);
        }
    public GameEntity SetGameDescription(GameDescription newValue)
    {
        if (hasGameDescription)
        {
            throw new Entitas.EntitasException("Could not set GameDescription!\n" + this + " already has an entity with GameDescriptionComponent!",
                                               "You should check if the context already has a gameDescriptionEntity before setting it or use context.ReplaceGameDescription().");
        }
        var entity = CreateEntity();

        entity.AddGameDescription(newValue);
        return(entity);
    }
Beispiel #16
0
    public void createSaveGameDescriptions(ref GameDescription[] saveGameDescription)
    {
        for (int i = 0; i < saveGameDescription.Length; i++)
        {
            saveGameDescription[i] = new GameDescription();

            if (DataGame.saveGameExist(i))
            {
                DataGame.fillGameDescription(i, ref saveGameDescription[i]);
            }
        }
    }
Beispiel #17
0
 public bool JoinGame(GameDescription game)
 {
     try
     {
         return(_service.JoinGame(game));
     }
     catch (Exception e)
     {
         FatalError(e);
         return(false);
     }
 }
Beispiel #18
0
        private void ExpertClick(object sender, RoutedEventArgs e)
        {
            if (zeroStart.IsChecked == true)
            {
                gameDescription = GameDescription.EXPERT_ZERO;
            }
            else
            {
                gameDescription = GameDescription.EXPERT_SAFE;
            }

            NewGame();
        }
Beispiel #19
0
        private void IntermediateClick(object sender, RoutedEventArgs e)
        {
            if (zeroStart.IsChecked == true)
            {
                gameDescription = GameDescription.INTERMEDIATE_ZERO;
            }
            else
            {
                gameDescription = GameDescription.INTERMEDIATE_SAFE;
            }

            NewGame();
        }
    public void ReplaceGameDescription(GameDescription newValue)
    {
        var entity = gameDescriptionEntity;

        if (entity == null)
        {
            entity = SetGameDescription(newValue);
        }
        else
        {
            entity.ReplaceGameDescription(newValue);
        }
    }
Beispiel #21
0
        private void BeginnerClick(object sender, RoutedEventArgs e)
        {
            if (zeroStart.IsChecked == true)
            {
                gameDescription = GameDescription.BEGINNER_ZERO;
            }
            else
            {
                gameDescription = GameDescription.BEGINNER_SAFE;
            }

            NewGame();
        }
Beispiel #22
0
 private void lstbGames_OnSelectedIndexChanged(object sender, EventArgs e)
 {
     _activeGame = lstbGames.SelectedItem as GameDescription;
     if (_activeGame == null)
     {
         return;
     }
     lstbPlayers.Items.Clear();
     foreach (var name in _activeGame.Players)
     {
         lstbPlayers.Items.Add(name);
     }
     Mode = Modes.Choosing;
 }
 public void reset()
 {
     foreach (KeyValuePair <string, Level> level in levels)
     {
         if (level.Value.display.active)
         {
             level.Value.display.clearVisibleGameObjects();
             level.Value.display.active = false;
             break;
         }
     }
     levels       = null;
     gameDesc     = null;
     curLevelName = null;
 }
Beispiel #24
0
        protected override GameDescription[] ExecuteDeserialize(TextReader reader)
        {
            var sourceText = reader.ReadToEnd();

            var parser    = new Parser(new PgnGrammar());
            var parseTree = parser.Parse(sourceText);

            if (parseTree.Status != ParseTreeStatus.Parsed)
            {
                var parserMessage = parseTree.ParserMessages.First();
                var errorLocation = parserMessage.Location;

                throw new ChessPlatformException(
                          $@"Invalid PGN. Error at line {errorLocation.Line + 1}, column {errorLocation.Column + 1}: {
                        parserMessage.Message}");
            }

            var databaseNode = (parseTree.Root.EnsureNotNull().AstNode as DatabaseAstNode).EnsureNotNull();
            var games        = databaseNode.Games.EnsureNotNull();

            var resultList = new List <GameDescription>(games.Length);

            foreach (var game in games)
            {
                var fen          = game.TagSection.GetTagValue(TagNames.Fen);
                var initialBoard = fen is null ? new GameBoard() : new GameBoard(fen, true);

                var moves        = new List <GameMove>(game.MovetextSection.ElementSequence.Elements.Length);
                var currentBoard = initialBoard;
                foreach (var element in game.MovetextSection.ElementSequence.Elements)
                {
                    if (!element.ElementType.HasValue || element.ElementType.Value != ElementType.SanMove)
                    {
                        continue;
                    }

                    var sanMoveText = element.SanMove.EnsureNotNull().Text.EnsureNotNull();
                    var move        = currentBoard.ParseSanMove(sanMoveText);
                    moves.Add(move);
                    currentBoard = currentBoard.MakeMove(move);
                }

                var gameDescription = new GameDescription(initialBoard, moves);
                resultList.Add(gameDescription);
            }

            return(resultList.ToArray());
        }
        protected override GameDescription[] ExecuteDeserialize(TextReader reader)
        {
            var gameDescriptions = new List <GameDescription>();

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                var fen             = line.Trim();
                var gameBoard       = new GameBoard(fen);
                var gameDescription = new GameDescription(gameBoard);
                gameDescriptions.Add(gameDescription);
            }

            return(gameDescriptions.ToArray());
        }
Beispiel #26
0
 private void ShapeClick(object sender, EventArgs e)
 {
     if (controlVariable == GameDescription.PvsCMode)
     {
         OvalShapeExtended s = (OvalShapeExtended)sender;
         if (shapeLimit < 3)
         {
             if (controlMove == GameDescription.AddPawnPlayerOne)
             {
                 if (playerOne.spacingPawns(s.shapeId, computerPlayer.listOfPawns, listOfOvalShapes, (Image)Properties.Resources.OrangePawn))
                 {
                     controlMove = GameDescription.AddPawnComputer;
                     computerPlayer.addPawn(playerOne.listOfPawns, listOfOvalShapes, (Image)Properties.Resources.GreenPawn);
                     if (computerPlayer.win)
                     {
                         controlVariable = GameDescription.WinComputer;
                     }
                     shapeLimit++;
                     controlMove = GameDescription.AddPawnPlayerOne;
                     if (shapeLimit == 3)
                     {
                         controlMove = GameDescription.MovePlayerOne;
                     }
                 }
             }
         }
         else
         {
             if (controlMove == GameDescription.MovePlayerOne)
             {
                 playerOne.MovePawn(s.shapeId, computerPlayer.listOfPawns, listOfOvalShapes, (Image)Properties.Resources.OrangePawn);
                 if (playerOne.playerWin)
                 {
                     controlVariable = GameDescription.WinPlayerOne;
                 }
                 if (playerOne.doMove)
                 {
                     computerPlayer.MovePawn(playerOne.listOfPawns, listOfOvalShapes, (Image)Properties.Resources.GreenPawn, Properties.Resources.BlackCircle);
                     if (computerPlayer.win)
                     {
                         controlVariable = GameDescription.WinComputer;
                     }
                 }
             }
         }
     }
 }
Beispiel #27
0
        public GameSession(GameDescription gameDescription)
        {
            #region инициализация объектов

            WindVane             = new WindVane(true);
            GameLevel            = new GameLevel(Constants.LevelWidth, Constants.LevelHeigh);
            LocalGameDescription = gameDescription;
            StaticObjects        = InitializeBorders();
            _ships              = InitializeShips();
            _bullets            = new List <IBullet>();
            _updateObjectsTimer = new Timer(UpdateObjects, null, 1000, 25);
            _gameTimer          = new System.Timers.Timer();

            #endregion

            Start();
        }
Beispiel #28
0
    void drawNewGameScreen()
    {
        if (inTransition(MainMenu.MainMenuScreens.NewGameScreen, newGameScreenButtonInitialPos, newGameScreenButtonDestinyPos, ref newGameScreenButtonsCurrentPos))
        {
            newGameScreen.transform.position = new Vector3(newGameScreenButtonsCurrentPos.x, newGameScreenButtonsCurrentPos.y, newGameScreen.transform.position.z);

            for (int i = 0; i < 3; i++)
            {
                if (saveGameDescription[i].empty)
                {
                    newGameEmptyTextMeshes[i].gameObject.active       = true;
                    newGameCorruptTextMeshes[i].gameObject.active     = false;
                    newGameDescriptionTextMeshes[i].gameObject.active = false;
                    newGameDeleteslotButtons[i].gameObject.active     = false;
                }
                else if (saveGameDescription[i].corrupt)
                {
                    newGameEmptyTextMeshes[i].gameObject.active       = false;
                    newGameCorruptTextMeshes[i].gameObject.active     = true;
                    newGameDescriptionTextMeshes[i].gameObject.active = false;
                    newGameDeleteslotButtons[i].gameObject.active     = true;
                }
                else
                {
                    newGameEmptyTextMeshes[i].gameObject.active       = false;
                    newGameCorruptTextMeshes[i].gameObject.active     = false;
                    newGameDescriptionTextMeshes[i].gameObject.active = true;
                    newGameDeleteslotButtons[i].gameObject.active     = true;

                    GameDescription desc = saveGameDescription[i];

                    string text = desc.town + "\nLVL: " + desc.level + "  EXP: " + desc.experience;
                    newGameDescriptionTextMeshes[i].text     = text;
                    newGameDescriptionTextMeshes[i].maxChars = text.Length;
                    newGameDescriptionTextMeshes[i].Commit();
                }
            }
        }
        else
        {
            newGameScreen.transform.position = new Vector3(newGameScreenButtonDestinyPos.x, newGameScreenButtonDestinyPos.y, newGameScreen.transform.position.z);
        }
    }
Beispiel #29
0
        public GameDesc(GameDescription gameDescription)
        {
            Id          = gameDescription.Id;
            Name        = gameDescription.Name;
            State       = gameDescription.StateDerscription;
            HasPassword = gameDescription.HasPassword;
            TurnState   = gameDescription.TurnDescription;

            WhiteUsername      = gameDescription.WhitePlayer?.Name;
            WhiteRating        = gameDescription.WhitePlayer?.TotalScore;
            WhiteRatingForWin  = gameDescription.WhitePlayer?.RatingForWin;
            WhiteRatingForLose = gameDescription.WhitePlayer?.RatingForLose;
            WhiteRatingForDraw = gameDescription.WhitePlayer?.RatingForDraw;

            BlackUsername      = gameDescription.BlackPlayer?.Name;
            BlackRating        = gameDescription.BlackPlayer?.TotalScore;
            BlackRatingForWin  = gameDescription.BlackPlayer?.RatingForWin;
            BlackRatingForLose = gameDescription.BlackPlayer?.RatingForLose;
            BlackRatingForDraw = gameDescription.BlackPlayer?.RatingForDraw;
        }
Beispiel #30
0
        public SolverInfo(GameDescription description, bool verbose)
        {
            this.description = description;
            this.verbose     = verbose;

            tiles = new SolverTile[description.width, description.height];

            // populate the grid with solver tiles showing what we know so far ... which is nothing
            for (int x = 0; x < description.width; x++)
            {
                for (int y = 0; y < description.height; y++)
                {
                    tiles[x, y] = new SolverTile(key, x, y);
                }
            }

            tilesLeft = description.height * description.width;

            knownMines = new HashSet <SolverTile>(description.mines);
        }