Пример #1
0
    public async UniTask EndDialog()
    {//触发支付
        SetSelfPayState();
        Root2dSceneManager._instance.manorUnLockDialogComponent.FinishDialog();
        //Root2dSceneManager._instance.worldCameraComponent.PlayCameraToUnLockRegionOld();
        await UniTask.Delay(1000);

        //UIComponent.CreateUI(UIType.UIManor);
        UIComponent.RemoveUI(UIType.UICommonPopupTips);

        CSUnlockArea csUnlockArea = new CSUnlockArea()
        {
            AreaId = regionId,
            State  = AreaState.Conversation//上一阶段对话状态
        };

        ManorProtocalHelper.UnlockRegion(csUnlockArea, (regionUnLockDialogEndSucc) =>
        {
            StaticData.DebugGreen($"对话结束返回状态:{regionUnLockDialogEndSucc.State.ToString()}");
            //对话状态开始
            if (regionUnLockDialogEndSucc.State == AreaState.Pay)
            {
                BeginPayUI();
            }
        });
    }
Пример #2
0
    private void ClickWorkShed()
    {
        CSUnlockArea csUnlockArea = new CSUnlockArea()
        {
            AreaId = regionId,
            State  = AreaState.WorkShed
        };

        ManorProtocalHelper.UnlockRegion(csUnlockArea, (regionUnLockDialogEndSucc) =>
        {
            //播放音效点击
            GameSoundPlayer.Instance.PlaySoundEffect(MusicHelper.SoundEffectAreaUnlockedSuccessfully);
            SetDataDotRegionUnLockSucc();
            ////工棚新手引导完成
            //if (StaticData.isOpenGuide && GuideCanvasComponent._instance != null && GuideCanvasComponent._instance.isCurrStepGuiding)
            //{
            //    GuideCanvasComponent._instance.SetLittleStepFinish();
            //}
            //展示动画,临时替代
            List <CSWareHouseStruct> awardIds = new List <CSWareHouseStruct>();
            for (int i = 0; i < regionUnLockDialogEndSucc.GoodsInfo.Count; i++)
            {
                var wareHouseStruct = StaticData.SCBuyGoodsStructToCSWareHouseStruct(regionUnLockDialogEndSucc.GoodsInfo[i]);
                awardIds.Add(wareHouseStruct);
            }
            var goReward = UIComponent.CreateUI(UIType.UIManorUnlockReward);
            goReward.GetComponent <UIManorUnlockRewardComponent>().SetRewards(this, awardIds, regionUnLockDialogEndSucc);
        });
    }
Пример #3
0
    //从一块地上收获
    public void GainOneTile(SeedGrowComponent willSeedGrowComponent)
    {
        csHarvestData.HarvestInfo.Clear();//只保存当前的这个可收获的
        CSHarvestStruct csHarvestStruct = new CSHarvestStruct()
        {
            SoilId = willSeedGrowComponent.tileComponent.SoilId
        };

        csHarvestData.HarvestInfo.Add(csHarvestStruct);
        ManorProtocalHelper.ManorHarvest(csHarvestData, async(succ) =>
        {
            CloseAll();
            int cropId       = willSeedGrowComponent.tileComponent.CropGoodId;
            int gameDefineId = StaticData.configExcel.GetManorCropByCropId(cropId).IdGainGameItem;
            int addCount     = 0;
            for (int j = 0; j < succ.HarvestResult.Count; j++)
            {
                if (succ.HarvestResult[j].HarvestId == gameDefineId)
                {
                    addCount = succ.HarvestResult[j].HarvestNum;
                    break;
                }
            }
            PlayItemHarvestEffect(willSeedGrowComponent.tileComponent, addCount);
            int addExp = 0;
            for (int i = 0; i < succ.HarvestResult.Count; i++)
            {
                addExp = succ.HarvestResult[i].HarvestExperience;
            }
            PlayExpAnim(willSeedGrowComponent.tileComponent, addExp);
            willSeedGrowComponent.tileComponent.CropGoodId = 0;
            //删除
            Destroy(willSeedGrowComponent.gameObject);
            willSeedGrowComponent.tileComponent.SetCurrGoPlant(null);
            //删除seedGrowCom
            Root2dSceneManager._instance.RemoveFromListSeedGrow(willSeedGrowComponent);
            willSeedGrowComponent = null;
            csHarvestData.HarvestInfo.Clear();
            //更新仓库 2020/9/29 huangjiangdong 将收获果实数据入库提前
            for (int i = 0; i < succ.HarvestResult.Count; i++)
            {
                //更新仓库果实数量
                StaticData.UpdateWareHouseItem(succ.HarvestResult[i].HarvestId, succ.HarvestResult[i].HarvestNum);
            }
        });
    }
Пример #4
0
 //确认旋转
 public async void OnButtonRotateOKClick(bool isAutoPlayCloseDecorate = true)
 {
     if (isAutoPlayCloseDecorate)
     {
         //关闭装饰物界面
         UIComponent.GetComponentHaveExist <UIManorComponent>(UIType.UIManor).uiManorAnim.PlayAnimCloseDecorate();
     }
     if (AfterRotateInfo.SoilId <= 0)//没有旋转过
     {
         //关闭界面
         goRebackAndRotate.SetActive(false);
         //关闭提示
         TipsTileComponent._instance.CloseAll();
         isRotatingDecorate = false;
         return;
     }
     if (AfterRotateInfo.isCanPlace)
     {//能放,提交服务器
         CSManorDecorateRotate csManorDecorateRotate = new CSManorDecorateRotate()
         {
             SoilId      = (int)AfterRotateInfo.SoilId,
             RotateIndex = AfterRotateInfo.idxDecorateRotate
         };
         ManorProtocalHelper.SendManorDecorateRotate(csManorDecorateRotate, async(succ) =>
         {
             if (isAutoPlayCloseDecorate)
             {
                 //关闭界面
                 goRebackAndRotate.SetActive(false);
                 isRotatingDecorate = false;
             }
             //关闭提示
             TipsTileComponent._instance.CloseAll();
             //排序
             Root2dSceneManager._instance.UpdateSortLayer(true);
         }, async(error) => {
             //旋转成最开始的样子
             await ResetToOldDecorate(isAutoPlayCloseDecorate);
         });
     }
     else
     {//不能放,旋转成最开始的样子
         await ResetToOldDecorate(isAutoPlayCloseDecorate);
     }
 }
