Ejemplo n.º 1
0
    /// <summary>
    /// 设置植物 土地和动物的状态
    /// </summary>
    /// <param name="landIndex"></param>
    /// <param name="state"></param>
    void SetPlantAndAnimalEntityState(int landIndex, int state, EntityType type)
    {
        foreach (var land in entityStateDic)
        {
            HomeEntityInfo info = land.Value;

            if (info.index == landIndex)
            {
                if (type == EntityType.EntityType_Plant || type == EntityType.EntityType_Animal)
                {
                    uint seedID = 0;
                    if (seedIndexDic.TryGetValue((uint)landIndex, out seedID))
                    {
                        SeedAndCubDataBase sdb = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(seedID);
                        if (sdb != null)
                        {
                            SetHomeEntityState(land.Key, state, sdb.indexID);
                            return;
                        }
                    }
                }
                else if (type == EntityType.EntityType_Soil)
                {
                    SetHomeEntityState(land.Key, state, landID);
                    return;
                }
            }
        }
    }
Ejemplo n.º 2
0
    void SetGainOrAtOnce()
    {
        if (DataManager.Manager <HomeDataManager>().CanGetLeftTime((int)(this.m_farmId + m_animalIndexStart)))
        {
            if (m_SeedIndexDic.ContainsKey(m_farmId + m_animalIndexStart))
            {
                SeedAndCubDataBase cubData = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(m_SeedIndexDic[m_farmId + m_animalIndexStart]);
                if (cubData != null)
                {
                    m_Icon.spriteName = cubData.icon;
                    m_lblName.text    = cubData.name;
                }
            }

            if (DataManager.Manager <HomeDataManager>().GetLeftTimeByIndex((int)(this.m_farmId + m_animalIndexStart)) == 0)
            {
                SetGainOrAtOnceBtn(true);
            }
            else
            {
                SetGainOrAtOnceBtn(false);

                this.m_nLeftTime = DataManager.Manager <HomeDataManager>().GetLeftTimeByIndex((int)(m_farmId + m_animalIndexStart));
                if (m_nLeftTime > 0)
                {
                    TimerAxis.Instance().KillTimer(HOMEANIMAL_TIMERID, this);
                    TimerAxis.Instance().SetTimer(HOMEANIMAL_TIMERID, 1000, this);
                }
                else
                {
                    TimerAxis.Instance().KillTimer(HOMEANIMAL_TIMERID, this);
                }
            }
        }
    }
Ejemplo n.º 3
0
 void AddPlantAndAnimalModel(HomePosInfo plant, uint leftTime, uint seedID, EntityType type = EntityType.EntityType_Plant)
 {
     if (seedID != 0)
     {
         CreatureSmallState st = GetPlantStateByLandData(seedID, leftTime);
         SeedAndCubDataBase db = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(seedID);
         if (db == null)
         {
             Log.Error("种子没找到");
             return;
         }
         IEntity sen = HomeScene.Instance.AddEntity(plant.index.ToString(), type, db.indexID, (int)st);
         if (sen != null)
         {
             sen.SendMessage(EntityMessage.EntityCommand_SetPos, new Vector3(plant.posX, 2.97f, -plant.posZ));
             HomeEntityInfo info = new HomeEntityInfo();
             info.index    = plant.index;
             info.state    = (int)st;
             info.type     = type;
             info.entityID = sen.GetUID();
             AddHomeEntity(sen.GetUID(), info);
             AddPlantAndAnimalRemainTime(plant.index, leftTime);
         }
     }
 }
