Exemple #1
0
 public void OpenImpulseView()
 {
     FindComponent();
     GetNPCID();
     GetServerInfo();
     JoinViewRefreshGift();
     //如果在隐藏中就刷新主界面
     if (UIComponent.GetComponentHaveExist <UIImpulseComponent>(UIType.UIImpulse) != null)
     {
         impulesMainView.ShowView(0);
     }
 }
Exemple #2
0
    /// <summary>
    /// 请求赠送礼物并返回主界面
    /// </summary>
    void GivingGiftAndBackMainView()
    {
        //请求
        if (giftInfo.giftInfo.Count > 0)//有送礼物(请求成功后清除列表)
        {
            CSSendNPCGift cSSendNPCGift = new CSSendNPCGift()
            {
                NPCId = giftInfo.NpcID
            };
            foreach (var item in giftInfo.giftInfo)
            {
                cSSendNPCGift.SendGiftInfo.Add(item);
            }
            //最后一个参数false 则请求失败后自己处理
            ProtocalManager.Instance().SendCSSendNPCGift(cSSendNPCGift, (SCEmptySendNPCGift FavorableInfo) =>
            {//成功就成功返回主界面
                this.LastFavorableState.FieldAssignment(this.NewFavorableState);

                foreach (var item in StaticData.playerInfoData.favorableData)
                {
                    if (item.NPCId != this.NewFavorableState.NPCId)
                    {
                        continue;
                    }
                    item.FieldAssignment(this.NewFavorableState);
                }
                //前端自己处理前端仓库数据
                foreach (var item in giftInfo.giftInfo)
                {
                    var goods = StaticData.GetWareHouseItem(item.GoodId);
                    if (goods != null)
                    {
                        goods.GoodNum -= item.GoodNum;
                    }
                }
                giftInfo.giftInfo.Clear();//清除数据
                //删除属性计时器
                if (npc2Player.timeCountDown != null)
                {
                    GameObject.Destroy(npc2Player.timeCountDown.gameObject);
                    npc2Player.timeCountDown = null;
                }
                if (player2Npc.timeCountDown != null)
                {
                    GameObject.Destroy(player2Npc.timeCountDown.gameObject);
                    player2Npc.timeCountDown = null;
                }
                this.transform.DOLocalMoveX(closeValue, moveAnimaTime);
                impulesMainView.ShowView();
            }, (ErrorInfo e) =>
            {                                                                    //失败再刷新页面
                uIImpulseComponent.RefreshLastGift();                            //失败后刷新仓库礼物道具
                ShowGiftList();                                                  //刷新列表
                GetNpcAndPlayerInfo(this.LastFavorableState);                    //回到初入界面的好感值
                this.NewFavorableState.FieldAssignment(this.LastFavorableState); //前端缓存的好感值同时回到最初
                giftInfo.giftInfo.Clear();                                       //清除数据
                Debug.LogError("服务器赠送礼物错误");
            }, false);
        }
        else
        {
            this.transform.DOLocalMoveX(closeValue, moveAnimaTime);
            impulesMainView.ShowView();
        }
    }