Пример #5
0
    private void OnPlantClick(PointerEventData eventData)
    {
        int seedCount     = StaticData.GetWareHouseItem(CropGoodId).GoodNum;
        int costCoinCount = 0;

        if (seedCount <= 0)
        {
            //判定金钱
            if (StaticData.GetWareHouseItem(currPlantSeed.coinPriceId).GoodNum < currPlantSeed.price)
            {
                ToBuyCurrency();
                return;
            }
            costCoinCount = (int)currPlantSeed.price;
        }
        UIWorldHandleManager uiUIWorldHandleComponent = StaticData.GetUIWorldHandleComponent();

        //实例化
        goPlant = GameObject.Instantiate <GameObject>(goPrefab);
        CSPlantStruct csPlantStruct = new CSPlantStruct()
        {
            SoilId     = uiUIWorldHandleComponent.currClickComponent.SoilId,
            CropGoodId = this.CropGoodId
        };

        if (uiUIWorldHandleComponent.currClickComponent != null)
        {
            uiUIWorldHandleComponent.currClickComponent.Plant(goPlant, csPlantStruct, () => {
                //设置地块上庄稼的id
                uiUIWorldHandleComponent.currClickComponent.CropGoodId = this.CropGoodId;
                AfterPlantCropSetInfo(uiUIWorldHandleComponent.currClickComponent);
            });
        }
        //种植
        ManorProtocalHelper.ManorPlant(Root2dSceneManager._instance.PlantData, (succ) => {
            StaticData.UpdateSeedMinus1(Root2dSceneManager._instance.PlantData);
            //更新货币
            if (costCoinCount > 0)
            {
                StaticData.UpdateWareHouseItem(currPlantSeed.coinPriceId, -costCoinCount);
            }
            uiUIWorldHandleComponent.SetHandleTileUIClose();
        });
    }
Пример #6
0
    public void OnDragUp()
    {
        PlantSeedDragComponent plantSeedDragComponent = StaticData.GetUIWorldHandleComponent().plantSeedDragComponent;

        plantSeedDragComponent.gameObject.SetActive(false);
        plantSeedDragComponent.isDrag = false;
        //种植
        if (Root2dSceneManager._instance.PlantData.PlantInfo.Count > 0)
        {
            //种植
            ManorProtocalHelper.ManorPlant(Root2dSceneManager._instance.PlantData, (succ) => {
                StaticData.UpdateSeedMinus1(Root2dSceneManager._instance.PlantData);
                Root2dSceneManager._instance.PlantData.PlantInfo.Clear();
                //更新货币
                if (DragWillCostCoin > 0)
                {
                    StaticData.UpdateWareHouseItem(currPlantSeed.coinPriceId, -DragWillCostCoin);
                }
            });
        }
    }
Пример #7
0
    internal void OnIncreaseClick(WorkShedSpeedUpWay workShedSpeedUpWay)
    {
        CSWorkShedSpeedUp csWorkShedSpeedUp = new CSWorkShedSpeedUp()
        {
            AreaId     = regionId,
            SpeedUpWay = workShedSpeedUpWay
        };

        ManorProtocalHelper.WorkLoadSpeedUp(csWorkShedSpeedUp, (succ) => {
            StaticData.CreateToastTips($"加速成功");
            //UIComponent.HideUI(UIType.UIManorRegionAdIncrease);
            decorateBoardComponent.SetRegionTimeChange(succ.UnlockTime, this);
            //广告加速钻石不变
            if (workShedSpeedUpWay == WorkShedSpeedUpWay.DiamondWay)
            {
                //更新道具
                var dealClass      = StaticData.configExcel.GetAreaUnlockByID(regionId).UseGoods;
                DealClass willCost = dealClass[0];
                StaticData.UpdateWareHouseItem(willCost.IdGameItem, -willCost.Price);
            }
        });
    }
Пример #8
0
    private void OnButtonRebackClick()
    {
        CSOrnamentalRecycle csOrnamentalRecycle = new CSOrnamentalRecycle()
        {
            SoilId = currClickDecorateComponent.SoilId
        };

        ManorProtocalHelper.SendOrnamentalRecycle(csOrnamentalRecycle, (succ) =>
        {
            //更新仓库装饰物
            StaticData.UpdateWareHouseItem(currClickDecorateComponent.CropGoodId, 1);
            //回收完更新装饰物界面
            UIManorComponent uiManorComponent = UIComponent.GetComponentHaveExist <UIManorComponent>(UIType.UIManor);
            uiManorComponent.RefreshDecorateList();

            //回收装饰物之前关闭提示,否则会把这个提示删掉
            TipsTileComponent._instance.CloseAll();
            Destroy(currClickDecorateComponent.gameObject);
            goReback.SetActive(false);
            goRebackAndRotate.SetActive(false);
        });
    }
