Example #1
0
        private static void DoSync(Cake cake)
        {
            var pkt = new PktParamUpdate();

            pkt.id       = cake.id;
            pkt.iid      = cake.iid;
            pkt.cakeType = cake.cakeType;
            foreach (var p in cake.dParams)
            {
                if (!p.Value.bSyncToClient)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(p.Key))
                {
                    throw new Exception($"Empty paramname!");
                }
                if (p.Value.paramValue != null)
                {
                    pkt.lInfos.Add(new ParamInfo()
                    {
                        paramName = p.Key, paramValue = p.Value.paramValue.ToString()
                    });
                }
            }
            APlayerManager.SendToClient(cake.id, pkt);
        }
Example #2
0
        protected override void Save(string paramName)
        {
            base.Save(paramName);
            if (!bInited)
            {
                return;
            }

            if (string.IsNullOrEmpty(iid))
            {
                if (!CakeCache.dIDDirtyParams.ContainsKey(id))
                {
                    CakeCache.dIDDirtyParams.Add(id, new Dictionary <string, Dictionary <string, AParam> >());
                }
                if (!CakeCache.dIDDirtyParams[id].ContainsKey(cakeType))
                {
                    CakeCache.dIDDirtyParams[id].Add(cakeType, new Dictionary <string, AParam>());
                }
                if (!CakeCache.dIDDirtyParams[id][cakeType].ContainsKey(paramName))
                {
                    CakeCache.dIDDirtyParams[id][cakeType].Add(paramName, GetValue(paramName));
                }
                else
                {
                    CakeCache.dIDDirtyParams[id][cakeType][paramName] = GetValue(paramName);
                }

                APlayerManager.SendToClient(id, GetDirtyPkt());
            }
            else
            {
                if (!CakeCache.dIIDDirtyParams.ContainsKey(id))
                {
                    CakeCache.dIIDDirtyParams.Add(id, new Dictionary <string, Dictionary <string, Dictionary <string, AParam> > >());
                }
                if (!CakeCache.dIIDDirtyParams[id].ContainsKey(iid))
                {
                    CakeCache.dIIDDirtyParams[id].Add(iid, new Dictionary <string, Dictionary <string, AParam> >());
                }
                if (!CakeCache.dIIDDirtyParams[id][iid].ContainsKey(cakeType))
                {
                    CakeCache.dIIDDirtyParams[id][iid].Add(cakeType, new Dictionary <string, AParam>());
                }
                if (!CakeCache.dIIDDirtyParams[id][iid][cakeType].ContainsKey(paramName))
                {
                    CakeCache.dIIDDirtyParams[id][iid][cakeType].Add(paramName, GetValue(paramName));
                }
                else
                {
                    CakeCache.dIIDDirtyParams[id][iid][cakeType][paramName] = GetValue(paramName);
                }

                APlayerManager.SendToClient(id, GetSubCake(iid).GetDirtyPkt());
            }
        }