Пример #1
0
    //设置第一阶段化肥
    public void SetFirstStageFertilizer(SeedGrowComponent seedGrowComponent)
    {
        ItemFirstStageFertilizerComponent willSetItemFirstStageFertilizerComponent = null;

        ItemFirstStageFertilizerComponent[] itemFirstStageFertilizers = TransGoFirstStageRoot.GetComponentsInChildren <ItemFirstStageFertilizerComponent>();
        bool isFind = false;

        for (int i = 0; i < itemFirstStageFertilizers.Length; i++)
        {
            if (itemFirstStageFertilizers[i].seedGrowComponent == null)
            {
                continue;
            }
            if (itemFirstStageFertilizers[i].seedGrowComponent.tileComponent.SoilId == seedGrowComponent.tileComponent.SoilId)
            {
                isFind = true;
                willSetItemFirstStageFertilizerComponent = itemFirstStageFertilizers[i];
                break;
            }
        }
        if (isFind)
        {
            SetWorldPos(willSetItemFirstStageFertilizerComponent.seedGrowComponent.tileComponent, willSetItemFirstStageFertilizerComponent.gameObject, TypePointUI.FirstFertilizer);
        }
        else
        {
            //实例化
            GameObject goFirstStage = GameObject.Instantiate <GameObject>(GoFirstStageFertilizer);
            goFirstStage.transform.SetTransformDefalutWithParent(TransGoFirstStageRoot);
            willSetItemFirstStageFertilizerComponent = goFirstStage.GetComponent <ItemFirstStageFertilizerComponent>();
            willSetItemFirstStageFertilizerComponent.seedGrowComponent = seedGrowComponent;
            //设置屏幕位置
            SetWorldPos(willSetItemFirstStageFertilizerComponent.seedGrowComponent.tileComponent, goFirstStage, TypePointUI.FirstFertilizer);
        }
    }
Пример #2
0
    //有收获的 创建图标
    public void CreateSteal(SeedGrowComponent seedGrowComponent)
    {
        var listStealComponent = GetListItemStealComponent();
        UIGoStealComponent uiItemStealComponent = null;

        if (listStealComponent != null && listStealComponent.Count > 0)
        {
            uiItemStealComponent = listStealComponent.Find(x => x.SoildId == seedGrowComponent.tileComponent.SoilId);
        }

        if (uiItemStealComponent != null)
        {
            uiItemStealComponent.gameObject.SetActive(true);
        }
        else
        {//创建
            var itemSteal = GameObject.Instantiate(goSteal);
            itemSteal.transform.SetTransformDefalutWithParentNotStretch(transParentGoSteal);
            itemSteal.SetActive(false);
            //第一次设置好位置后打开
            SetWorldPos(seedGrowComponent.tileComponent, itemSteal, TypePointUI.Steal);
            itemSteal.SetActive(true);
            itemSteal.GetComponent <UIGoStealComponent>().SetSeedGrowComponent(seedGrowComponent);
        }
    }
Пример #3
0
 public void RemoveFromListSeedGrow(SeedGrowComponent seedGrow)
 {
     if (ListSeedGrow.Contains(seedGrow))
     {
         ListSeedGrow.Remove(seedGrow);
     }
 }
Пример #4
0
 public void AddListSeedGrow(SeedGrowComponent seedGrow)
 {
     if (!ListSeedGrow.Contains(seedGrow))
     {
         ListSeedGrow.Add(seedGrow);
     }
 }
Пример #5
0
 internal void SetSeedGrowComponent(SeedGrowComponent seedGrowComponent)
 {
     this.seedGrowComponent = seedGrowComponent;
     ButtonGain.onClick.RemoveAllListeners();
     ButtonGain.onClick.AddListener(() => {
         StaticData.GetUIWorldHandleComponent().OnButtonGainClick(seedGrowComponent);
     });
 }
Пример #6
0
    //获取成熟期的一个地块
    public SeedGrowComponent GetTileRipe()
    {
        SeedGrowComponent ripe = null;

        if (ListSeedGrow != null && ListSeedGrow.Count > 0)
        {
            ripe = ListSeedGrow.Find(x => x.currCropPeriod == SeedGrowComponent.PeriodGrow.Ripe);
        }
        return(ripe);
    }
Пример #7
0
    //获取种子期的一个地块
    public SeedGrowComponent GetTileSeed()
    {
        SeedGrowComponent seed = null;

        if (ListSeedGrow != null && ListSeedGrow.Count > 0)
        {
            seed = ListSeedGrow.Find(x => x.currCropPeriod == SeedGrowComponent.PeriodGrow.Seed);
        }
        return(seed);
    }
Пример #8
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);
            }
        });
    }