Пример #9
0
    private void EradicatePlant()
    {
        if (seedGrowComponent != null && seedGrowComponent.currCropPeriod == SeedGrowComponent.PeriodGrow.Ripe)
        {
            StaticData.CreateToastTips($"作物已成熟,不能铲除!");
            SetHandleTileUIClose();
            return;
        }
        CSEradicate csEradicate = new CSEradicate()
        {
            SoilId = currClickComponent.SoilId
        };

        ManorProtocalHelper.ManorEradicatePlant(csEradicate, async(succ) =>
        {
            //关闭UI
            SetHandleTileUIClose();
            //铲除特效
            GoEradicateEffect.GetComponent <RectTransform>().anchoredPosition = StaticData.ManorWorldPointToUICameraAnchorPos(currClickComponent.transform.position);
            GoEradicateEffect.SetActive(true);
            isEradicating = true;
            await UniTask.Delay(500);
            GoEradicateEffect.SetActive(false);
            isEradicating = false;
            //播放音效点击
            GameSoundPlayer.Instance.PlaySoundEffect(MusicHelper.SoundEffectEradicate);
            currClickComponent.CropGoodId = 0;
            //删除
            if (seedGrowComponent != null)
            {
                Destroy(seedGrowComponent.gameObject);
            }
            currClickComponent.SetCurrGoPlant(null);
            //删除seedGrowCom
            Root2dSceneManager._instance.RemoveFromListSeedGrow(this.seedGrowComponent);
            this.seedGrowComponent = null;
        });
    }
Пример #10
0
    // Update is called once per frame
    void Update()
    {
        if (Root2dSceneManager._instance.currHandleTile != this.gameObject)
        {
            return;
        }
        var  worldComponent   = Root2dSceneManager._instance.worldCameraComponent;
        var  clickObj         = StaticData.UI_GetCurrentSelect();
        bool isUIScrollMask   = false;
        bool isUIDecorateMask = false;

        if (clickObj != null)//表明是UI
        {
            isUIScrollMask   = clickObj.CompareTag(TagHelper.UIScrollMask);
            isUIDecorateMask = clickObj.CompareTag(TagHelper.DecorateUIMask);
        }
        if (!isDrag && Input.GetMouseButtonUp(0) && (clickObj == null || isUIScrollMask || isUIDecorateMask))//鼠标抬起
        {
            //关闭掉正在处理的装饰物
            if (isUIDecorateMask && StaticData.GetUIWorldHandleComponent().isRotatingDecorate)
            {
                StaticData.GetUIWorldHandleComponent().OnButtonRotateOKClick(false);
                StaticData.GetUIWorldHandleComponent().SetHandleTileUIClose();
            }
            isPress     = false;
            isDrag      = false;
            isLongPress = false;
            if (timeCurrPress > timeOnClickMinThreshold && timeCurrPress <= timeLongPressThreshold)
            {
                StaticData.DebugGreen("触发小地块点击");
                OnTileClick();
            }
            timeCurrPress = 0f;
        }
        else if (isDrag)
        {
            //正在拖拽,判定是否小于边缘

            EnumDirection direction = EnumDirection.None;
            for (int i = 0; i < worldComponent.listDirection.Count; i++)
            {
                float xDir   = worldComponent.listDirection[i].x;
                float yDir   = worldComponent.listDirection[i].y;
                var   newPos = Input.mousePosition + new Vector3(xDir, yDir, 0) * ManorCameraWorldComponent.SizeScreenToSide;
                //四个方向判定
                if (newPos.x <= 0f)
                {
                    direction = EnumDirection.Left;
                    break;
                }
                else if (newPos.x >= Screen.width)
                {
                    direction = EnumDirection.Right;
                    break;
                }
                else if (newPos.y <= 0f)
                {
                    direction = EnumDirection.Bottom;
                    break;
                }
                else if (newPos.y >= Screen.height)
                {
                    direction = EnumDirection.Up;
                    break;
                }
            }
            if (direction != EnumDirection.None)//表示是自动滑动
            {
                worldComponent.TriggerAutoScroll(direction);
            }
            else
            {//改变了方向
                worldComponent.EndAutoScroll();
            }
        }
        //只要鼠标抬起,就停止自动滚动
        if (Input.GetMouseButtonUp(0))//滑动过程中鼠标抬起也终止自动滑动
        {
            worldComponent.EndAutoScroll();
        }

        if (isPress && !isDrag)
        {
            timeCurrPress += Time.deltaTime;
            //小地块滑动
            if (Vector2.Distance(tileMousePos, Input.mousePosition) <= 10f)//10f做为滑动的阈值
            {
                if (timeCurrPress >= timeLongPressThreshold)
                {
                    if (!Root2dSceneManager._instance.isFriendManor)//好友庄园不能长按拖动
                    {
                        //正在处理装饰物
                        if (StaticData.GetUIWorldHandleComponent().isRotatingDecorate&& typeTile == TypeManorDecorate.Decorate)
                        {
                            isPress = false;
                            return;
                        }
                        isLongPress = true;
                        StaticData.DebugGreen("触发小地块拖动");
                        BeginDrag(true);
                    }
                }
            }
        }
        if (isBeginPlace && Input.GetMouseButton(0))//鼠标按住处理
        {
            SetTilePos(false);
            //播放完抬起动画再检查
            if (isUpAnimPlaying == false)
            {
                CheckIsCanPlace(() =>
                {
                    //显示红色箭头
                    TipsTileComponent._instance.SetCanPlace(transform, false, this);
                }, () =>
                {
                    //显示蓝色箭头
                    TipsTileComponent._instance.SetCanPlace(transform, true, this);
                });
            }
        }
        if (Input.GetMouseButtonUp(0))//鼠标抬起
        {
            ctsWaitPlayUpAnim?.Cancel();
            isUpAnimPlaying = false;
            //庄园角色移动,继续气泡播放
            if (isNPC)
            {
                Root2dSceneManager._instance.GetManorBubbleComponent().ResetBeginAnimByTime();
            }
            //关闭提示
            TipsTileComponent._instance.CloseAll();
            //打开Manor UI
            UIManorComponent uiManorComponent = UIComponent.GetComponentHaveExist <UIManorComponent>(UIType.UIManor);
            uiManorComponent.DragTileOrDecorateCloseSelfManor(false);
            TipsTileComponent._instance.CloseUpAnim();
            ResetHandleVar();
            if (GoUIRootScroll != null)
            {
                GoUIRootScroll.SetActive(true);
            }
            CheckIsCanPlace(() =>
            {
                if (isBeginPlace == false)
                {
                    return;
                }
                CancelPlaceHandle();
                isBeginPlace = false;
                return;
            }, () =>
            {
                if (isBeginPlace == false)
                {
                    return;
                }
                isBeginPlace = false;
                //放置的时候排序
                Root2dSceneManager._instance.UpdateSortLayer(true);
                if (!this.isDragFromScene)//创建过程
                {
                    CSDrag csDrag = new CSDrag()
                    {
                        Type   = (int)DecorateType,
                        Xaxle  = transform.localPosition.x,
                        Yaxle  = transform.localPosition.y,
                        GoodId = this.CropGoodId
                    };
                    ManorProtocalHelper.CreateManorGoByDrag(csDrag, (scDrag) =>
                    {
                        //设置id
                        this.SoilId = scDrag.SoilId;
                        //地块使用数+1
                        //可以放置,地块数量变化
                        if (DecorateType == TypeManorDecorate.Tile && this.CropGoodId == 0)
                        {
                            //扣除货币
                            StaticData.UpdateWareHouseItem(Root2dSceneManager._instance.dealClassCurrency.IdGameItem, -Root2dSceneManager._instance.dealClassCurrency.Price);
                        }
                        else if (DecorateType == TypeManorDecorate.Decorate && this.CropGoodId != 0)
                        {
                            StaticData.DecorateMinusOne(this.CropGoodId);
                            uiManorComponent.RefreshDecorateList();
                            //拖拽生成装饰物
                            StaticData.GetUIWorldHandleComponent().OpenRebackDecorate(this);
                        }
                    });
                }
                else
                {
                    //移动位置
                    CSChangeLocation csChangeLocation = new CSChangeLocation()
                    {
                        SoilId = this.SoilId,
                        Xaxle  = transform.localPosition.x,
                        Yaxle  = transform.localPosition.y
                    };
                    ManorProtocalHelper.MoveManorGo(csChangeLocation, (succ) => { });
                }
            });
        }
    }
