Esempio n. 1
0
        public EAlly HAllyOperate(int unionID, int targetID, EAllyOperate operateType)
        {
            EAlly result = EAlly.EFail;

            try
            {
                lock (_Mutex)
                {
                    if (!VersionIsEqual())
                    {
                        _unionDic.Clear();
                        _allyDic.Clear();
                        _requestDic.Clear();
                        _acceptDic.Clear();

                        _CoreInterface.GetEventSourceInterface().fireEvent(new KFNotifyAllyStartGameEvent(), (int)_sceneType);
                        return(result);
                    }

                    ConcurrentDictionary <int, List <AllyData> > dic = null;
                    switch (operateType)
                    {
                    case EAllyOperate.Agree:
                    case EAllyOperate.Refuse:
                        dic = _acceptDic;
                        break;

                    case EAllyOperate.Cancel:
                        dic = _requestDic;
                        break;

                    case EAllyOperate.Remove:
                        dic = _allyDic;
                        break;
                    }

                    List <AllyData> list = null;
                    if (!dic.TryGetValue(unionID, out list))
                    {
                        return(EAlly.ENoTargetUnion);
                    }

                    AllyData targetData = dic[unionID].Find(
                        delegate(AllyData data) { return(data.UnionID == targetID); });
                    if (targetData == null)
                    {
                        return(EAlly.ENoTargetUnion);
                    }

                    IAllyService kuaFuService = GetKuaFuService();
                    if (null == kuaFuService)
                    {
                        return(EAlly.EServer);
                    }

                    try
                    {
                        result = (EAlly)kuaFuService.AllyOperate(_ClientInfo.ServerId, unionID, targetID, (int)operateType);
                        if (result == EAlly.AllyAgree || result == EAlly.AllyRefuse ||
                            result == EAlly.AllyCancelSucc || result == EAlly.AllyRemoveSucc)
                        {
                            dic[unionID].Remove(targetData);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        ResetKuaFuService();
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }

            return(result);
        }