public void LoadData_Technology(GameObject player)
        {
            TechnologyManager manager = player.GetComponent <TechnologyManager>();

            foreach (c2w_technology row in connection.Query <c2w_technology>("SELECT * FROM c2w_technology WHERE owner=?", player.name))
            {
                if (row.slot < manager.GetCapacity)
                {
                    if (String.IsNullOrWhiteSpace(row.name))
                    {
                        manager.AddEntry(row.slot, null, 0, 0, 0);
                    }
                    else if (TechnologyTemplate.dict.TryGetValue(row.name.GetDeterministicHashCode(), out TechnologyTemplate template))
                    {
                        manager.AddEntry(row.slot, template, row.state, row.timer, row.level);
                    }
                    else
                    {
                        Debug.LogWarning("Load: Skipped technology " + row.name + " for " + player.name + " as it was not found in Resources.");
                    }
                }
                else
                {
                    Debug.LogWarning("Skipped technology slot " + row.slot + " for " + player.name + " because it's bigger than size " + manager.GetCapacity);
                }
            }
        }
示例#2
0
        // -------------------------------------------------------------------------------
        protected override void ThrottledUpdate()
        {
            if (manager == null)
            {
                manager = localPlayer.GetComponent <TechnologyManager>();
            }

            for (int i = 0; i < contentGroup.childCount; i++)
            {
                GameObject.Destroy(contentGroup.GetChild(i).gameObject);
            }

            foreach (TechnologySyncStruct _entry in manager.GetEntries(true, SortOrder.None, category))
            {
                TechnologySyncStruct entry  = _entry;
                GameObject           prefab = null;

                if (displayType == DisplayType.Horizontal)
                {
                    prefab = horizontalSlotPrefab.gameObject;
                }
                else if (displayType == DisplayType.Vertical)
                {
                    prefab = verticalSlotPrefab.gameObject;
                }
                else if (displayType == DisplayType.Grid)
                {
                    prefab = gridSlotPrefab.gameObject;
                }

                GameObject go = GameObject.Instantiate(prefab);
                go.transform.SetParent(contentGroup, false);
                go.GetComponent <UIPlayerListTechnologySlot>().Init(localPlayer, ref entry);
            }
        }
        public void SaveData_Technology(GameObject player)
        {
            connection.Execute("DELETE FROM c2w_technology WHERE owner=?", player.name);

            TechnologyManager manager = player.GetComponent <TechnologyManager>();

            List <TechnologySyncStruct> list = manager.GetEntries(false);

            for (int i = 0; i < list.Count; i++)
            {
                TechnologySyncStruct entry = list[i];

                connection.InsertOrReplace(new c2w_technology {
                    owner = player.name,
                    slot  = entry.slot,
                    name  = entry.name,
                    level = entry.level,
                    state = entry.state,
                    timer = entry.timer
                });
            }
        }
        public void CreateDefaultData_Technology(GameObject player)
        {
            TechnologyManager manager = player.GetComponent <TechnologyManager>();

            manager.CreateDefaultData();
        }