Пример #11
0
 public void OnButtonGainOrStealOneKeyClick()
 {
     if (!Root2dSceneManager._instance.isFriendManor)
     {//一键收取
         var listSeedGrow = Root2dSceneManager._instance.GetListSeedGrow();
         var listRipe     = listSeedGrow.FindAll(x => x.currCropPeriod == SeedGrowComponent.PeriodGrow.Ripe);
         if (listRipe != null && listRipe.Count > 0)
         {
             CSHarvestData csHarvestData = new CSHarvestData();
             for (int i = 0; i < listRipe.Count; i++)
             {
                 CSHarvestStruct csHarvestStruct = new CSHarvestStruct()
                 {
                     SoilId = listRipe[i].tileComponent.SoilId
                 };
                 csHarvestData.HarvestInfo.Add(csHarvestStruct);
             }
             ManorProtocalHelper.ManorHarvest(csHarvestData, async(succ) =>
             {
                 CloseAll();
                 //一键收取特效
                 for (int i = 0; i < listRipe.Count; i++)
                 {
                     int cropId       = listRipe[i].tileComponent.CropGoodId;
                     int gameDefineId = StaticData.configExcel.GetManorCropByCropId(cropId).IdGainGameItem;
                     int addCount     = 0;
                     for (int j = 0; j < succ.HarvestResult.Count; j++)
                     {
                         if (succ.HarvestResult[j].HarvestId == gameDefineId)
                         {
                             addCount = succ.HarvestResult[j].HarvestNum;
                             break;
                         }
                     }
                     PlayItemHarvestEffect(listRipe[i].tileComponent, addCount);
                     int addExp = 0;
                     for (int k = 0; k < succ.HarvestResult.Count; k++)
                     {
                         addExp = succ.HarvestResult[k].HarvestExperience;
                     }
                     PlayExpAnim(listRipe[i].tileComponent, addExp);
                 }
                 for (int i = 0; i < listRipe.Count; i++)
                 {
                     listRipe[i].tileComponent.CropGoodId = 0;
                     //删除
                     Destroy(listRipe[i].gameObject);
                     listRipe[i].tileComponent.SetCurrGoPlant(null);
                     //删除seedGrowCom
                     Root2dSceneManager._instance.RemoveFromListSeedGrow(listRipe[i]);
                 }
                 //更新仓库
                 for (int i = 0; i < succ.HarvestResult.Count; i++)
                 {
                     //更新仓库果实数量
                     StaticData.UpdateWareHouseItem(succ.HarvestResult[i].HarvestId, succ.HarvestResult[i].HarvestNum);
                 }
             });
         }
     }
     else
     {//一键偷取
         ListStealInfo.Clear();
         for (int i = 0; i < listStealClass.Count; i++)
         {
             if (listStealClass[i].isSteal)
             {
                 ListStealInfo.Add(new CSStealStruct()
                 {
                     SoilId = listStealClass[i].SolidId
                 });
             }
         }
         CSStealData csStealData = new CSStealData();
         for (int i = 0; i < ListStealInfo.Count; i++)
         {
             csStealData.StealInfo.Add(ListStealInfo[i]);
         }
         csStealData.StealUid = IdFriend;
         ManorProtocalHelper.StealFriendFruit(csStealData, async(scStealData) =>
         {
             StaticData.DataDot(Company.Cfg.DotEventId.FriendManorStealSucc);
             //已经偷取过的,设置状态为不能偷
             if (scStealData == null)
             {
                 return;
             }
             if (scStealData.StealResult == null)
             {
                 return;
             }
             if (scStealData.StealResult.Count <= 0)
             {
                 return;
             }
             //偷取特效
             CloseAll();
             for (int i = 0; i < scStealData.StealResult.Count; i++)
             {
                 var stealClass = this.listStealClass.Find(x => x.SolidId == scStealData.StealResult[i].SoilId);
                 if (stealClass != null)
                 {
                     //播放特效
                     TileComponent tile = null;
                     for (int j = 0; j < Root2dSceneManager._instance.objPool.transform.childCount; j++)
                     {
                         var tileGo            = Root2dSceneManager._instance.objPool.transform.GetChild(j);
                         TileComponent tileCom = tileGo.GetComponent <TileComponent>();
                         if (tileGo.gameObject.activeInHierarchy && tileCom.SoilId == stealClass.SolidId)
                         {
                             tile = tileGo.GetComponent <TileComponent>();
                             break;
                         }
                     }
                     //设置图片个数
                     int cropId       = tile.CropGoodId;
                     int gameDefineId = StaticData.configExcel.GetManorCropByCropId(cropId).IdGainGameItem;
                     int addCount     = 0;
                     for (int j = 0; j < scStealData.StealResult.Count; j++)
                     {
                         if (scStealData.StealResult[j].StealId == gameDefineId)
                         {
                             addCount = scStealData.StealResult[j].StealNum;
                             break;
                         }
                     }
                     PlayItemHarvestEffect(tile, addCount);
                 }
             }
             for (int i = 0; i < scStealData.StealResult.Count; i++)
             {
                 var stealClass = this.listStealClass.Find(x => x.SolidId == scStealData.StealResult[i].SoilId);
                 if (stealClass != null)
                 {
                     stealClass.isSteal = false;
                 }
                 //更新仓库果实数量
                 StaticData.UpdateWareHouseItem(scStealData.StealResult[i].StealId, scStealData.StealResult[i].StealNum);
             }
             SetFriendManorStealState(this.listStealClass);
         });
     }
 }
