Esempio n. 1
0
    public static void Init()
    {
        if (isInit == true)
        {
            return;
        }
        isInit = true;

        var texture1 = PngLoader.LoadPNG("Customize/Frame/StrikerFrame.png");

        StrikerFrame = Sprite.Create(texture1, new Rect(0, 0, texture1.width, texture1.height), new Vector2(0.5f, 0.5f));

        var texture2 = PngLoader.LoadPNG("Customize/Frame/AbilityStrikerFrame.png");

        AbilityStrikerFrame = Sprite.Create(texture2, new Rect(0, 0, texture2.width, texture2.height), new Vector2(0.5f, 0.5f));

        var texture3 = PngLoader.LoadPNG("Customize/Frame/SupportFrame.png");

        SupportFrame = Sprite.Create(texture3, new Rect(0, 0, texture3.width, texture3.height), new Vector2(0.5f, 0.5f));

        var texture4 = PngLoader.LoadPNG("Customize/Frame/EventFrame.png");

        EventFrame = Sprite.Create(texture4, new Rect(0, 0, texture4.width, texture4.height), new Vector2(0.5f, 0.5f));

        var texture5 = PngLoader.LoadPNG("Customize/Frame/JOKERFrame.png");

        JOKERFrame = Sprite.Create(texture5, new Rect(0, 0, texture5.width, texture5.height), new Vector2(0.5f, 0.5f));
    }
