Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public static FightProperties Clamp(FightProperties value, FightProperties max)
        {
            FightProperties fight = new FightProperties
            {
                hp  = Mathf.Clamp(value.hp, 1, SettingVars.maxHp),
                mp  = Mathf.Clamp(value.mp, 0, SettingVars.maxMp),
                str = Mathf.Clamp(value.str, 0, max.str),
                mag = Mathf.Clamp(value.mag, 0, max.mag),
                skl = Mathf.Clamp(value.skl, 0, max.skl),
                spd = Mathf.Clamp(value.spd, 0, max.spd),
                def = Mathf.Clamp(value.def, 0, max.def),
                mdf = Mathf.Clamp(value.mdf, 0, max.mdf)
            };

            return(fight);
        }
Exemplo n.º 4
0
        public static FightProperties operator *(FightProperties lhs, int rhs)
        {
            FightProperties fight = new FightProperties
            {
                hp  = lhs.hp * rhs,
                mp  = lhs.mp * rhs,
                str = lhs.str * rhs,
                mag = lhs.mag * rhs,
                skl = lhs.skl * rhs,
                spd = lhs.spd * rhs,
                def = lhs.def * rhs,
                mdf = lhs.mdf * rhs,
            };

            return(fight);
        }
Exemplo n.º 5
0
        public static FightProperties operator +(FightProperties lhs, int rhs)
        {
            FightProperties fight = new FightProperties
            {
                hp  = lhs.hp + rhs,
                mp  = lhs.mp + rhs,
                str = lhs.str + rhs,
                mag = lhs.mag + rhs,
                skl = lhs.skl + rhs,
                spd = lhs.spd + rhs,
                def = lhs.def + rhs,
                mdf = lhs.mdf + rhs,
            };

            return(fight);
        }
Exemplo n.º 6
0
        public static FightProperties operator /(FightProperties lhs, int rhs)
        {
            if (rhs == 0)
            {
                return(lhs);
            }

            FightProperties fight = new FightProperties
            {
                hp  = lhs.hp / rhs,
                mp  = lhs.mp / rhs,
                str = lhs.str / rhs,
                mag = lhs.mag / rhs,
                skl = lhs.skl / rhs,
                spd = lhs.spd / rhs,
                def = lhs.def / rhs,
                mdf = lhs.mdf / rhs,
            };

            return(fight);
        }