コード例 #1
0
ファイル: SpriteDatabase.cs プロジェクト: scot140/SideProj
    //load information
    public bool Load(string _file)
    {
        if (0 == _file.Length)
        {
            return(false);
        }

        //create a reader and opne the file
        StreamReader ifs = new StreamReader(Application.dataPath + "/Resources/" + _file);

        //temporary string for reading values
        string line;

        string[] lineParse;
        char[]   delims = { '\n', '\r', '-', '\t' };

        //read the first line : ID
        line = ifs.ReadLine();
        //parse until EOF
        while (line != null)
        {
            //line data : ID
            lineParse = line.Split(delims);
            //confirm the size
            if (4 == lineParse.Length)
            {
                VisualInfo     visualData = new VisualInfo();
                CardIdentifier cardID     = new CardIdentifier(lineParse[0], lineParse[2], lineParse[1]);

                string spritePath   = SpriteFolderPath + cardID.FactionID + "/" + cardID.UniqueID;
                string animatorPath = AnimationControllerFolderPath + cardID.FactionID + "/" + cardID.UniqueID + "_0";

                //load visual information
                if (visualData.Load(spritePath, animatorPath))
                {
                    //add into database
                    spriteDatabase.AddEntry(cardID.ID, ref visualData);
                }
            }
            //read the next line
            line = ifs.ReadLine();
        }

        ifs.Close();

        return(true);
    }