Example #1
0
        /// <summary>
        /// 创建独有角色数据
        /// </summary>
        /// <param name="characterId"></param>
        /// <returns></returns>
        private RoleData CreateUniqueRoleData(int characterId)
        {
            Character character = GetOrCreateCharacter(characterId);

            if (character == null)
            {
                return(null);
            }

            Class cls = GetOrCreateClass(character.info.classId);

            if (cls == null)
            {
                return(null);
            }

            RoleData self = new RoleData();

            self.characterId     = characterId;
            self.classId         = character.info.classId;
            self.level           = Mathf.Clamp(character.info.level, 0, SettingVars.maxLevel);
            self.exp             = 0;
            self.fightProperties = FightProperties.Clamp(
                character.info.fightProperties + cls.info.fightProperties,
                cls.info.maxFightProperties);
            self.hp  = self.fightProperties.hp;
            self.mp  = self.fightProperties.mp;
            self.luk = Mathf.Clamp(character.info.luk, 0, SettingVars.maxLuk);
            //self.money = character.info.money;
            self.movePoint = cls.info.movePoint;
            self.holding   = false;

            return(self);
        }
Example #2
0
        /// <summary>
        /// 获取或创建杂兵模板
        /// </summary>
        /// <param name="classId"></param>
        /// <returns></returns>
        public RoleData GetOrCreateFollowingTemplate(int classId)
        {
            Class cls = GetOrCreateClass(classId);

            if (cls == null || cls.info == null)
            {
                return(null);
            }

            ClassInfo info = cls.info;

            RoleData data;

            if (!m_FollowingTemplates.TryGetValue(info.id, out data))
            {
                data                 = new RoleData();
                data.classId         = info.id;
                data.level           = 1;
                data.exp             = 0;
                data.fightProperties = FightProperties.Clamp(
                    cls.info.fightProperties,
                    cls.info.maxFightProperties);
                data.hp  = data.fightProperties.hp;
                data.mp  = data.fightProperties.mp;
                data.luk = 0;
                //data.money = character.info.money;
                data.movePoint = cls.info.movePoint;
                data.holding   = false;

                // TODO 计算公式,计算npc出生数据
                m_FollowingTemplates.Add(data.classId, data);
            }

            return(data);
        }