Exemple #1
0
        //type 1:开始抽奖  2:下次抽奖
        private void ActivityLottery(int id, OperationActivityTermDataModel current, int type)
        {
            if (null != mCoroutine)
            {
                Logger.Error("ClaimRewardOperationActivity not finish");
                return;
            }
            int opt         = id;//0重置,1抽奖
            int need        = 0;
            var lotterModel = current.LotteryData;

            if (0 == opt)
            {
                if (lotterModel.Times < lotterModel.TotalTimes)
                {
                    return;
                }
                need = lotterModel.ResetCost;
            }
            else
            {
                if (lotterModel.Times >= lotterModel.TotalTimes)
                {
                    return;
                }
                need = lotterModel.CurrentCost;
            }
            if (PlayerDataManager.Instance.GetRes((int)eResourcesType.DiamondRes) < need)
            {
                EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(GameUtils.GetDictionaryText(210102)));
                GameUtils.GotoUiTab(79, 0);
            }
            else
            {
                if (null != GameLogic.Instance)
                {
                    float delay = 0 == opt ? 0 : 1f;
                    mCoroutine = GameLogic.Instance.StartCoroutine(OperationActivityClaimRewardCoroutine(current.ActivityId, id, delay));
                    if (0 != opt)
                    {
                        if (type == 1)
                        {
                            isLotteryStart = false;
                        }
                        else
                        {
                            isLotteryEnd = false;
                        }
                        var e = new OperationActivityDrawLotteryEvent(-1);
                        EventDispatcher.Instance.DispatchEvent(e);
                    }
                }
            }
        }
    private IEnumerator OperationActivityClaimRewardCoroutine(int parentId, int id, float delay = 0)
    {
        if (delay > 0)
        {
            yield return(new WaitForSeconds(delay));
        }

        var msg = NetManager.Instance.ClaimOperationReward(parentId, id);

        yield return(msg.SendAndWaitUntilDone());

        if (msg.State != MessageState.Reply)
        {
            EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(200005000));
            mCoroutine = null;
            yield break;
        }

        if (msg.ErrorCode != 0)
        {
            UIManager.Instance.ShowNetError(msg.ErrorCode);
            mCoroutine = null;
            yield break;
        }


        var ret = msg.Response;

        for (int i = 0; i < OperationActivityDataModel.ActivityTermList.Count; i++)
        {
            var termModel = OperationActivityDataModel.ActivityTermList[i];
            if (-1 != termModel.ActivityId && termModel.ActivityId == parentId && OperationActivityUIType.Lottery == (OperationActivityUIType)termModel.UIType)
            {
                for (int j = 0; j < termModel.LotteryData.ActivityItemList.Count; j++)
                {
                    var actItem = termModel.LotteryData.ActivityItemList[j];
                    if (ret == actItem.ItemId)
                    {
                        var e = new OperationActivityDrawLotteryEvent(j, actItem.Rewards[0].ItemId, actItem.Rewards[0].Count);
                        EventDispatcher.Instance.DispatchEvent(e);

                        AddLotteryRecord(actItem.Rewards[0].ItemId, actItem.Rewards[0].Count);
                        break;
                    }
                }
                break;
            }
        }

        mCoroutine = null;
    }