Пример #12
0
    private void OnButtonAdClick()
    {
        List <SeedGrowComponent> listSeedGrow = Root2dSceneManager._instance.GetListSeedGrow();
        //23阶段的作物
        List <SeedGrowComponent> listSeedGrow23 = new List <SeedGrowComponent>();

        if (listSeedGrow != null && listSeedGrow.Count > 0)
        {
            for (int i = 0; i < listSeedGrow.Count; i++)
            {
                if (listSeedGrow[i].currCropPeriod == SeedGrowComponent.PeriodGrow.Germinate ||
                    listSeedGrow[i].currCropPeriod == SeedGrowComponent.PeriodGrow.GrowUp)
                {
                    listSeedGrow23.Add(listSeedGrow[i]);
                }
            }
        }
        if (listSeedGrow23.Count > 0)
        {
            CSEmptyCropSpeed csEmptyCropSpeed = new CSEmptyCropSpeed();
            ManorProtocalHelper.FertilizerAdIncrease(csEmptyCropSpeed, (succ) =>
            {
                //关闭UI
                uiWorldHandleManager.SetHandleTileUIClose();
                StaticData.playerInfoData.userInfo.CropCount++;
                if (StaticData.playerInfoData.userInfo.CropCount <= 0)
                {
                    StaticData.playerInfoData.userInfo.CropCount = 0;
                }
                UpdateFertilizerAdCount();
                for (int i = 0; i < listSeedGrow23.Count; i++)
                {
                    SeedGrowComponent.PeriodGrow nextPeriod = SeedGrowComponent.PeriodGrow.Seed;
                    float remainTimeToRipe = listSeedGrow23[i].remainTimeGerminateToRipe / 2f;
                    float remainTime       = listSeedGrow23[i].remainTime - remainTimeToRipe;
                    if (remainTime <= 0)
                    {
                        //下一个时期
                        switch (listSeedGrow23[i].currCropPeriod)
                        {
                        case SeedGrowComponent.PeriodGrow.Seed:
                            nextPeriod = SeedGrowComponent.PeriodGrow.Germinate;
                            break;

                        case SeedGrowComponent.PeriodGrow.Germinate:
                            remainTime = remainTimeToRipe;
                            nextPeriod = SeedGrowComponent.PeriodGrow.GrowUp;
                            break;

                        case SeedGrowComponent.PeriodGrow.GrowUp:
                            remainTime = remainTimeToRipe;
                            nextPeriod = SeedGrowComponent.PeriodGrow.Ripe;
                            break;

                        case SeedGrowComponent.PeriodGrow.Ripe:
                            break;
                        }
                        //remainTime = StaticData.GetSeedGrowComponentTotalSecond(listSeedGrow23[i], nextPeriod);
                    }
                    else
                    {
                        nextPeriod = listSeedGrow23[i].currCropPeriod;
                    }

                    listSeedGrow23[i].SetPeriod(nextPeriod, (long)remainTime * 1000);
                }
            }, (error) =>
            {
                uiWorldHandleManager.SetHandleTileUIClose();
            });
        }
        else
        {
            //关闭UI
            uiWorldHandleManager.SetHandleTileUIClose();
        }
    }
