public int GetFertilizerByPeriod(SeedGrowComponent.PeriodGrow period) { List <int> Fertilizers = StaticData.configExcel.GetVertical().StageRelation; int propId = Fertilizers[0]; switch (period) { case SeedGrowComponent.PeriodGrow.Seed: propId = Fertilizers[0]; break; case SeedGrowComponent.PeriodGrow.Germinate: propId = Fertilizers[1]; break; case SeedGrowComponent.PeriodGrow.GrowUp: propId = Fertilizers[2]; break; } return(propId); }
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(); }); }
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(); } }
//庄园一键浇水 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(); } }); }
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(); }); }