Exemple #3
0
        private void OnSyncOperationActivityItem(IEvent ievent)
        {
            var e = ievent as SyncOperationActivityItemEvent;

            if (null == e.Data)
            {
                Dirty = true;
                return;
            }

            bool needRefreshLotteryMask = false;

            foreach (var item in mItemCache)
            {
                if (item.ItemId == e.Data.Id)
                {
                    needRefreshLotteryMask = (0 == e.Data.AquiredTimes && item.AquiredTimes > 0);
                    item.Count             = Math.Min(e.Data.Count, item.Need);
                    item.AquiredTimes      = e.Data.AquiredTimes;
                    item.RemainAquireTimes = string.Format(GameUtils.GetDictionaryText(100001156), Math.Max(item.AquiredTotalTimes - item.AquiredTimes, 0));
                    CheckAllCondition();

                    var totalDataModel = OperationActivityDataModel;
                    foreach (var term in totalDataModel.OpenActivityTermList)
                    {
                        if (term.ActivityId == item.ParentId)
                        {
                            term.OnPropertyChanged("NoticeCount");
                            totalDataModel.OnPropertyChanged("OpenNoticeCount");
                            break;
                        }
                        else if (term.UIType == (int)OperationActivityUIType.Table)
                        {
                            foreach (var item2 in term.TableData.TableList)
                            {
                                if (item2.ActivityId == item.ParentId)
                                {
                                    item2.OnPropertyChanged("NoticeCount");
                                    term.OnPropertyChanged("NoticeCount");
                                    totalDataModel.OnPropertyChanged("OpenNoticeCount");
                                    break;
                                }
                            }
                        }
                    }

                    //totalDataModel = OperationActivityDataModel2;
                    foreach (var term in totalDataModel.NormalActivityTermList)
                    {
                        if (term.ActivityId == item.ParentId)
                        {
                            term.OnPropertyChanged("NoticeCount");
                            totalDataModel.OnPropertyChanged("NormalNoticeCount");
                            break;
                        }
                        else if (term.UIType == (int)OperationActivityUIType.Table)
                        {
                            foreach (var item2 in term.TableData.TableList)
                            {
                                if (item2.ActivityId == item.ParentId)
                                {
                                    item2.OnPropertyChanged("NoticeCount");
                                    term.OnPropertyChanged("NoticeCount");
                                    totalDataModel.OnPropertyChanged("NormalNoticeCount");
                                    break;
                                }
                            }
                        }
                    }

                    /*
                     *          if (!needRefreshLotteryMask && item.AquiredTimes == 0)
                     *          {
                     *                  if (OperationActivityDataModel.CurrentSelectPageIdx >= 0 && OperationActivityDataModel.CurrentSelectPageIdx < OperationActivityDataModel.ActivityTermList.Count)
                     *                  {
                     *                          var currentData = OperationActivityDataModel.ActivityTermList[OperationActivityDataModel.CurrentSelectPageIdx];
                     *                          if ((OperationActivityUIType) currentData.UIType == OperationActivityUIType.Lottery)
                     *                          {
                     *                                  needRefreshLotteryMask = true;
                     *                          }
                     *                  }
                     *
                     *          }
                     */

                    break;
                }
            }

            if (needRefreshLotteryMask)
            {
                var ee = new OperationActivityDrawLotteryEvent(-2);
                EventDispatcher.Instance.DispatchEvent(ee);
            }
        }
    private void ClaimRewardOperationActivity(int id)
    {
        //判断是否是抽奖
        if (OperationActivityDataModel.CurrentSelectPageIdx >= 0 &&
            OperationActivityDataModel.CurrentSelectPageIdx < OperationActivityDataModel.ActivityTermList.Count)
        {
            var current = OperationActivityDataModel.ActivityTermList[OperationActivityDataModel.CurrentSelectPageIdx];
            if ((OperationActivityUIType)current.UIType == OperationActivityUIType.Lottery)
            {
                int opt         = id;        //0重置,1抽奖
                int need        = 0;
                var lotterModel = current.LotteryData;
                if (0 == opt)
                {
                    if (lotterModel.Times < lotterModel.TotalTimes)
                    {
                        return;
                    }
                    need = lotterModel.ResetCost;
                }
                else
                {
                    if (lotterModel.Times >= lotterModel.TotalTimes)
                    {
                        return;
                    }
                    need = lotterModel.CurrentCost;
                    if (null != mCoroutine)
                    {
                        Logger.Error("ClaimRewardOperationActivity not finish");
                        return;
                    }
                }
                if (PlayerDataManager.Instance.GetRes((int)eResourcesType.DiamondRes) < need)
                {
                    EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(GameUtils.GetDictionaryText(210102)));
                    GameUtils.GotoUiTab(79, 0);
                }
                else
                {
                    if (null != GameLogic.Instance)
                    {
                        float delay = 0 == opt?0:1f;
                        mCoroutine = GameLogic.Instance.StartCoroutine(OperationActivityClaimRewardCoroutine(current.ActivityId, id, delay));
                        if (0 != opt)
                        {
                            var e = new OperationActivityDrawLotteryEvent(-1);
                            EventDispatcher.Instance.DispatchEvent(e);
                        }
                    }
                }
                return;
            }
        }

        OperationActivityItemDataModel item = null;

        foreach (var itemDataModel in mItemCache)
        {
            if (itemDataModel.ItemId == id)
            {
                item = itemDataModel;
                break;
            }
        }

        if (null == item)
        {
            return;
        }

        if (-1 != item.GuideActivityId)
        {        //导航
            for (int i = 0; i < OperationActivityDataModel.ActivityTermList.Count; i++)
            {
                if (OperationActivityDataModel.ActivityTermList[i].ActivityId == item.GuideActivityId)
                {
                    ChooseActivityMenu(i);
                    return;
                }
            }

            return;
        }

        if (!item.CanGetReward)
        {
            if (-1 != item.GuideUI)
            {
                GameUtils.GotoUiTab(item.GuideUI, 0);
                return;
            }
            return;
        }

        var type = item.ParentId;

        if (-1 != item.NeedItemId)
        {
            var itemRecord = Table.GetItemBase(item.NeedItemId);
            if (null == itemRecord)
            {
                return;
            }

            var haveItemCount = PlayerDataManager.Instance.GetItemTotalCount(item.NeedItemId).Count;
            if (haveItemCount < item.NeedItemCount)
            {
                var str = GameUtils.GetDictionaryText(270002);
                if (3 == item.NeedItemId)
                {
                    str = GameUtils.GetDictionaryText(210102);
                    GameUtils.GotoUiTab(79, 0);
                }
                EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(str));
                return;
            }
        }
        NetManager.Instance.StartCoroutine(OperationActivityClaimRewardCoroutine(type, id));
    }