Exemplo n.º 1
0
        public int RemoveKuaFuFuBenRoleData(int roleId, GameElementWarRoleCountChanged handler)
        {
            bool changed = false;
            int  result;

            lock (this)
            {
                KuaFuFuBenRoleData kuaFuFuBenRoleData;
                if (this.RoleDict.TryGetValue(roleId, out kuaFuFuBenRoleData))
                {
                    this.RoleDict.Remove(roleId);
                    changed = true;
                    this.RoleCount--;
                    this.TeamCombatSum -= (long)kuaFuFuBenRoleData.ZhanDouLi;
                    this.TeamCombatSum  = Math.Max(this.TeamCombatSum, 0L);
                }
                int roleCount = this.RoleDict.Count;
                if (changed && null != handler)
                {
                    handler(this, roleCount);
                }
                result = roleCount;
            }
            return(result);
        }
Exemplo n.º 2
0
        public int RemoveKuaFuFuBenRoleData(int roleId, GameElementWarRoleCountChanged handler)
        {
            int  roleCount;
            bool changed = false;

            lock (this)
            {
                KuaFuFuBenRoleData kuaFuFuBenRoleData;
                if (RoleDict.TryGetValue(roleId, out kuaFuFuBenRoleData))
                {
                    RoleDict.Remove(roleId);
                    changed = true;
                    RoleCount--;
                    TeamCombatSum -= kuaFuFuBenRoleData.ZhanDouLi;
                    TeamCombatSum  = Math.Max(TeamCombatSum, 0);
                }

                roleCount = RoleDict.Count;

                if (changed && null != handler)
                {
                    handler(this, roleCount);
                }

                return(roleCount);
            }
        }
Exemplo n.º 3
0
        public int AddKuaFuFuBenRoleData(KuaFuFuBenRoleData kuaFuFuBenRoleData, int maxRoleCount, GameElementWarRoleCountChanged handler)
        {
            int roleCount = -1;

            lock (this)
            {
                if (this.RoleDict.Count < maxRoleCount && !this.RoleDict.ContainsKey(kuaFuFuBenRoleData.RoleId))
                {
                    this.RoleCount++;
                    this.TeamCombatSum += (long)kuaFuFuBenRoleData.ZhanDouLi;
                    this.RoleDict[kuaFuFuBenRoleData.RoleId] = kuaFuFuBenRoleData;
                    roleCount = this.RoleDict.Count;
                    if (null != handler)
                    {
                        handler(this, roleCount);
                    }
                    return(roleCount);
                }
            }
            return(roleCount);
        }