Exemplo n.º 1
0
        public bool FindAnimalProp(int animalType, int animalDetailType, out AnimalProp animalProp)
        {
            this.animalType       = animalType;
            this.animalDetailType = animalDetailType;

            animalProp = null;
            if (animalProps.Count <= 0)
            {
                return(false);
            }

            //if (animalProps.Count < 100)
            {
                animalProp = animalProps.Find(IsAnimalPropEquals);
                return(animalProp != null);
            }

            this.animalProp.animalType       = this.animalType;
            this.animalProp.animalDetailType = this.animalDetailType;

            int idx = animalProps.BinarySearch(this.animalProp);

            if (idx >= 0)
            {
                animalProp = animalProps[idx];
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 动物升级
        /// </summary>
        /// <param name="animalID"></param>
        /// <param name="lv"></param>
        public void AnimalLvUp(int animalID, int lv)
        {
            AnimalProp animalProp = GetAnimalProp(animalID);

            if (animalProp == null)
            {
                string e = string.Format("AnimalLvUp 没有获取到动物属性 animalid = {0}", animalID);
                throw new System.Exception(e);
            }
            animalProp.lv += lv;
            sumLv         += lv;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获得动物属性
        /// </summary>
        /// <param name="animalID"></param>
        /// <returns></returns>
        public AnimalProp GetAnimalProp(int animalID)
        {
            if (!FindAnimalID(animalID))
            {
                //string e = string.Format("动物id在用户数据中不存在 {0}", animalID);
                //throw new System.Exception(e);
                return(null);
            }

            var        cell       = Config.animalupConfig.getInstace().getCell(animalID);
            AnimalProp animalProp = null;

            if (!FindAnimalProp(cell.bigtype, cell.smalltype, out animalProp))
            {
                string e = string.Format("动物类型属性在用户数据中不存在 动物id{0}, " +
                                         "大类型 {1} ,小类型{2}",
                                         animalID, cell.bigtype, cell.smalltype);
                throw new System.Exception(e);
            }

            return(animalProp);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 新增加动物
        /// </summary>
        /// <param name="animalID"></param>
        public void AddAnimal(int animalID, bool isFindProp)
        {
            var cell = Config.animalupConfig.getInstace().getCell(animalID);

            if (cell == null)
            {
                string e = string.Format("动物表animalup不存在 {0}", animalID);
                throw new System.Exception(e);
            }

            if (FindAnimalID(animalID))
            {
                string e = string.Format("动物id重复添加 {0}", animalID);
                throw new System.Exception(e);
            }

            animalIDs.Add(animalID);
            //animalIDs.Sort();

            //查询animalProps中是否存在,不存在增加1条等级为1的记录
            if (!isFindProp)
            {
                return;
            }
            AnimalProp animalProp = null;

            if (!FindAnimalProp(cell.bigtype, cell.smalltype, out animalProp))
            {
                animalProp                  = new AnimalProp();
                animalProp.animalType       = cell.bigtype;
                animalProp.animalDetailType = cell.smalltype;
                animalProp.lv               = 1;
                ++sumLv;
                animalProps.Add(animalProp);
                //animalProps.Sort();
            }
        }
Exemplo n.º 5
0
 bool IsAnimalPropEquals(AnimalProp animalProp)
 {
     return((animalProp.animalType == this.animalType) &&
            (animalProp.animalDetailType == this.animalDetailType));
 }