Ejemplo n.º 4
0
    CreatureSmallState GetPlantStateByLandData(uint seedID, uint leftTime)
    {
        CreatureSmallState st  = CreatureSmallState.Seed;
        SeedAndCubDataBase sdb = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(seedID);

        if (sdb != null)
        {
            uint totalTime = sdb.growTime;

            if (leftTime > totalTime * 0.7f)                                   //70% -- 100% 种子
            {
                st = CreatureSmallState.Seed;
            }
            else if (leftTime > totalTime * 0.3 && leftTime < totalTime * 0.7) //30% -- 70% 幼苗
            {
                st = CreatureSmallState.Seeding;
            }
            else if (leftTime < totalTime * 0.3f && leftTime > 0)             // 0% -- 30%  成熟
            {
                st = CreatureSmallState.Ripe;
            }
            else if (leftTime == 0)
            {
                st = CreatureSmallState.CanGain;                             //可收获
            }
        }
        return(st);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// 通过[道具ID]二分快速查表
        /// </summary>
        /// <param name="itemID">道具ID</param>
        /// <returns></returns>
        public static SeedAndCubDataBase Query(this List <SeedAndCubDataBase> sorted, uint itemID)
        {
            var key = new SeedAndCubDataBase()
            {
                itemID = itemID
            };
            var comparer = new Comparer1();
            var index    = sorted.BinarySearch(key, comparer);

            return(index >= 0 ? sorted[index] : default(SeedAndCubDataBase));
        }
Ejemplo n.º 6
0
    void OnClickPlant(HomeEntityInfo info)
    {
        uint index = (uint)info.index;

        if (info.state != (int)CreatureSmallState.CanGain && info.state != (int)CreatureSmallState.None)
        {
            uint seedID = 0;
            if (seedIndexDic.TryGetValue(index, out seedID))
            {
                SeedAndCubDataBase sdb = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(seedID);
                if (sdb != null && sdb.type == 0)
                {
                    uint leftTime = 0;
                    if (plantAndAnimalRemainTimeDic.TryGetValue((int)index, out leftTime))
                    {
                        Double c = (double)leftTime / sdb.growUnitTime;
                        c = c * sdb.growUnitCostCoupons;
                        IncreaseDataBase idb = GameTableManager.Instance.GetTableItem <IncreaseDataBase>(1, (int)PlantFastRipeNum);
                        int count            = 0;
                        if (idb != null)
                        {
                            count = (int)Math.Ceiling(c * idb.increase);
                        }
                        Engine.Utility.Log.LogGroup("LC", "剩余时间:" + leftTime.ToString()
                                                    + "    立即成熟单位时长:" + sdb.growUnitTime
                                                    + "    基础单位费用:" + sdb.growUnitCostCoupons
                                                    + "    使用次数:" + PlantFastRipeNum
                                                    + "    涨  幅:" + idb.increase.ToString()
                                                    + "    元宝数:" + count.ToString());
                        if (HasEnoughDianJuan(count))
                        {
                            string tips = DataManager.Manager <TextManager>().GetLocalFormatText(114533, count);
                            TipsManager.Instance.ShowTipWindow(TipWindowType.CancelOk, tips, () =>
                            {
                                stImmediRipeHomeUserCmd_CS cmd = new stImmediRipeHomeUserCmd_CS();
                                cmd.land_id = index;
                                NetService.Instance.Send(cmd);
                                info.state = (int)CreatureSmallState.CanGain;
                            });
                        }
                        else
                        {
                            TipsManager.Instance.ShowTips("目前还没有通用充值界面,此处后期再做处理");
                        }
                    }
                }
            }
        }
        else if (info.state == (int)CreatureSmallState.CanGain)
        {
            this.GainOnePlant(info.index);
        }
    }
Ejemplo n.º 7
0
 public void InitSeedItem(SeedAndCubDataBase sdb)
 {
     if (sdb != null)
     {
         m_seedDataBase = sdb;
         UIItem.AttachParent(m_sprite_icon.transform, sdb.itemID);
         ItemDataBase db = GameTableManager.Instance.GetTableItem <ItemDataBase>(sdb.itemID);
         if (db != null)
         {
             m_itemDataBase        = db;
             m_label_seedname.text = db.itemName;
             float hour = sdb.growTime * 1.0f / 3600;
             m_label_ripetime.text = hour.ToString();
             int  level = MainPlayerHelper.GetPlayerLevel();
             bool bshow = level < db.useLevel ? true : false;
             ShowWaring(bshow);
         }
     }
 }
Ejemplo n.º 8
0
    public void OnSowLand(stSowHomeUserCmd_CS cmd)
    {
        AddSeedToDic(cmd.land_id, cmd.seed_id);
        HomePosInfo pos = GetPosInfoByIndex(landID, (int)cmd.land_id);

        if (pos != null)
        {
            SeedAndCubDataBase db = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(cmd.seed_id);
            if (db != null)
            {
                ItemDataBase idb = GameTableManager.Instance.GetTableItem <ItemDataBase>(cmd.seed_id);
                if (idb != null)
                {
                    TipsManager.Instance.ShowTipsById(114505, idb.itemName);
                    AddPlantAndAnimalModel(pos, db.growTime, cmd.seed_id);
                    SetLandEntityState((int)cmd.land_id, (int)LandState.Growing);
                    RefreshLandUI();
                }
            }
        }
        DataManager.Manager <UIPanelManager>().HidePanel(PanelID.PlantingPanel);
    }
Ejemplo n.º 9
0
    public void OnFeedAnimal(stFeedHomeUserCmd_CS cmd)
    {
        uint animalIndex = (uint)(cmd.land_id + animalIndexStart);

        AddSeedToDic(animalIndex, cmd.seed_id);
        HomePosInfo pos = GetAnimalPos((int)cmd.land_id);

        if (pos != null)
        {
            SeedAndCubDataBase db = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(cmd.seed_id);
            if (db != null)
            {
                ItemDataBase idb = GameTableManager.Instance.GetTableItem <ItemDataBase>(cmd.seed_id);
                if (idb != null)
                {
                    TipsManager.Instance.ShowTipsById(114505, idb.itemName);
                    AddPlantAndAnimalModel(pos, db.growTime, cmd.seed_id, EntityType.EntityType_Animal);
                    RefreshLandUI();
                }
            }
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 跟新商品展示信息
    /// </summary>
    void UpdatePurchaseInfo()
    {
        HomeTradeDataBase htDb = GameTableManager.Instance.GetTableItem <HomeTradeDataBase>(m_nSelectMallItemId);

        if (htDb == null)
        {
            Engine.Utility.Log.Error("Can Not Find Data !!!");
            return;
        }

        if (m_tradeType == ETradeType.ETradeType_Buy)
        {
            SeedAndCubDataBase data = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(htDb.itemID);//种子幼崽表中取
            if (data == null)
            {
                Engine.Utility.Log.Error("Can Not Find Data !!!");
                return;
            }

            m_label_MallItemName.text = data.name;
            m_label_MallItemDes.text  = data.des;
        }
        else
        {
            ItemDataBase data = GameTableManager.Instance.GetTableItem <ItemDataBase>(htDb.itemID);//item表中取
            if (data == null)
            {
                Engine.Utility.Log.Error("Can Not Find Data !!!");
                return;
            }

            m_label_MallItemName.text = data.itemName;
            m_label_MallItemDes.text  = data.description;
        }

        UpdatePurchaseNum();
    }
Ejemplo n.º 11
0
    /// <summary>
    /// 买格子数据刷新
    /// </summary>
    /// <param name="grid"></param>
    /// <param name="index"></param>
    private void OnUpdateGridData(UIGridBase grid, int index)
    {
        //买
        if (grid is UIHomeTradeBuyGrid)
        {
            if (index >= m_dicMallItem[m_nSelectTabId].Count)
            {
                Engine.Utility.Log.Error("Out Of Index !!!");
                return;
            }

            UIHomeTradeBuyGrid buyGrid = grid as UIHomeTradeBuyGrid;
            if (buyGrid == null)
            {
                return;
            }

            HomeTradeDataBase htDb = GameTableManager.Instance.GetTableItem <HomeTradeDataBase>(m_dicMallItem[m_nSelectTabId][index]);//大管家
            if (htDb == null)
            {
                Engine.Utility.Log.Error("Can Not Find Data !!!");
                return;
            }

            SeedAndCubDataBase data = GameTableManager.Instance.GetTableItem <SeedAndCubDataBase>(htDb.itemID);//种子幼崽表中取
            if (data == null)
            {
                Engine.Utility.Log.Error("Can Not Find Data !!!");
                return;
            }

            buyGrid.SetGridData(htDb.indexId);
            buyGrid.SetIcon(data.icon);
            buyGrid.SetName(data.name);
            buyGrid.SetNum(htDb.pileNum);                                    //叠加数量
            buyGrid.SetPrice((GameCmd.MoneyType)htDb.moneyType, htDb.price); //现在的价格
            bool select = (htDb.indexId == m_nSelectMallItemId) ? true : false;
            buyGrid.SetHightLight(select);
            //buyGrid.SetTag("");
        }
        //卖
        else if (grid is UIHomeTradeSellGrid)
        {
            if (index >= m_dicMallItem[m_nSelectTabId].Count)
            {
                Engine.Utility.Log.Error("Out Of Index !!!");
                return;
            }

            UIHomeTradeSellGrid sellGrid = grid as UIHomeTradeSellGrid;
            if (sellGrid == null)
            {
                return;
            }

            HomeTradeDataBase htDb = GameTableManager.Instance.GetTableItem <HomeTradeDataBase>(m_dicMallItem[m_nSelectTabId][index]);
            if (htDb == null)
            {
                Engine.Utility.Log.Error("Can Not Find Data !!!");
                return;
            }

            ItemDataBase data = GameTableManager.Instance.GetTableItem <ItemDataBase>(htDb.itemID);//item表中取
            if (data == null)
            {
                Engine.Utility.Log.Error("Can Not Find Data !!!");
                return;
            }

            CropLivestock cropLivestock = m_dicCropLivestock[data.itemID];

            sellGrid.SetGridData(htDb.indexId);
            sellGrid.SetIcon(data.itemIcon);
            sellGrid.SetName(data.itemName);
            sellGrid.SetNum(htDb.pileNum);                                                                                                             //叠加数量
            sellGrid.SetPrice((GameCmd.MoneyType)htDb.moneyType, (uint)cropLivestock.m_nPrice, cropLivestock.m_fPriceChangeRate, cropLivestock.m_bUp); //现在的价格
            bool select = (htDb.indexId == m_nSelectMallItemId) ? true : false;
            sellGrid.SetHightLight(select);
            //buyGrid.SetTag("");
        }
        //页签
        else if (grid is UITabGrid)
        {
            if (index > m_lstHomeTradeTab.Count)
            {
                Engine.Utility.Log.Error("Can Not Find Data !!!");
                return;
            }

            UITabGrid tabGrid = grid as UITabGrid;
            if (grid == null)
            {
                return;
            }

            tabGrid.SetGridData(m_lstHomeTradeTab[index]);
            tabGrid.SetName(m_dicHomeTradeTab[m_lstHomeTradeTab[index]]);
            bool select = m_lstHomeTradeTab[index] == m_nSelectTabId ? true : false;
            tabGrid.SetHightLight(select);
        }
    }