//lz-2016.08.09 点击ScriptItem事件
    private void ScriptItemEvent(int itemID, int scriptIndex)
    {
        if (!this.m_Formulas.ContainsKey(itemID) || scriptIndex >= this.m_Formulas[itemID].Count || scriptIndex < 0)
        {
            return;
        }

        //更改new的状态
        Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scriptIndex];
        Pathea.Replicator r = UIGraphControl.GetReplicator();
        if (null != r)
        {
            r.SetKnownFormulaFlag(knownFornula.id);
        }

        bool ok = ReDrawGraph(itemID, scriptIndex);

        if (ok)
        {
            _updateQueryGridItems(itemID);
            _setCompundInfo(itemID);
            // Add id to grap history
            FactoryReplicator.AddGraphHistory(itemID);
        }

        FactoryReplicator.m_MiddleContent.graphScrollBox.Reposition();
    }
 //lz-2016.08.08 通过ItemID找到所有可以合成这个Item的脚本
 private void AddScriptItemData(int itemID)
 {
     if (!this.m_Formulas.ContainsKey(itemID))
     {
         List <Pathea.Replicator.Formula> formulaList = Pathea.Replicator.Formula.Mgr.Instance.FindAllByProDuctID(itemID);
         if (null == formulaList || formulaList.Count <= 0)
         {
             return;
         }
         List <Pathea.Replicator.KnownFormula> knownFormulaList = new List <Replicator.KnownFormula>();
         for (int i = 0; i < formulaList.Count; i++)
         {
             Pathea.Replicator.KnownFormula knownFormula = UIGraphControl.GetReplicator().GetKnownFormula(formulaList[i].id);
             if (null != knownFormula)
             {
                 knownFormulaList.Add(knownFormula);
             }
         }
         ItemProto item = ItemProto.GetItemData(itemID);
         this.m_ItemDataList.Add(item);
         this.m_Formulas.Add(itemID, knownFormulaList);
     }
     if (this.m_Formulas.ContainsKey(itemID) && itemID != this.m_CurItemID)
     {
         this.UpdateCurItemScriptList(itemID);
         this.SelectFirstScritItem(false);
     }
 }
Exemple #3
0
    private bool ReDrawGraph(int itemID, int scirptIndex = 0)
    {
        if (mGraphCtrl == null)
        {
            return(false);
        }
        this.AddScriptItemData(itemID);
        if (!this.m_Formulas.ContainsKey(itemID) || scirptIndex >= this.m_Formulas[itemID].Count || scirptIndex < 0)
        {
            return(true);
        }
        if (mRootType == ItemLabel.Root.ISO)
        {
            // Iso
        }
        else
        {
            Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scirptIndex];
            Pathea.Replicator.Formula      ms           = knownFornula.Get();
            ItemProto item = this.m_ItemDataList.Find(a => a.id == itemID);

            if (ms == null || item == null)
            {
                return(false);
            }

            // 临时处理
            bool enable = (ms.workSpace != 0) ? true : false;
            mLbGraphInfo.enabled = enable;
            mLbGraphInfo.text    = enable ? PELocalization.GetString(8000151) : "";

            mGraphCtrl.ClearGraph();

            int level_v = 0;

            UIGraphNode root = mGraphCtrl.AddGraphItem(level_v, null, ms, item.icon, "Icon");
            root.mTipCtrl.SetToolTipInfo(ListItemType.mItem, itemID);
            root.mCtrl.ItemClick += this.GraphItemOnClick;

            this.m_CurScriptMatIDs.Clear();
            for (int j = 0; j < ms.materials.Count; j++)
            {
                if (ms.materials[j].itemId != 0)
                {
                    this.m_CurScriptMatIDs.Add(ms.materials[j].itemId);
                    ItemProto   item2 = ItemProto.GetItemData(ms.materials[j].itemId);
                    UIGraphNode node  = mGraphCtrl.AddGraphItem(level_v, root, null, item2.icon, "Icon");
                    node.mTipCtrl.SetToolTipInfo(ListItemType.mItem, ms.materials[j].itemId);
                    node.mCtrl.ItemClick += this.GraphItemOnClick;
                }
            }

            UpdateItemsTrackState(ms);
        }
        mGraphCtrl.DrawGraph();
        return(true);
    }
Exemple #4
0
    //lz-2016.08.08 点击ScriptItem事件
    private void ScriptItemEvent(int itemID, int scriptIndex)
    {
        if (!this.m_Formulas.ContainsKey(itemID) || scriptIndex >= this.m_Formulas[itemID].Count || scriptIndex < 0)
        {
            return;
        }

        //更改new的状态
        Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scriptIndex];
        Pathea.Replicator r = replicator;
        if (null != r)
        {
            r.SetKnownFormulaFlag(knownFornula.id);
        }


        //颜色根据选的脚本改变
        List <GameObject> ListItems = m_LeftList.Gos;

        if (mListSelectedIndex >= 0 && mListSelectedIndex < ListItems.Count)
        {
            Pathea.Replicator.Formula formula = knownFornula.Get();
            bool  isInColony = (formula.workSpace != 0) ? true : false;
            Color textColor  = isInColony ? Color.red : Color.white;
            UICompoundWndListItem listItem = ListItems[mListSelectedIndex].GetComponent <UICompoundWndListItem>();
            listItem.SetTextColor(textColor);
        }

        //绘制当前选择的脚本和Item
        bool ok = ReDrawGraph(itemID, scriptIndex);

        if (ok)
        {
            AddGraphResetList(itemID);
            SetBottomInfo();
            QueryGridItems(itemID);
        }
    }
    // ---------------------------------
    //  Func
    // ---------------------------------

    private bool ReDrawGraph(int itemID, int scirptIndex = 0)
    {
        if (FactoryReplicator == null)
        {
            return(false);
        }
        this.AddScriptItemData(itemID);
        if (!this.m_Formulas.ContainsKey(itemID) || scirptIndex >= this.m_Formulas[itemID].Count || scirptIndex < 0)
        {
            return(true);
        }

        UIGraphControl graph_ctrl = FactoryReplicator.m_MiddleContent.graphCtrl;

        if (m_RootType == ItemLabel.Root.ISO)
        {
            // Iso
        }
        else
        {
            if (itemID != -1)
            {
                //Pathea.Replicator.Formula ms = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(m_id);

                Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scirptIndex];
                Pathea.Replicator.Formula      ms           = knownFornula.Get();
                ItemProto item = this.m_ItemDataList.Find(a => a.id == itemID);

                if (ms == null || item == null)
                {
                    return(false);
                }

                FactoryReplicator.ClearGraph();

                int level_v = 0;

                UIGraphNode root = graph_ctrl.AddGraphItem(level_v, null, ms, item.icon, "Icon");
                root.mTipCtrl.SetToolTipInfo(ListItemType.mItem, itemID);
                root.mCtrl.ItemClick += this.OnGraphItemClick;


                for (int j = 0; j < ms.materials.Count; j++)
                {
                    if (ms.materials[j].itemId != 0)
                    {
                        ItemProto item2   = ItemProto.GetItemData(ms.materials[j].itemId);
                        string[]  strico2 = item2.icon;

                        UIGraphNode node = graph_ctrl.AddGraphItem(level_v, root, null, strico2, "Icon");
                        node.mTipCtrl.SetToolTipInfo(ListItemType.mItem, ms.materials[j].itemId);
                        node.mCtrl.ItemClick += this.OnGraphItemClick;
                    }
                }
                UpdateItemsTrackState(ms);
            }
        }
        //		graph_ctrl.DrawGraph();
        FactoryReplicator.DrawGraph();
        return(true);
    }