Ejemplo n.º 1
0
    public override void DrawCell(int i, int index, int count = 0)
    {
        base.DrawCell(i, index, count);
        var dataList = dynamicPackage.GetFilteredTradeInfoList();

        if (mIndex >= dataList.Count)
        {
            return;
        }
        NTradeInfo tradeInfo = dataList[mIndex];
        ITEM_RES   config    = itemPackage.GetItemDataByConfigID(tradeInfo.configID);

        nameLabel.text        = config.MinName;
        iconSprite.spriteName = config.IconName;
        NItemInfo info = itemPackage.GetItemInfo(tradeInfo.configID);

        if (info == null)
        {
            numLabel.text = "0";
        }
        else
        {
            numLabel.text = GlobalFunction.NumberFormat(info.number);
        }
    }
Ejemplo n.º 2
0
    void OnReceive(NetMsgDef msg)
    {
        TSCReceive receive    = TSCReceive.ParseFrom(msg.mBtsData);
        long       buildingID = receive.BuildingId;
        int        configID   = receive.ConfigId;
        int        num        = receive.Number;

        sanctuaryPackage.Receive(buildingID, receive);
        NBuildingInfo info = sanctuaryPackage.GetBuildingInfo(buildingID);

        if (sanctuaryPackage.GetBuildingFuncByConfigID(info.configID) == BuildingFunc.Craft)
        {
            SendEvent("RefreshCraftPanel");
        }
        NDictionary data = new NDictionary();

        if (configID == 0)   //elec
        {
            string content = string.Format("获得电力 x {0}", num);
            data.Add("content", content);
        }
        else
        {
            ITEM_RES itemConfig = itemPackage.GetItemDataByConfigID(configID);
            string   content    = string.Format("获得{0} x {1}", itemConfig.MinName, num);
            data.Add("content", content);
        }
        //info.number = Mathf.Max(0, info.number - num);
        //info.building.SetCollect(false);
        info.building.RefreshHud();
        FacadeSingleton.Instance.OpenUtilityPanel("UITipsPanel");
        FacadeSingleton.Instance.SendEvent("OpenTips", data);
        FacadeSingleton.Instance.InvokeService("RPCGetResourceInfo", ConstVal.Service_Sanctuary);
    }
Ejemplo n.º 3
0
    //get item history price
    public void CalculateGraphInfo(int configID, long startTime, long curTime)
    {
        mGraphInfoList.Clear();
        EventPackage           eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage;
        ItemPackage            itemPackage  = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage;
        ITEM_RES               itemConfig   = itemPackage.GetItemDataByConfigID(configID);
        List <NWorldEventInfo> eventList    = eventPackage.GetHistoryEventList();
        string itemKeyName = itemConfig.KeyName;

        itemKeyName = char.ToUpper(itemKeyName[0]) + itemKeyName.Substring(1).ToLower();

        //reflection
        System.Type  type = System.Type.GetType("com.nkm.framework.resource.data." + "WORLD_EVENTS");
        PropertyInfo itemPriceProperty = type.GetProperty(itemKeyName);
        PropertyInfo itemHasProperty   = type.GetProperty("Has" + itemKeyName);

        NGraphNode preNode = null;
        NGraphNode node    = null;

        //add start node
        node       = new NGraphNode();
        node.price = (double)itemConfig.GoldConv / 1000d;
        node.time  = startTime;
        mGraphInfoList.Add(node);

        for (int i = 0; i < eventList.Count; i++)
        {
            NWorldEventInfo info        = eventList[i];
            WORLD_EVENTS    eventConfig = eventPackage.GetEventConfigDataByConfigID(info.configID);
            bool            isHas       = (bool)itemHasProperty.GetValue(eventConfig, null);
            if (!isHas)
            {
                continue;
            }
            double priceArgs = System.Convert.ToDouble(itemPriceProperty.GetValue(eventConfig, null)) / 100;

            if (info.happenTime <= startTime)
            {
                node        = mGraphInfoList[0];
                node.price *= priceArgs;
            }
            else
            {
                preNode = mGraphInfoList[mGraphInfoList.Count - 1];
                node    = new NGraphNode();
                if (info.isHappen)
                {
                    node.price = preNode.price * priceArgs;
                }
                else
                {
                    node.price = preNode.price / priceArgs;
                }
                mGraphInfoList.Add(node);
            }
        }
    }