Esempio n. 2
0
    static void LoadCards()
    {
        // フォルダー列挙
        var directory = System.IO.Directory.GetParent(Application.dataPath).ToString() + "/CardDatas";

        string[] subFolders = oulFile.EnumDirectory(directory);

        // 曲の分の配列確保
        //cardDatas = new CardData[subFolders.Length];
        cardDatas           = new Queue <CardData>();
        createOnlyCardDatas = new Queue <CardData>();

        int deckCardNo   = 0;
        int createCardNo = 0;

        for (int i = 0; i < subFolders.Length; i++)
        {
            var cardData = new CardData();

            var folderName = subFolders[i];

            // フォルダー名=保存
            //m_aCardDatas[i].folderName = folderName;

            var path = directory + "/" + folderName;

            // テキスト情報読み込み
            {
                //Debug.Log(path + "/info.txt");

                //oulFile.OutPutLog(Application.dataPath + "/log.txt", "テキストオープン\r\n");

                //oulFile.OutPutLog(path + "/log.txt", "キテルグマ");

                var loader = new TextLoader();
                loader.LoadText(path + "/info.txt");

                //oulFile.OutPutLog(Application.dataPath + "/log.txt", "テキストロード開始\r\n");

                // 読み飛ばし用
                string skip;

                // 生成専用かどうか分岐
                skip = loader.ReadString();
                Debug.Assert(skip == "[CREATE_ONLY]", "生成専用テキストがない");
                skip = loader.ReadString();
                if (skip == "ON")
                {
                    cardData.id = createCardNo++;
                    createOnlyCardDatas.Enqueue(cardData);
                }
                else
                {
                    cardData.id = deckCardNo++;
                    cardDatas.Enqueue(cardData);
                }

                // カードタイプ(ファイターor効果ファイターorイベント)
                skip = loader.ReadString();
                Debug.Assert(skip == "[TYPE]", "カードID" + i + "のテキストずれてるクマ");
                var cardType = (CardType)loader.ReadInt();
                switch (cardType)
                {
                case CardType.Fighter:
                    cardData.fighterCard = new FighterCard();
                    break;

                case CardType.AbilityFighter:
                    cardData.abilityFighterCard = new AbilityFighterCard();
                    break;

                case CardType.Joker:
                    cardData.jokerCard = new JokerCard();
                    break;

                case CardType.Support:
                    cardData.supportCard = new SupportCard();
                    break;

                case CardType.Connect:
                    cardData.connectCard = new ConnectCard();
                    break;

                case CardType.Intercept:
                    cardData.interceptCard = new InterceptCard();
                    break;

                default:
                    ExceptionMessage.MessageBox("text error.", "card type error." + folderName);
                    break;
                }

                cardData.cardType = cardType;

                // カード名
                skip = loader.ReadString();
                Debug.Assert(skip == "[NAME]", "カードID" + i + "のテキストずれてるクマ");
                cardData.cardName = loader.ReadString();

                // レア度
                skip = loader.ReadString();
                Debug.Assert(skip == "[RARE]", "カードID" + i + "のテキストずれてるクマ");
                cardData.rarelity = (Rarelity)loader.ReadInt();

                // 効果テキスト
                skip = loader.ReadString();
                Debug.Assert(skip == "[A_TEXT]", "カードID" + i + "のテキストずれてるクマ");
                while (true)
                {
                    var str = loader.ReadLine();
                    if (str == "")
                    {
                        continue;
                    }
                    if (str == "[F_TEXT]")
                    {
                        break;
                    }

                    cardData.abilityText += str + "\r\n";
                }

                // フレーバーテキスト
                skip = loader.ReadString();
                while (true)
                {
                    var str = loader.ReadLine();
                    if (str == "")
                    {
                        continue;
                    }
                    if (str.ToCharArray()[0] == '[')
                    {
                        break;
                    }

                    cardData.flavorText += str + "\r\n";
                }

                // パワー
                //skip = loader.ReadString();
                cardData.power = loader.ReadInt();

                // タイプによって分岐
                switch (cardType)
                {
                case CardType.Fighter:
                {
                    // 種族
                    skip = loader.ReadLine();
                    // 種族の個数
                    int numSyuzoku = loader.ReadInt();
                    cardData.fighterCard.syuzokus = new Syuzoku[numSyuzoku];
                    // 個数に応じて読み込み
                    for (int j = 0; j < numSyuzoku; j++)
                    {
                        cardData.fighterCard.syuzokus[j] = (Syuzoku)loader.ReadInt();
                    }
                }
                break;

                case CardType.AbilityFighter:
                {
                    var abilityFighterCard = cardData.abilityFighterCard;

                    // 種族
                    skip = loader.ReadLine();
                    // 種族の個数
                    int numSyuzoku = loader.ReadInt();
                    abilityFighterCard.syuzokus = new Syuzoku[numSyuzoku];
                    // 個数に応じて読み込み
                    for (int j = 0; j < numSyuzoku; j++)
                    {
                        abilityFighterCard.syuzokus[j] = (Syuzoku)loader.ReadInt();
                    }

                    // 効果読み込み
                    skip = loader.ReadString();
                    var numAbility = loader.ReadInt();
                    abilityFighterCard.abilityDatas = new CardAbilityData[numAbility];
                    for (int j = 0; j < numAbility; j++)
                    {
                        abilityFighterCard.abilityDatas[j] = new CardAbilityData();
                        LoadAbility(loader, out abilityFighterCard.abilityDatas[j]);
                    }
                }
                break;

                case CardType.Joker:
                    // 効果
                {
                    var jokerCard = cardData.GetJokerCard();

                    // [NEW] 今は種族考慮せず
                    //// 種族
                    //skip = loader.ReadLine();
                    //// 種族の個数
                    //int numSyuzoku = loader.ReadInt();
                    //jokerCard.syuzokus = new Syuzoku[numSyuzoku];
                    //// 個数に応じて読み込み
                    //for (int j = 0; j < numSyuzoku; j++)
                    //    abilityFighterCard.syuzokus[j] = (Syuzoku)loader.ReadInt();


                    // 効果
                    var numAbility = loader.ReadInt();
                    jokerCard.abilityDatas = new CardAbilityData[numAbility];
                    for (int j = 0; j < numAbility; j++)
                    {
                        jokerCard.abilityDatas[j] = new CardAbilityData();
                        LoadAbility(loader, out jokerCard.abilityDatas[j]);
                    }
                }
                break;

                case CardType.Support:
                case CardType.Connect:
                case CardType.Intercept:
                {
                    var eventCard = cardData.GetEventCard();

                    // 効果
                    var numAbility = loader.ReadInt();
                    eventCard.abilityDatas = new CardAbilityData[numAbility];
                    for (int j = 0; j < numAbility; j++)
                    {
                        eventCard.abilityDatas[j] = new CardAbilityData();
                        LoadAbility(loader, out eventCard.abilityDatas[j]);
                    }
                }
                break;
                }
            }

            // キャラ画像
            var texture = PngLoader.LoadPNG(path + "/image.png");
            if (texture)
            {
                cardData.image = /*texture;*/ Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
            }

            //Debug.Log("カードID" + i + "番の読み込みが完了");
        }
    }