Пример #13
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="friendId">-1 表示自己</param>
    public async UniTask EnterManor(long friendId)
    {
        if (friendId == -1)
        {//自己
            StaticData.DataDot(Company.Cfg.DotEventId.OpenManor);
            StaticData.idPreEnterManor = -1;
            CSEmptyManorInfo csEmptyManorInfo = new CSEmptyManorInfo();
            ManorProtocalHelper.GetSelfManorInfo(csEmptyManorInfo, async(scManorData) =>
            {
                Root2dSceneManager._instance.isFriendManor = false;
                //设置头像信息
                StaticData.SetPlayerIconInfo();
                Root2dSceneManager._instance.UnlockAreaInfoSelf = scManorData.UnlockAreaInfo;
                // add_by_wsf
                mouseManorManager.playerUid = StaticData.Uid;
                // add_by_wsf end
                await GenerateExistPlants(scManorData.ManorInfo, false);
                SetRegionsUnLockInfoState();
                //根据本地数据恢复相机参数
                worldCameraComponent.SetWorldCameraParam();
                //判定是不是有公棚
                SetCameraToWorkShedRegion();
                //是否触发Avg动画
                if (LocalInfoData.localManorInfoData != null && LocalInfoData.localManorInfoData.isFirstAvgDialogFinish == false)
                {
                    //打开对话框
                    var UIDialogGo = await UIComponent.CreateUIAsync(UIType.UIManorUnLockRegionDialog);
                    UIDialogGo.GetComponent <UIManorUnLockRegionDialogComponent>().BeginFirstAVGDialog();
                }
            });
        }
        else
        {//好友
            StaticData.DataDot(Company.Cfg.DotEventId.EnterFriendManor);
            //新手引导
            if (friendId == 1 && StaticData.isOpenGuide && GuideCanvasComponent._instance != null && GuideCanvasComponent._instance.CurrExecuteGuideLittleStepDefine.Id == 10023)
            {
                CSEmptyManorGuidance csEmptyManorGuidance = new CSEmptyManorGuidance()
                {
                };
                ManorProtocalHelper.LookFriendGuide(csEmptyManorGuidance, async(scManorData) =>
                {
                    Root2dSceneManager._instance.isFriendManor = true;
                    //设置头像信息
                    StaticData.SetPlayerIconInfo();
                    Root2dSceneManager._instance.UnlockAreaInfoFriend = scManorData.UnlockAreaInfo;
                    StaticData.GetUIWorldHandleComponent().IdFriend   = friendId;
                    mouseManorManager.playerUid = friendId;
                    SetFriendGuideStealClass(scManorData.ManorInfo);
                    await GenerateExistPlants(scManorData.ManorInfo, true);
                    SetRegionsUnLockInfoState();
                });
                return;
            }
            CSQueryOther csQueryOther = new CSQueryOther()
            {
                OtherUid = friendId
            };
            ManorProtocalHelper.LookFriendManorInfo(csQueryOther, async(scManorData) =>
            {
                Root2dSceneManager._instance.isFriendManor = true;
                //设置头像信息
                StaticData.SetPlayerIconInfo();
                Root2dSceneManager._instance.UnlockAreaInfoFriend = scManorData.UnlockAreaInfo;
                StaticData.GetUIWorldHandleComponent().IdFriend   = friendId;
                // add_by_wsf
                mouseManorManager.playerUid = friendId;
                // add_by_wsf end

                //设置是否能偷的状态
                SetFriendManorListStealClass(scManorData);
                await GenerateExistPlants(scManorData.OtherManorInfo, true);
                SetRegionsUnLockInfoState();
            });
        }
    }
Пример #14
0
    //庄园一键浇水
    void OnButtonWateringOneKeyClick()
    {
        if (Root2dSceneManager._instance.isFriendManor)
        {//好友庄园不可操作
            return;
        }
        var firstFertilizer = StaticData.GetFertilizerCountByWhich(0);

        //水滴数量不足提示
        if (firstFertilizer.GoodNum <= 0)
        {
            //关闭UI
            StaticData.GetUIWorldHandleComponent().SetHandleTileUIClose();
            string FertilizerName = StaticData.GetMultiLanguageByGameItemId(firstFertilizer.GoodId);
            string Tips           = string.Format(StaticData.GetMultilingual(120068), FertilizerName);
            StaticData.OpenCommonTips(Tips, 120010, async() =>
            {
                //跳转商城
                await StaticData.OpenShopUI(1);
            });
            return;
        }
        //对接服务器
        CSEmptyOnceWatering csEmptyOnceWatering = new CSEmptyOnceWatering();

        ManorProtocalHelper.SendCSEmptyOnceWatering(csEmptyOnceWatering, (succ) =>
        {
            if (succ == null)
            {
                return;
            }
            if (succ.SoilId == null)
            {
                return;
            }
            if (succ.SoilId.Count <= 0)
            {
                return;
            }
            List <ItemFirstStageFertilizerComponent> listItemWaterComponent = new List <ItemFirstStageFertilizerComponent>();
            listItemWaterComponent.AddRange(uIWorldHandleManager.TransGoFirstStageRoot.GetComponentsInChildren <ItemFirstStageFertilizerComponent>());
            if (listItemWaterComponent != null && listItemWaterComponent.Count > 0)
            {
                //关闭UI
                StaticData.GetUIWorldHandleComponent().SetHandleTileUIClose();
                //播放音效点击
                GameSoundPlayer.Instance.PlaySoundEffect(MusicHelper.SoundEffectWatering);
                for (int i = 0; i < succ.SoilId.Count; i++)
                {
                    var itemWaterCom = listItemWaterComponent.Find(x => x.seedGrowComponent.tileComponent.SoilId == succ.SoilId[i]);

                    if (itemWaterCom != null)
                    {
                        //点击浇水的时候,关闭水滴
                        itemWaterCom.ButtonFertilizer.gameObject.SetActive(false);
                        itemWaterCom.TextNumNormal.gameObject.SetActive(false);
                        itemWaterCom.TextNumZero.gameObject.SetActive(false);
                        //施肥特效
                        StaticData.GetUIWorldHandleComponent().PlayWateringAnim(itemWaterCom.seedGrowComponent.tileComponent);

                        //end 施肥特效
                        SeedGrowComponent.PeriodGrow nextPeriod = SeedGrowComponent.PeriodGrow.Germinate; //种子的下一时期,幼苗期
                                                                                                          //直接进入下一个时期
                        float remainTime = StaticData.GetSeedGrowComponentTotalSecond(itemWaterCom.seedGrowComponent, nextPeriod);
                        itemWaterCom.seedGrowComponent.SetPeriod(nextPeriod, (long)remainTime * 1000);
                    }
                }
                //更新水滴数量
                StaticData.UpdateWareHouseItem(firstFertilizer.GoodId, -succ.SoilId.Count);
                //看是否还有能浇水的
                SetCanWateringOnekey();
            }
        });
    }