Ejemplo n.º 4
0
    void InitView(NDictionary data = null)
    {
        configID = itemPackage.GetSelectionItemConfigID();
        isBuy    = data.Value <bool>("isbuy");
        ITEM_RES config = itemPackage.GetItemDataByConfigID(configID);

        if (isBuy)
        {
            titleLabel.text = string.Format("购买 {0}", config.MinName);
            double price   = itemPackage.GetItemPrice(configID);
            double curGold = itemPackage.GetGoldNumber();
            double tax     = itemPackage.GetTaxRate();
            itemCap       = Mathf.Min(itemPackage.GetBuyLimit(configID), (int)(curGold / (price * (1 + tax))));
            btnLabel.text = "购买";
        }
        else
        {
            NItemInfo info = itemPackage.GetItemInfo(configID);
            titleLabel.text = string.Format("出售 {0}", config.MinName);
            itemCap         = info.number;
            if (itemCap <= 0)
            {
                ITEM_RES test = itemPackage.GetItemDataByConfigID(info.configID);
                print(string.Format("{0}'s number is zero", test.MinName));
            }
            btnLabel.text = "出售";
        }
        if (config.GoldConv >= 1000)
        {
            ratio = 1;
        }
        else
        {
            ratio = 1000 / config.GoldConv;
        }
        itemCap = AdjustCap(ratio, itemCap);

        value                = 0;
        slider.value         = 0f;
        slider.numberOfSteps = (int)Mathf.Ceil((float)itemCap / (float)ratio) + 1;
        UpdateValueView();
    }
Ejemplo n.º 5
0
    void SetIcon(int configID)
    {
        ItemPackage itemPackge = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage;

        if (configID == 0)       //elec
        {
            iconSprite.spriteName = "electricity";
        }
        else
        {
            ITEM_RES config = itemPackge.GetItemDataByConfigID(configID);
            iconSprite.spriteName = config.IconName;
        }
    }
Ejemplo n.º 6
0
    void SellItemResponce(NetMsgDef msg)
    {
        TSCSellGoods res = TSCSellGoods.ParseFrom(msg.mBtsData);
        string       content;

        if (res.IsChange == true)
        {
            content = "价格已改变, 请重新操作";
            FacadeSingleton.Instance.InvokeService("RPCGetItemTradeInfo", ConstVal.Service_Sanctuary);
        }
        else
        {
            ITEM_RES config = itemPackage.GetItemDataByConfigID(res.ConfigId);
            double   price  = itemPackage.GetItemPrice(res.ConfigId);
            content = string.Format("出售{0} x {1}单位\n获得黄金{2}", config.MinName, res.Number, price * res.Number);
            FacadeSingleton.Instance.InvokeService("RPCGetResourceInfo", ConstVal.Service_Sanctuary);
        }
        FacadeSingleton.Instance.OpenUtilityPanel("UIMsgBoxPanel");
        NDictionary args = new NDictionary();

        args.Add("content", content);
        args.Add("method", 1);
        SendEvent("OpenMsgBox", args);
    }
Ejemplo n.º 7
0
    public override void DrawCell(int index, int count = 0)
    {
        int              dataIndex    = index;
        UICostResPanel   panel        = FacadeSingleton.Instance.RetrievePanel("UICostResPanel") as UICostResPanel;
        List <NItemInfo> costInfoList = panel.GetCostInfoList();

        if (costInfoList == null)
        {
            return;
        }
        NItemInfo   info        = costInfoList[dataIndex];
        ItemPackage itemPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage;

        nameLabel.text  = itemPackage.GetItemDataByConfigID(info.configID).MinName;
        valueLabel.text = info.number.ToString();
    }
Ejemplo n.º 8
0
    void InitView()
    {
        NItemInfo info       = itemPackage.GetSelectionItem();
        ITEM_RES  configData = itemPackage.GetItemDataByConfigID(info.configID);

        nameLabel.text        = configData.MinName;
        numLabel.text         = info.number.ToString();
        descLabel.text        = configData.Desc;
        iconSprite.spriteName = configData.IconName;
        if (configData.IfAvailable == 1)
        {
            ShowEffect(configData.Id);
        }
        else
        {
            tableView.DataCount = 0;
            tableView.TableChange();
        }
    }
