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(); }); }
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); } }); } }