Exemplo n.º 1
0
        /// <summary>
        /// Loads the game configuration from the specified path.
        /// </summary>
        /// <param name="path">The path to the game configuration.</param>
        public void LoadGameConfiguration(string path)
        {
            var gamePropertiesPath = path + "/game_properties.json";
            var gameProperties     = LoadJSONFile <GameProperties>(gamePropertiesPath);

            if (gameProperties != null)
            {
                properties = gameProperties;
            }

            var gameZonesPath = path + "/game_zones.json";
            var zones         = LoadJSONFile <List <GameZoneType> >(gameZonesPath);

            if (zones != null)
            {
                gameZones = zones;
            }
            if (gameZones.Count > 0)
            {
                GameZoneType.currentId = gameZones.Max(x => x.id) + 1;
            }

            var playerStatsPath = path + "/player_stats.json";
            var stats           = LoadJSONFile <List <DefinitionStat> >(playerStatsPath);

            if (stats != null)
            {
                playerStats = stats;
            }
            if (playerStats.Count > 0)
            {
                PlayerStat.currentId = playerStats.Max(x => x.id) + 1;
            }

            var cardTypesPath = path + "/card_types.json";
            var types         = LoadJSONFile <List <CardType> >(cardTypesPath);

            if (types != null)
            {
                cardTypes = types;
            }
            if (cardTypes.Count > 0)
            {
                CardType.currentId = cardTypes.Max(x => x.id) + 1;
            }
            var ids = new List <int>();

            foreach (var type in cardTypes)
            {
                if (type.stats.Count > 0)
                {
                    ids.Add(type.stats.Max(x => x.id));
                }
            }
            if (ids.Count > 0)
            {
                CardStat.currentId = ids.Max() + 1;
            }

            var keywordsPath = path + "/keywords.json";
            var keywords     = LoadJSONFile <List <Keyword> >(keywordsPath);

            if (keywords != null)
            {
                this.keywords = keywords;
            }
            if (this.keywords.Count > 0)
            {
                Keyword.currentId = this.keywords.Max(x => x.id) + 1;
            }

            var cardLibraryPath = Application.streamingAssetsPath + "/card_lib.json";
            var cardLibrary     = LoadJSONFile <List <CardSet> >(cardLibraryPath);

            if (cardLibrary != null)
            {
                cardSets = cardLibrary;
            }
            var max = -1;

            foreach (var set in cardSets)
            {
                var currentMax = set.cards.Max(x => x.id);
                if (currentMax > max)
                {
                    max = currentMax;
                }
            }
            Card.currentId = max + 1;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the game configuration from the specified path.
        /// </summary>
        /// <param name="path">The path to the game configuration.</param>
        public void LoadGameConfiguration(string path)
        {
            var gamePropertiesPath = path + "/game_properties.json";
            var gameProperties     = LoadJSONFile <GameProperties>(gamePropertiesPath);

            if (gameProperties != null)
            {
                properties = gameProperties;
            }

            var gameZonesPath = path + "/game_zones.json";
            var zones         = LoadJSONFile <List <GameZoneType> >(gameZonesPath);

            if (zones != null)
            {
                gameZones = zones;
            }
            if (gameZones.Count > 0)
            {
                GameZoneType.currentId = gameZones.Max(x => x.id) + 1;
            }

            var playerStatsPath = path + "/player_stats.json";
            var stats           = LoadJSONFile <List <DefinitionStat> >(playerStatsPath);

            if (stats != null)
            {
                playerStats = stats;
            }
            if (playerStats.Count > 0)
            {
                PlayerStat.currentId = playerStats.Max(x => x.id) + 1;
            }

            var cardTypesPath = path + "/card_types.json";
            var types         = LoadJSONFile <List <CardType> >(cardTypesPath);

            if (types != null)
            {
                cardTypes = types;
            }
            if (cardTypes.Count > 0)
            {
                CardType.currentId = cardTypes.Max(x => x.id) + 1;
            }
            var ids = new List <int>();

            foreach (var type in cardTypes)
            {
                if (type.stats.Count > 0)
                {
                    ids.Add(type.stats.Max(x => x.id));
                }
            }
            if (ids.Count > 0)
            {
                CardStat.currentId = ids.Max() + 1;
            }

            var keywordsPath = path + "/keywords.json";
            var keywords     = LoadJSONFile <List <Keyword> >(keywordsPath);

            if (keywords != null)
            {
                this.keywords = keywords;
            }
            if (this.keywords.Count > 0)
            {
                Keyword.currentId = this.keywords.Max(x => x.id) + 1;
            }

            var cardLibraryPath = path + "/card_library.json";

/*
 *          checkTeam=SelectTeamScene.GetTeamFlag();
 *          if(checkTeam!=null){
 *              if(checkTeam=="kouma"){
 *                 cardLibraryPath = path + "/kouma_card_library.json";
 *              }else if(checkTeam=="hakugyoku"){
 *                  cardLibraryPath = path + "/hakugyoku_card_library.json";
 *              }else if(checkTeam=="eien"){
 *                  cardLibraryPath = path + "/eien_card_library.json";
 *              }else{
 *
 *              }
 *
 *          }
 */

            var cardLibrary = LoadJSONFile <List <CardSet> >(cardLibraryPath);

            if (cardLibrary != null)
            {
                cardSets = cardLibrary;
            }
            var max = -1;

            foreach (var set in cardSets)
            {
                var currentMax = set.cards.Max(x => x.id);
                if (currentMax > max)
                {
                    max = currentMax;
                }
            }
            Card.currentId = max + 1;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the game configuration at runtime.
        /// </summary>
        public void LoadGameConfigurationAtRuntime()
        {
            var gamePropertiesJSON = Resources.Load <TextAsset>("game_properties");

            Assert.IsTrue(gamePropertiesJSON != null);
            var gameProperties = LoadJSONString <GameProperties>(gamePropertiesJSON.text);

            if (gameProperties != null)
            {
                properties = gameProperties;
            }

            var gameZonesJSON = Resources.Load <TextAsset>("game_zones");

            Assert.IsTrue(gameZonesJSON != null);
            var zones = LoadJSONString <List <GameZoneType> >(gameZonesJSON.text);

            if (zones != null)
            {
                gameZones = zones;
            }

            var playerStatsJSON = Resources.Load <TextAsset>("player_stats");

            Assert.IsTrue(playerStatsJSON != null);
            var stats = LoadJSONString <List <DefinitionStat> >(playerStatsJSON.text);

            if (stats != null)
            {
                playerStats = stats;
            }

            var cardTypesJSON = Resources.Load <TextAsset>("card_types");

            Assert.IsTrue(cardTypesJSON != null);
            var types = LoadJSONString <List <CardType> >(cardTypesJSON.text);

            if (types != null)
            {
                cardTypes = types;
            }

            var keywordsJSON = Resources.Load <TextAsset>("keywords");

            Assert.IsTrue(keywordsJSON != null);
            var keywords = LoadJSONString <List <Keyword> >(keywordsJSON.text);

            if (keywords != null)
            {
                this.keywords = keywords;
            }

            //var cardLibraryJSON = Resources.Load<TextAsset>("card_library");
            string cardLibraryJSON = File.ReadAllText(Application.streamingAssetsPath + "/card_lib.json");

            Assert.IsTrue(cardLibraryJSON != null);
            //var cardLibrary = LoadJSONString<List<CardSet>>(cardLibraryJSON.text);
            var cardLibrary = LoadJSONString <List <CardSet> >(cardLibraryJSON);

            if (cardLibrary != null)
            {
                cardSets = cardLibrary;
                foreach (var set in cardSets)
                {
                    foreach (var card in set.cards)
                    {
                        cards.Add(card);
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the game configuration at runtime.
        /// 実行時にゲームの設定を読み込みます。
        /// </summary>
        public void LoadGameConfigurationAtRuntime()
        {
            //全てのカードデータ、デッキに構築できるカード枚数、1ターンの時間、ターン開始時の行動、ターン終了時の行動を読み込む
            var gamePropertiesJSON = Resources.Load <TextAsset>("game_properties");

            Assert.IsTrue(gamePropertiesJSON != null);
            var gameProperties = LoadJSONString <GameProperties>(gamePropertiesJSON.text);

            if (gameProperties != null)
            {
                properties = gameProperties;
            }

            //デッキ、ハンド、ボード、墓地それぞれの最大値を設定する
            var gameZonesJSON = Resources.Load <TextAsset>("game_zones");

            Assert.IsTrue(gameZonesJSON != null);
            var zones = LoadJSONString <List <GameZoneType> >(gameZonesJSON.text);

            if (zones != null)
            {
                gameZones = zones;
            }

            //ライフとマナの最大値を設定する
            var playerStatsJSON = Resources.Load <TextAsset>("player_stats");

            Assert.IsTrue(playerStatsJSON != null);
            var stats = LoadJSONString <List <DefinitionStat> >(playerStatsJSON.text);

            if (stats != null)
            {
                playerStats = stats;
            }

            //ミニオンの属性、スタッツの扱い、ミニオンが死ぬ条件、スペルについてそれぞれ設定する
            var cardTypesJSON = Resources.Load <TextAsset>("card_types");

            Assert.IsTrue(cardTypesJSON != null);
            var types = LoadJSONString <List <CardType> >(cardTypesJSON.text);

            if (types != null)
            {
                cardTypes = types;
            }

            //keywordsの設定
            var keywordsJSON = Resources.Load <TextAsset>("keywords");

            Assert.IsTrue(keywordsJSON != null);
            var keywords = LoadJSONString <List <Keyword> >(keywordsJSON.text);

            if (keywords != null)
            {
                this.keywords = keywords;
            }


            //カード一覧の設定。
            ///各陣営分けはここで設定する?
            var cardLibraryJSON = Resources.Load <TextAsset>("card_library");


//            var koumaCardLibraryJSON = Resources.Load<TextAsset>("kouma_card_library");
//            var hakugyokuCardLibraryJSON = Resources.Load<TextAsset>("hakugyoku_card_library");
//            var eienCardLibraryJSON = Resources.Load<TextAsset>("eien_card_library");


            Assert.IsTrue(cardLibraryJSON != null);
            var cardLibrary = LoadJSONString <List <CardSet> >(cardLibraryJSON.text);

/*
 *          checkTeam=SelectTeamScene.GetTeamFlag();
 *          if(checkTeam!=null){
 *              if(checkTeam=="kouma"){
 *                 cardLibrary = LoadJSONString<List<CardSet>>(koumaCardLibraryJSON.text);
 *              }else if(checkTeam=="hakugyoku"){
 *                  cardLibrary = LoadJSONString<List<CardSet>>(hakugyokuCardLibraryJSON.text);
 *              }else if(checkTeam=="eien"){
 *                  cardLibrary = LoadJSONString<List<CardSet>>(eienCardLibraryJSON.text);
 *              }else{
 *
 *              }
 *          }
 *
 */


            if (cardLibrary != null)
            {
                cardSets = cardLibrary;
                foreach (var set in cardSets)
                {
                    foreach (var card in set.cards)
                    {
                        cards.Add(card);
                    }
                }
            }
        }