Exemplo n.º 1
0
    public void OnButtonOK()
    {
        if (string.IsNullOrEmpty(inputUserName.text))
        {
            return;
        }

        inputBoard.SetActive(false);
        rankBoard.SetActive(true);

        Record myRecord = new Record
        {
            name  = inputUserName.text,
            score = GameController.Instance.GetScore()
        };

        ScoreData scoreData = dataManager.LoadScore();

        scoreData.recordList.Add(myRecord);
        scoreData.recordList.Sort(CompareRecord);
        dataManager.SaveScore(scoreData);

        for (int i = 0; i < scoreData.recordList.Count; i++)
        {
            RecordCell cell       = Instantiate <RecordCell>(recordCell, scrollContent);
            Record     recordData = scoreData.recordList[i];

            int    rank   = i + 1;
            string userId = recordData.name;
            int    score  = recordData.score;
            bool   me     = (recordData == myRecord);
            cell.Init(userId, rank, score, me);
        }
    }
Exemplo n.º 2
0
        public void AddRecord(string name, string md5, int fileSize, long buildTime)
        {
            OpenRecordFileStream(true);

            if (m_RecordFileStream == null)
            {
                return;
            }

            try
            {
                string writeData      = string.Format("{0}:{1}:{2}:{3}\n", name, md5, fileSize, buildTime);
                byte[] writeDataArray = UTF8Encoding.UTF8.GetBytes(writeData);
                m_RecordFileStream.Write(writeDataArray, 0, writeDataArray.Length);

                m_RecordFileStream.Flush();

                RecordCell cell = new RecordCell();
                cell.SetData(name, md5, fileSize, buildTime);
                m_UpdateRecordList.Add(cell);
            }
            catch (Exception e)
            {
                Log.e(e);
            }
        }
Exemplo n.º 3
0
        public int GetInt(string key, int defaultValue = 0)
        {
            RecordCell cell = null;

            if (!m_DataMap.TryGetValue(key, out cell))
            {
                return(defaultValue);
            }
            return(cell.intValue);
        }
Exemplo n.º 4
0
        public float GetFloat(string key, float defaultValue = 0)
        {
            RecordCell cell = null;

            if (!m_DataMap.TryGetValue(key, out cell))
            {
                return(defaultValue);
            }
            return(cell.floatValue);
        }
Exemplo n.º 5
0
        public string GetString(string key, string defaultValue = "")
        {
            RecordCell cell = null;

            if (!m_DataMap.TryGetValue(key, out cell))
            {
                return(defaultValue);
            }
            return(cell.stringValue);
        }
Exemplo n.º 6
0
        public bool GetBool(string key, bool defaultValue = false)
        {
            RecordCell cell = null;

            if (!m_DataMap.TryGetValue(key, out cell))
            {
                return(defaultValue);
            }
            return(cell.boolValue);
        }
Exemplo n.º 7
0
        public void Load()
        {
            OpenRecordFileStream(false);

            if (m_RecordFileStream == null)
            {
                return;
            }

            try
            {
                m_UpdateRecordList.Clear();

                if (m_RecordFileStream.Length <= 0)
                {
                    return;
                }

                byte[] byteData = new byte[m_RecordFileStream.Length];

                m_RecordFileStream.Read(byteData, 0, byteData.Length);

                string context = UTF8Encoding.UTF8.GetString(byteData);
                if (string.IsNullOrEmpty(context))
                {
                    return;
                }

                string[] msgs = context.Split('\n');

                for (int i = 0; i < msgs.Length; ++i)
                {
                    if (string.IsNullOrEmpty(msgs[i]))
                    {
                        continue;
                    }

                    string[] param = msgs[i].Split(':');

                    if (param == null || param.Length < 4)
                    {
                        continue;
                    }

                    RecordCell cell = new RecordCell();
                    cell.SetData(param);
                    m_UpdateRecordList.Add(cell);
                }
            }
            catch (Exception e)
            {
                Log.e(e);
            }
        }
    //Will be called by the TableView when a cell needs to be created for display
    public TableViewCell GetCellForRowInTableView(TableView tableView, int row)
    {
        RecordCell cell = tableView.GetReusableCell(m_cellPrefab.reuseIdentifier) as RecordCell;

        if (cell == null)
        {
            cell = Instantiate(m_cellPrefab);
        }

        cell.Load(records[row]);
        return(cell);
    }
Exemplo n.º 9
0
        public void AddInt(string key, int offset)
        {
            RecordCell cell = null;

            if (!m_DataMap.TryGetValue(key, out cell))
            {
                cell     = new RecordCell();
                cell.key = key;
                m_DataMap.Add(key, cell);
            }

            cell.intValue += offset;
            m_IsMapDirty   = true;
        }
Exemplo n.º 10
0
        public void SetFloat(string key, float value)
        {
            RecordCell cell = null;

            if (!m_DataMap.TryGetValue(key, out cell))
            {
                cell     = new RecordCell();
                cell.key = key;
                m_DataMap.Add(key, cell);
            }

            cell.floatValue = value;
            m_IsMapDirty    = true;
        }
Exemplo n.º 11
0
        public void SetInt(string key, int value)
        {
            RecordCell cell = null;

            if (!m_RecordMap.TryGetValue(key, out cell))
            {
                cell     = new RecordCell();
                cell.key = key;
                m_RecordMap.Add(key, cell);
            }

            cell.intValue = value;
            m_IsDataDirty = true;
        }
Exemplo n.º 12
0
        private void SetSerizlizeData(string data)
        {
            string[] values = data.Split('|');

            for (int i = 0; i < values.Length; ++i)
            {
                if (string.IsNullOrEmpty(values[i]))
                {
                    continue;
                }

                RecordCell cell = new RecordCell();
                cell.SetData(values[i]);

                m_DataMap.Add(cell.key, cell);
            }
        }
Exemplo n.º 13
0
    // 添加item
    void AddItem(ChallengeInfo info)
    {
        if (info == null)
        {
            return;
        }
        UnityEngine.GameObject item = CrossObjectHelper.TryCastObject <UnityEngine.GameObject>(ArkCrossEngine.ResourceSystem.GetSharedResource("UI/PartnerPvp/RecordCell"));
        item = NGUITools.AddChild(grid.gameObject, item);
        if (item != null)
        {
            RecordCell cell = item.GetComponent <RecordCell>();
            if (cell != null)
            {
                cell.InitItemInfo(info);
            }
        }

        recordDic.Add(item, info);
    }
Exemplo n.º 14
0
        public void ModifyAssetDataTable(AssetDataTable table)
        {
            RecordCell       cell    = null;
            AssetDataPackage package = null;

            for (int i = 0; i < m_UpdateRecordList.Count; ++i)
            {
                cell = m_UpdateRecordList[i];
                ABUnit unit = table.GetABUnit(cell.name);
                if (unit == null)
                {
                    table.AddAssetBundleName(cell.name, null, cell.md5, 1, cell.buildTime, out package);
                    continue;
                }
                else
                {
                    unit.buildTime = cell.buildTime;
                    unit.md5       = cell.md5;
                    unit.fileSize  = cell.fileSize;
                }
            }
        }