Пример #9
0
    internal void SetGrowUpInfo(TileComponent tileComponent, SeedGrowComponent seedGrowComponent)
    {
        this.seedGrowComponent = seedGrowComponent;
        currClickComponent     = tileComponent;
        var cropDefine = StaticData.configExcel.GetManorCropByCropId(tileComponent.CropGoodId);

        seedName = StaticData.GetMultiLanguageByGameItemId(cropDefine.IdGainGameItem);
        if (Root2dSceneManager._instance.isFriendManor)
        {
            isShowGrowUpUIFriendManor = true;
            SetWorldPos(tileComponent, goGrowUpFriendManor, TypePointUI.GrowUp);
        }
        else
        {
            if (!isFertiliezeringAnimPlay)
            {
                SetWorldPos(tileComponent, SelfGrowUpComponent.gameObject, TypePointUI.GrowUp);
                SelfGrowUpComponent.seedGrowComponent = seedGrowComponent;
                isShowGrowUpUI = true;
            }
        }
    }
Пример #10
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;
        });
    }
Пример #11
0
    public async UniTask OnTileClick()
    {
        UIManorComponent uiManorComponent = UIComponent.GetComponentHaveExist <UIManorComponent>(UIType.UIManor);

        switch (typeTile)
        {
        case TypeManorDecorate.None:
            if (isNPC)
            {
                //todo 说话
            }
            break;

        case TypeManorDecorate.GiftBox:
            break;

        case TypeManorDecorate.DogHouse:
            break;

        case TypeManorDecorate.Tile:
            if (goTileClickFrame != null)
            {
                goTileClickFrame.SetActive(true);
            }
            //if (!Root2dSceneManager._instance.isFriendManor)
            //{//不是好友,等女主移动到位置,好友庄园不需要移动
            //    var tileCom = await Root2dSceneManager._instance.femaleManorManager.PlayAnim(this);
            //    if (tileCom != this)
            //    {
            //        return;
            //    }
            //}
            if (currGoPlant == null)
            {    //没有种植东西
                 //播放音效点击
                GameSoundPlayer.Instance.PlaySoundEffect(MusicHelper.SoundEffectClickPlot);
                if (!Root2dSceneManager._instance.isFriendManor)
                {    //不是好友庄园
                    StaticData.GetUIWorldHandleComponent().OpenRootPlant(this);
                    //新手引导点击地块算完成
                    if (StaticData.isOpenGuide && GuideCanvasComponent._instance != null && GuideCanvasComponent._instance.isCurrStepGuiding)
                    {
                        //点击的时候只保存点击一块一步,不干扰后边两步
                        if (GuideCanvasComponent._instance.CurrExecuteGuideLittleStepDefine.Id == 10002)
                        {
                            GuideCanvasComponent._instance.SetLittleStepFinish();
                        }
                    }
                }
            }
            else
            {    //种植了东西
                //好友的东西在SetGrowUpInfo中判定
                SeedGrowComponent seedGrowComponent = transform.GetComponentInChildren <SeedGrowComponent>();
                if (seedGrowComponent.currCropPeriod == SeedGrowComponent.PeriodGrow.Ripe)
                {
                    if (!Root2dSceneManager._instance.isFriendManor)
                    {
                        StaticData.GetUIWorldHandleComponent().GainOneTile(seedGrowComponent);
                    }
                    else    //偷取
                    {
                        StaticData.GetUIWorldHandleComponent().OnButtonStealClick(seedGrowComponent);
                    }
                }
                else
                {
                    if (StaticData.GetUIWorldHandleComponent().isFertiliezeringAnimPlay)
                    {
                        return;
                    }
                    if (StaticData.GetUIWorldHandleComponent().isEradicating)
                    {
                        return;
                    }
                    //播放音效点击
                    GameSoundPlayer.Instance.PlaySoundEffect(MusicHelper.SoundEffectClickPlot);
                    //第二个时期
                    if (seedGrowComponent.currCropPeriod != SeedGrowComponent.PeriodGrow.Seed)
                    {
                        StaticData.GetUIWorldHandleComponent().SetGrowUpInfo(this, seedGrowComponent);
                    }
                    else
                    {
                        //直接算施肥
                        StaticData.GetUIWorldHandleComponent().ClickTileToFirstFertilizer(this);
                    }
                }
            }
            break;

        case TypeManorDecorate.Decorate:
            //if (!Root2dSceneManager._instance.isFriendManor)
            //{//不是好友,等女主移动到位置,好友庄园不需要移动
            //    var tileCom = await Root2dSceneManager._instance.femaleManorManager.PlayAnim(this);
            //    if (tileCom != this)
            //    {
            //        return;
            //    }
            //}
            if (!Root2dSceneManager._instance.isFriendManor)
            {
                StaticData.GetUIWorldHandleComponent().OpenRebackDecorate(this);
            }
            break;
        }
    }
Пример #12
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);
        });
    }
Пример #13
0
 public void OnButtonGainClick(SeedGrowComponent seedGrowComponent)
 {
     GainOneTile(seedGrowComponent);
 }