Ejemplo n.º 1
0
 //施肥
 public static void UseFertilizer(CSFertilizer csFertilizer, Action <SCEmptFertilizer> ResponseSCEmptFertilizerCallBack, Action <ErrorInfo> errorCallBack)
 {
     if (StaticData.IsUsedLocalDataNotServer)
     {
         //测试
         SCEmptFertilizer SCEmptFertilizer = new SCEmptFertilizer();
         ResponseSCEmptFertilizerCallBack(SCEmptFertilizer);
     }
     else
     {
         ProtocalManager.Instance().SendCSFertilizer(csFertilizer, ResponseSCEmptFertilizerCallBack, errorCallBack, true);
     }
 }
Ejemplo n.º 2
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();
        });
    }
Ejemplo n.º 3
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();
        });
    }
Ejemplo n.º 4
0
        public void SendCSFertilizer(CSFertilizer csfertilizer, Action <SCEmptFertilizer> ResponseSCEmptFertilizerCallBack, Action <ErrorInfo> errorCallBack, bool isShowDefaultTip = true)
        {
            OpCodeType opCodeType = ListOPRelation.GetOpCodeTypeByRequest <CSFertilizer> ();

            ProtoSendMethod.BusinessRequest <SCEmptFertilizer>(csfertilizer, opCodeType, ResponseSCEmptFertilizerCallBack, errorCallBack, isShowDefaultTip);
        }