Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (LoadConfigManager.allConfigLoaded)
     {
         LoadConfigManager.allConfigLoaded = false;
         ConfigDataManager.GetInstance().TestPrint();
     }
 }
Beispiel #2
0
    public Ball OnInit(BallType t)
    {
        this.Type = t;
        RandomPos();

        Pre          = null;
        Next         = null;
        IsNextDelete = false;

        this._ballData = ConfigDataManager.GetInstance().GetBallDataByType((int)t);
        this._ball.SetActive(true);
        return(this);
    }
Beispiel #3
0
 public static int RandomBallTypeIndex()
 {
     return(Random.Range(0, ConfigDataManager.GetInstance().GetBallDataKindNumber()));
 }
Beispiel #4
0
    private static void ParseFile(Byte[] bytes, string filePath)
    {
        Assembly asm = Assembly.GetExecutingAssembly();

        ByteArray ba         = new ByteArray(bytes);
        int       sheetCount = ba.readInt();

        for (int i = 0; i != sheetCount; ++i)
        {
            string className = ba.readUTF();
            int    rowCount  = ba.readInt();
            int    colCount  = ba.readInt();

            // 2. read values
            for (int r = 0; r != rowCount; ++r)
            {
                object obj = asm.CreateInstance(className);
                if (obj == null)
                {
                    Debug.Log("Load data error: " + className + " in " + filePath + " has no data.");
                    break;
                }
                FieldInfo[] fis = obj.GetType().GetFields();

                int id = 0;
                for (int c = 0; c != colCount; ++c)
                {
                    //string val = ba.readUTF();
                    if (c < fis.Length)
                    {
                        if (fis[c].FieldType == typeof(int))
                        {
                            int nVal = ba.readInt();
                            if (c == 0)
                            {
                                id = nVal;
                            }
                            fis[c].SetValue(obj, nVal);
                        }
                        else if (fis[c].FieldType == typeof(string))
                        {
                            fis[c].SetValue(obj, ba.readUTF());
                        }
                        else if (fis[c].FieldType == typeof(float))
                        {
                            string val = ba.readUTF();
                            fis[c].SetValue(obj, float.Parse(val));
                        }
                        else if (fis[c].FieldType == typeof(double))
                        {
                            string val = ba.readUTF();
                            fis[c].SetValue(obj, double.Parse(val));
                        }
                        else if (fis[c].FieldType == typeof(long))
                        {
                            fis[c].SetValue(obj, ba.readLong());
                        }
                    }
                }
                try
                {
                    ConfigDataManager.GetInstance().AddToDictionary(id, obj, rowCount);
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(ex.ToString() + " @Id=" + id + " of " + className + " in " + filePath);
                }
            }
        }
    }