Пример #15
0
    public void BeginPay()
    {
        //道具判定
        var       dealClass = StaticData.configExcel.GetAreaUnlockByID(regionId).ConsumptionGood;
        bool      isEnough  = true;
        DealClass willCost  = null;

        for (int i = 0; i < dealClass.Count; i++)
        {
            willCost = dealClass[i];
            int currHaveCount = StaticData.GetWareHouseItem(willCost.IdGameItem).GoodNum;
            if (currHaveCount < willCost.Price)
            {
                isEnough = false;
                break;
            }
        }
        if (isEnough == false)
        {
            string CoinNameNotEnough = StaticData.configExcel.GetLocalizeByID(willCost.IdGameItem).SimplifiedChinese;
            string Tips = string.Format(StaticData.GetMultilingual(120068), CoinNameNotEnough);
            StaticData.OpenCommonTips(Tips, 120010, async() =>
            {
                UIComponent.RemoveUI(UIType.UIManorRegionPay);
                if (willCost.IdGameItem == 1000001)//表示钻石
                {
                    //跳转充值
                    await StaticData.OpenRechargeUI(1, BeginPayUI);
                }
                else if (willCost.IdGameItem == 1000002)//表示金币
                {
                    //跳转充值
                    await StaticData.OpenRechargeUI(0, BeginPayUI);
                }
                else
                {
                    //跳转商城
                    await StaticData.OpenShopUI(1, BeginPayUI);
                }
            });
            return;
        }
        CSUnlockArea csUnlockArea = new CSUnlockArea()
        {
            AreaId = regionId,
            State  = AreaState.Pay//上一阶段对话状态
        };

        ManorProtocalHelper.UnlockRegion(csUnlockArea, (regionUnLockPaySucc) =>
        {
            StaticData.DebugGreen($"对话结束返回状态:{regionUnLockPaySucc.State.ToString()}");
            //对话状态开始
            if (regionUnLockPaySucc.State == AreaState.RoadWork)
            {
                //关闭UI
                UIComponent.RemoveUI(UIType.UIManorRegionPay);
                //更新道具
                StaticData.UpdateWareHouseItem(willCost.IdGameItem, -willCost.Price);
                SetSelfRoadWorkState(regionUnLockPaySucc.RoadworkTime);
            }
        });
    }
Пример #16
0
    public void OnButtonStealClick(SeedGrowComponent willSeedGrowComponent)
    {
        CSStealData   csStealData   = new CSStealData();
        CSStealStruct csStealStruct = new CSStealStruct()
        {
            SoilId = willSeedGrowComponent.tileComponent.SoilId
        };

        csStealData.StealInfo.Add(csStealStruct);
        csStealData.StealUid = IdFriend;
        ManorProtocalHelper.StealFriendFruit(csStealData, async(scStealData) =>
        {
            StaticData.DataDot(Company.Cfg.DotEventId.FriendManorStealSucc);
            //已经偷取过的,设置状态为不能偷
            if (scStealData == null)
            {
                return;
            }
            if (scStealData.StealResult == null)
            {
                return;
            }
            if (scStealData.StealResult.Count <= 0)
            {
                return;
            }
            //偷取特效
            CloseAll();
            //表示能偷
            TileComponent tile = null;
            for (int i = 0; i < Root2dSceneManager._instance.objPool.transform.childCount; i++)
            {
                var tileGo            = Root2dSceneManager._instance.objPool.transform.GetChild(i);
                TileComponent tileCom = tileGo.GetComponent <TileComponent>();
                if (tileGo.gameObject.activeInHierarchy && tileCom.SoilId == scStealData.StealResult[0].SoilId)
                {
                    tile = tileGo.GetComponent <TileComponent>();
                    break;
                }
            }

            int cropId       = tile.CropGoodId;
            int gameDefineId = StaticData.configExcel.GetManorCropByCropId(cropId).IdGainGameItem;
            int addCount     = 0;
            for (int j = 0; j < scStealData.StealResult.Count; j++)
            {
                if (scStealData.StealResult[j].StealId == gameDefineId)
                {
                    addCount = scStealData.StealResult[j].StealNum;
                    break;
                }
            }
            //播放偷取特效
            PlayItemHarvestEffect(tile, addCount);
            for (int i = 0; i < scStealData.StealResult.Count; i++)
            {
                var stealClass = this.listStealClass.Find(x => x.SolidId == scStealData.StealResult[i].SoilId);
                if (stealClass != null)
                {
                    stealClass.isSteal = false;
                }
                //更新仓库果实数量
                StaticData.UpdateWareHouseItem(scStealData.StealResult[i].StealId, scStealData.StealResult[i].StealNum);
            }
            SetFriendManorStealState(this.listStealClass);
        });
    }
