Esempio n. 1
0
        public MonsterSelfAdaption Get(int id)
        {
            if (id <= 0)
            {
                return(null);
            }
            MonsterSelfAdaption monster_self_adaption = null;

            if (_monster_self_adaptionMap.TryGetValue(id, out monster_self_adaption))
            {
                _refMap[monster_self_adaption.Id] = GetCurrentTimeTick();
                ReleaseData(false);
                return(monster_self_adaption);
            }

            monster_self_adaption = DbClassLoader.Instance.QueryData <MonsterSelfAdaption>(ConfigDataBase.Instance.DbAccessorFactory, id);
            if (monster_self_adaption == null)
            {
#if UNITY_EDITOR
                Debug.LogWarning("Invalid `id` value in table `monster_self_adaption` : " + id);
#endif
                return(null);
            }

            _monster_self_adaptionMap.Add(id, monster_self_adaption);
            if (_refMap.ContainsKey(monster_self_adaption.Id) == false)
            {
                _refMap.Add(monster_self_adaption.Id, GetCurrentTimeTick());
            }

            ReleaseData(false);
            return(monster_self_adaption);
        }
Esempio n. 2
0
        public void MemoryUpdate(int key, MonsterSelfAdaption monster_self_adaption)
        {
            MonsterSelfAdaptions.RemoveAll(n => n.Id == key);
            if (_monster_self_adaptionMap.ContainsKey(key))
            {
                _monster_self_adaptionMap.Remove(key);
                if (_refMap.ContainsKey(key))
                {
                    _refMap.Remove(key);
                }
            }

            if (monster_self_adaption != null)
            {
                MonsterSelfAdaptions.Add(monster_self_adaption);
                _monster_self_adaptionMap.Add(key, monster_self_adaption);
                _refMap.Add(key, DateTime.Now.Ticks);
            }
        }