Ejemplo n.º 9
0
    void ShowCost(BUILDING configData)
    {
        int count = 0;

        //show gold & elec
        if (configData.GoldCost > 0)
        {
            int    costNum = configData.GoldCost;
            double curNum  = itemPackage.GetGoldNumber();
            costCellList[count].title.text = "黄金消耗: ";
            costCellList[count].value.text = string.Format("{0} / {1}", GlobalFunction.NumberFormat(costNum), GlobalFunction.NumberFormat(curNum));
            costCellList[count].go.SetActive(true);
            if ((double)costNum > curNum)
            {
                costCellList[count].title.color = Color.red;
                costCellList[count].value.color = Color.red;
            }
            else
            {
                costCellList[count].title.color = Color.white;
                costCellList[count].value.color = Color.white;
            }
            count++;
        }
        if (configData.ElecCost > 0)
        {
            int    costNum = configData.ElecCost;
            double curNum  = itemPackage.GetElecNumber();
            costCellList[count].title.text = "电力消耗: ";
            costCellList[count].value.text = string.Format("{0} / {1}", GlobalFunction.NumberFormat(costNum), GlobalFunction.NumberFormat(curNum));
            costCellList[count].go.SetActive(true);
            if ((double)costNum > curNum)
            {
                costCellList[count].title.color = Color.red;
                costCellList[count].value.color = Color.red;
            }
            else
            {
                costCellList[count].title.color = Color.white;
                costCellList[count].value.color = Color.white;
            }
            count++;
        }
        for (int i = 0; i < configData.CostTableCount; i++)
        {
            int itemConfigId = configData.GetCostTable(i).CostId;
            if (itemConfigId == 0)
            {
                continue;
            }
            int       num      = configData.GetCostTable(i).CostQty;
            ITEM_RES  itemData = itemPackage.GetItemDataByConfigID(itemConfigId);
            NItemInfo itemInfo = itemPackage.GetItemInfo(itemConfigId);
            int       curNum   = itemInfo == null ? 0 : itemInfo.number;
            costCellList[count].title.text = itemData.MinName + ": ";
            costCellList[count].value.text = string.Format("{0} / {1}", num.ToString(), curNum);
            costCellList[count].go.SetActive(true);
            if (itemInfo == null || itemInfo.number < num)
            {
                costCellList[count].title.color = Color.red;
                costCellList[count].value.color = Color.red;
            }
            else
            {
                costCellList[count].title.color = Color.white;
                costCellList[count].value.color = Color.white;
            }
            count++;
        }
        for (; count < 5; count++)
        {
            costCellList[count].go.SetActive(false);
        }
    }
Ejemplo n.º 10
0
    public override void DrawCell(int index, int count = 0)
    {
        base.DrawCell(index, count);
        var      dataList = sanctuaryPackage.GetBuildingCostList();
        NCostDef cost     = dataList[index];
        bool     isEnough = true;

        if (cost.configID == 1)
        {
            nameLabel.text  = string.Format("庄园等级限制:");
            valueLabel.text = string.Format("{0}/{1}", cost.value, userPackage.GetManorLevel());
            if (userPackage.GetManorLevel() < cost.value)
            {
                isEnough = false;
            }
        }
        else if (cost.configID == 2)
        {
            nameLabel.text  = string.Format("黄金:");
            valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemPackage.GetGoldNumber()));
            if (itemPackage.GetGoldNumber() < cost.value)
            {
                isEnough = false;
            }
        }
        else if (cost.configID == 3)
        {
            nameLabel.text  = string.Format("电力:");
            valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemPackage.GetElecNumber()));
            if (itemPackage.GetElecNumber() < cost.value)
            {
                isEnough = false;
            }
        }
        else
        {
            ITEM_RES itemData = itemPackage.GetItemDataByConfigID(cost.configID);
            if (itemData == null)
            {
                return;
            }
            nameLabel.text = string.Format("{0}:", itemData.MinName);
            NItemInfo itemInfo = itemPackage.GetItemInfo(cost.configID);
            if (itemInfo == null)
            {
                valueLabel.text = string.Format("{0}/{1}", cost.value, 0);
                isEnough        = false;
            }
            else
            {
                valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemInfo.number));
                if (itemInfo.number < cost.value)
                {
                    isEnough = false;
                }
            }
        }
        if (isEnough)
        {
            nameLabel.color  = Color.white;
            valueLabel.color = Color.white;
        }
        else
        {
            nameLabel.color  = Color.red;
            valueLabel.color = Color.red;
        }
    }