Пример #17
0
    public void OnButtonFertilizerClick()
    {
        if (Root2dSceneManager._instance.isFriendManor)
        {//好友庄园不可操作
            return;
        }
        var firstFertilizer = StaticData.GetFertilizerCountByWhich(0);

        if (firstFertilizer.GoodNum <= 0)
        {
            //关闭UI
            StaticData.GetUIWorldHandleComponent().SetHandleTileUIClose();
            string FertilizerName = StaticData.GetMultiLanguageByGameItemId(firstFertilizer.GoodId);
            string Tips           = string.Format(StaticData.GetMultilingual(120068), FertilizerName);
            StaticData.OpenCommonTips(Tips, 120010, async() =>
            {
                //跳转商城
                await StaticData.OpenShopUI(1);
            });
            return;
        }
        CSFertilizer csFertilizer = new CSFertilizer()
        {
            SoilId       = seedGrowComponent.tileComponent.SoilId,
            FertilizerId = firstFertilizer.GoodId
        };

        ManorProtocalHelper.UseFertilizer(csFertilizer, async(succ) =>
        {
            //第一阶段使用化肥
            if (StaticData.isOpenGuide && GuideCanvasComponent._instance != null && GuideCanvasComponent._instance.CurrExecuteGuideLittleStepDefine.Id == 10004)
            {
                GuideCanvasComponent._instance.SetLittleStepFinish();
            }
            //点击浇水的时候,关闭水滴
            ButtonFertilizer.gameObject.SetActive(false);
            TextNumNormal.gameObject.SetActive(false);
            TextNumZero.gameObject.SetActive(false);
            //关闭UI
            StaticData.GetUIWorldHandleComponent().SetHandleTileUIClose();
            //施肥特效
            string iconFretilizer = string.Empty;
            int propId            = csFertilizer.FertilizerId;
            iconFretilizer        = StaticData.configExcel.GetGameItemByID(propId).Icon;
            StaticData.GetUIWorldHandleComponent().PlayWateringAnim(seedGrowComponent.tileComponent);
            //播放音效点击
            GameSoundPlayer.Instance.PlaySoundEffect(MusicHelper.SoundEffectWatering);
            //end 施肥特效
            SeedGrowComponent.PeriodGrow nextPeriod = SeedGrowComponent.PeriodGrow.Germinate;//种子的下一时期,幼苗期
            //直接进入下一个时期
            float remainTime = StaticData.GetSeedGrowComponentTotalSecond(seedGrowComponent, nextPeriod);
            seedGrowComponent.SetPeriod(nextPeriod, (long)remainTime * 1000);
            //化肥数量-1
            StaticData.UpdateFertilizerMinus1(propId);
            //设置是否能一键浇水
            UIManorComponent uiManorComponent = UIComponent.GetComponentHaveExist <UIManorComponent>(UIType.UIManor);
            uiManorComponent.SetCanWateringOnekey();
        }, (error) =>
        {
            //关闭UI
            StaticData.GetUIWorldHandleComponent().SetHandleTileUIClose();
        });
    }
Пример #18
0
    private void OnButtonFertilizerClick(TypeFertilizer typeFertilizer)
    {
        CSWareHouseStruct currFertilizerData = null;

        switch (typeFertilizer)
        {
        case TypeFertilizer.fertilizer2:
            currFertilizerData = StaticData.GetFertilizerCountByWhich(1);    //第二种化肥
            break;

        case TypeFertilizer.fertilizer3:
            currFertilizerData = StaticData.GetFertilizerCountByWhich(2);    //第二种化肥
            break;

        default:
            break;
        }
        if (currFertilizerData.GoodNum <= 0)
        {
            //关闭UI
            uiWorldHandleManager.SetHandleTileUIClose();
            string FertilizerName = StaticData.GetMultiLanguageByGameItemId(currFertilizerData.GoodId);
            string Tips           = string.Format(StaticData.GetMultilingual(120068), FertilizerName);
            StaticData.OpenCommonTips(Tips, 120010, async() =>
            {
                //跳转商城
                await StaticData.OpenShopUI(1);
            });
            return;
        }
        CSFertilizer csFertilizer = new CSFertilizer()
        {
            SoilId       = seedGrowComponent.tileComponent.SoilId,
            FertilizerId = currFertilizerData.GoodId
        };

        ManorProtocalHelper.UseFertilizer(csFertilizer, async(succ) =>
        {
            //关闭UI
            uiWorldHandleManager.SetHandleTileUIClose();
            //施肥特效
            string iconFretilizer = string.Empty;
            int propId            = csFertilizer.FertilizerId;
            iconFretilizer        = StaticData.configExcel.GetGameItemByID(propId).Icon;
            uiWorldHandleManager.uiFertilizerEffectComponent.ShowInfo(iconFretilizer);
            uiWorldHandleManager.uiFertilizerEffectComponent.GetComponent <RectTransform>().anchoredPosition = StaticData.ManorWorldPointToUICameraAnchorPos(seedGrowComponent.tileComponent.transform.position);
            uiWorldHandleManager.uiFertilizerEffectComponent.gameObject.SetActive(true);
            uiWorldHandleManager.isFertiliezeringAnimPlay = true;
            await UniTask.Delay(1000);
            uiWorldHandleManager.uiFertilizerEffectComponent.gameObject.SetActive(false);
            uiWorldHandleManager.isFertiliezeringAnimPlay = false;
            //end 施肥特效
            SeedGrowComponent.PeriodGrow nextPeriod = SeedGrowComponent.PeriodGrow.Seed;
            var remainTime = seedGrowComponent.remainTime - StaticData.GetFertilizerAddTimeMilliSeconds(currFertilizerData.GoodId) / 1000f;
            if (remainTime <= 0)
            {
                //下一个时期
                switch (seedGrowComponent.currCropPeriod)
                {
                case SeedGrowComponent.PeriodGrow.Seed:
                    nextPeriod = SeedGrowComponent.PeriodGrow.Germinate;
                    break;

                case SeedGrowComponent.PeriodGrow.Germinate:
                    nextPeriod = SeedGrowComponent.PeriodGrow.GrowUp;
                    //成长期减去对应的时间
                    remainTime = StaticData.GetSeedGrowComponentTotalSecond(seedGrowComponent, nextPeriod) + remainTime;
                    if (remainTime <= 0)
                    {
                        //跳过了成长期,直接到成熟期
                        remainTime = 0f;
                        nextPeriod = SeedGrowComponent.PeriodGrow.Ripe;
                    }
                    break;

                case SeedGrowComponent.PeriodGrow.GrowUp:
                    nextPeriod = SeedGrowComponent.PeriodGrow.Ripe;
                    break;

                case SeedGrowComponent.PeriodGrow.Ripe:
                    //如果成熟阶段继续施肥还是成熟阶段
                    nextPeriod = SeedGrowComponent.PeriodGrow.Ripe;
                    break;
                }
            }
            else
            {
                nextPeriod = seedGrowComponent.currCropPeriod;
            }

            seedGrowComponent.SetPeriod(nextPeriod, (long)remainTime * 1000);
            //化肥数量-1
            StaticData.UpdateFertilizerMinus1(currFertilizerData.GoodId);
        }, (error) =>
        {
            //关闭UI
            uiWorldHandleManager.SetHandleTileUIClose();
        });
    }