Пример #1
0
    void OnBlockPatternClick(int index)
    {
        if (PEBuildingMan.Self == null)
        {
            return;
        }

        if (!mWndCtrl.mBlockPatternList[index].IsActive)
        {
            //lz-2016.10.31 Insufficient skill to use this item.
            new PeTipMsg(PELocalization.GetString(8000854), PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
            return;
        }


        int i = 0;

        foreach (var kvp in BSPattern.s_tblPatterns)
        {
            if (i == index)
            {
                if (mWndCtrl.BlockMatSelectIndex == -1)
                {
                    // Voxel Mat is selected ?  Swicth it to block mat !
                    if (mWndCtrl.TextureListSelectIndex != -1)
                    {
                        int itemId = mWndCtrl.mVoxelMatList[mWndCtrl.TextureListSelectIndex].ItemId;
                        PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(itemId);
                        int find_index = mWndCtrl.mBlockMatList.FindIndex(item0 => item0.ItemId == itemId);
                        if (find_index != -1)
                        {
                            mWndCtrl.BlockMatSelectIndex = find_index;
                        }
                        else
                        {
                            mWndCtrl.BlockMatSelectIndex = 0;
                        }

                        mWndCtrl.DisselectVoxel();
                    }
                    else
                    {
                        PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(mWndCtrl.mBlockMatList[0].ItemId);
                        mWndCtrl.BlockMatSelectIndex = 0;
                    }
                }
                ItemAsset.ItemProto item = ItemAsset.ItemProto.GetItemData(mWndCtrl.mBlockMatList[mWndCtrl.BlockMatSelectIndex].ItemId);
                if (!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckBuildBlockLevel(item.level))
                {
                    PEBuildingMan.Self.Manipulator.MaterialType = 2;
                }
                PEBuildingMan.Self.Pattern = kvp.Value;

                ChangeBrushToBox();
                break;
            }
            i++;
        }
    }
Пример #2
0
        public static ESlotType GetSlotType(int prototypeId)
        {
            ItemProto itemData = ItemProto.GetItemData(prototypeId);

            if (null == itemData)
            {
                return(ItemAsset.ItemPackage.ESlotType.Max);
            }

            return((ItemAsset.ItemPackage.ESlotType)itemData.tabIndex);
        }
Пример #3
0
    void OnInitMenuList()
    {
        // Menu List
        UISkillWndCtrl uiSkill = GameUI.Instance.mSkillWndCtrl;

        if (uiSkill == null)
        {
            return;
        }

        foreach (UIBuildWndItem item in mMenuCtrl.mMenuList)
        {
            if (item.mTargetItemType == UIBuildWndItem.ItemType.mBlockMat)
            {
                ItemAsset.ItemProto proto = ItemAsset.ItemProto.GetItemData(item.ItemId);

                if (uiSkill._SkillMgr != null)
                {
                    if (!uiSkill._SkillMgr.CheckBuildBlockLevel(proto.level))
                    {
                        item.IsActive = false;
                    }
                    else
                    {
                        item.IsActive = true;
                    }
                }
            }
            else if (item.mTargetItemType == UIBuildWndItem.ItemType.mBlockPattern)
            {
                int index = item.mTargetIndex;

                if (uiSkill._SkillMgr != null)
                {
                    if (!uiSkill._SkillMgr.CheckBuildShape(index))
                    {
                        item.IsActive = false;
                    }
                    else
                    {
                        item.IsActive = true;
                    }
                }
            }
        }
    }
Пример #4
0
    public bool isCanCreate( )
    {
        if (mGraphItemList.Count == 0)
        {
            return(false);
        }

        Pathea.Replicator r = GetReplicator();
        if (null == r)
        {
            return(false);
        }

        Pathea.Replicator.Formula formula = Pathea.Replicator.Formula.Mgr.Instance.Find(rootNode.ms.id);
        if (null == formula)
        {
            return(false);
        }

        ItemAsset.ItemProto proto = ItemAsset.ItemProto.GetItemData(formula.productItemId);
        if (proto != null)
        {
            if (!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckUnlockProductItemLevel(proto.level))
            {
                return(false);
            }
            if (!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckUnlockProductItemType(proto.itemClassId))
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }

        if (r.MaxProductCount(rootNode.ms.id) < (rootNode.getCount / rootNode.ms.m_productItemCount))
        {
            return(false);
        }
        return(true);
    }
Пример #5
0
        static void InitEquipment(PeEntity entity, IEnumerable <int> equipmentItemProtoIds)
        {
            if (equipmentItemProtoIds == null)
            {
                return;
            }

            Pathea.EquipmentCmpt equipmentCmpt = entity.GetCmpt <Pathea.EquipmentCmpt>();
            if (null == equipmentCmpt)
            {
                Debug.LogError("no equipment cmpt");
                return;
            }

            PeSex entitySex = entity.ExtGetSex();

            foreach (int equipmentItemProtoId in equipmentItemProtoIds)
            {
                ItemAsset.ItemProto itemProto = ItemAsset.ItemProto.Mgr.Instance.Get(equipmentItemProtoId);
                if (itemProto == null)
                {
                    continue;
                }

                if (!PeGender.IsMatch(itemProto.equipSex, entitySex))
                {
                    continue;
                }

                ItemAsset.ItemObject itemObj = ItemAsset.ItemMgr.Instance.CreateItem(equipmentItemProtoId);
                if (itemObj != null)
                {
                    equipmentCmpt.PutOnEquipment(itemObj);
                }
            }
        }
Пример #6
0
    // On Skill Refresh
    void OnRefreshSkill(UISkillWndCtrl uiSkill)
    {
        if (!RandomMapConfig.useSkillTree)
        {
            return;
        }

        // Block Material
        foreach (UIBuildWndItem item in mWndCtrl.mBlockMatList)
        {
            ItemProto proto = ItemProto.Mgr.Instance.Get(item.ItemId);

            if (uiSkill._SkillMgr != null)
            {
                if (!uiSkill._SkillMgr.CheckBuildBlockLevel(proto.level))
                {
                    item.IsActive = false;
                }
                else
                {
                    item.IsActive = true;
                }
            }
        }

        // Block Pattern
        foreach (UIBuildWndItem item in mWndCtrl.mBlockPatternList)
        {
            int index = item.mIndex;

            if (uiSkill._SkillMgr != null)
            {
                if (!uiSkill._SkillMgr.CheckBuildShape(index))
                {
                    item.IsActive = false;
                }
                else
                {
                    item.IsActive = true;
                }
            }
        }

        // Menu List
        foreach (UIBuildWndItem item in mMenuCtrl.mMenuList)
        {
            if (item.mTargetItemType == UIBuildWndItem.ItemType.mBlockMat)
            {
                ItemAsset.ItemProto proto = ItemAsset.ItemProto.GetItemData(item.ItemId);

                if (uiSkill._SkillMgr != null)
                {
                    if (!uiSkill._SkillMgr.CheckBuildBlockLevel(proto.level))
                    {
                        item.IsActive = false;
                    }
                    else
                    {
                        item.IsActive = true;
                    }
                }
            }
            else if (item.mTargetItemType == UIBuildWndItem.ItemType.mBlockPattern)
            {
                int index = item.mTargetIndex;

                if (uiSkill._SkillMgr != null)
                {
                    if (!uiSkill._SkillMgr.CheckBuildShape(index))
                    {
                        item.IsActive = false;
                    }
                    else
                    {
                        item.IsActive = true;
                    }
                }
            }
        }
    }
Пример #7
0
 public bool Remove(ItemProto data)
 {
     return(mList.Remove(data));
 }
Пример #8
0
 public void Add(ItemProto data)
 {
     mList.Add(data);
 }
Пример #9
0
            void LoadProto()
            {
                SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("item_editor_type");

                while (reader.Read())
                {
                    ItemEditorType editorType = new ItemEditorType();
                    editorType.id = Convert.ToInt32(reader.GetString(reader.GetOrdinal("id")));

                    string   colorString = reader.GetString(reader.GetOrdinal("Colour"));
                    string[] colStrs     = colorString.Split(',');
                    editorType.color = new Color(Convert.ToSingle(colStrs[0]) / 255f,
                                                 Convert.ToSingle(colStrs[1]) / 255f,
                                                 Convert.ToSingle(colStrs[2]) / 255f,
                                                 Convert.ToSingle(colStrs[3]) / 255f);
                    editorType.parentID = Convert.ToInt32(reader.GetString(reader.GetOrdinal("parentid")));
                    m_ItemEditorTypes[editorType.id] = editorType;
                }

                reader = LocalDatabase.Instance.ReadFullTable("WeaponInfo");
                Dictionary <int, WeaponInfo> weaponInfos = new Dictionary <int, WeaponInfo>();

                while (reader.Read())
                {
                    WeaponInfo weaponInfo = new WeaponInfo();
                    string     str        = reader.GetString(reader.GetOrdinal("AttackMode"));
                    weaponInfo.attackModes  = ConvertToAttackModes(str);
                    weaponInfo.useEnergry   = Convert.ToInt32(reader.GetString(reader.GetOrdinal("UseEnergry"))) > 0;
                    weaponInfo.costItem     = Convert.ToInt32(reader.GetString(reader.GetOrdinal("CostItem")));
                    weaponInfo.costPerShoot = Convert.ToInt32(reader.GetString(reader.GetOrdinal("CostPerShoot")));
                    weaponInfos[Convert.ToInt32(reader.GetString(reader.GetOrdinal("ItemID")))] = weaponInfo;
                }

                reader = LocalDatabase.Instance.ReadFullTable("PrototypeItem");
                //skip first row
                reader.Read();

                mList = new List <ItemProto>();
                while (reader.Read())
                {
                    ItemProto protoItem = new ItemProto();
                    protoItem.id = Convert.ToInt32(reader.GetString(reader.GetOrdinal("id")));
                    //f_TD.name = reader.GetString(reader.GetOrdinal("_name"));
                    protoItem.level = Convert.ToInt32(reader.GetString(reader.GetOrdinal("itemlv")));
//                    protoItem.name = reader.GetString(reader.GetOrdinal("_engName"));
//                    protoItem.nameStringId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_nameID")));
                    protoItem.name = PELocalization.GetString(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_nameID"))));
                    if ("" == protoItem.name)
                    {
                        protoItem.name = reader.GetString(reader.GetOrdinal("_engName"));
                    }
                    protoItem.dragName  = PELocalization.GetString(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_dragnameID"))));
                    protoItem.itemLabel = Convert.ToByte(reader.GetString(reader.GetOrdinal("_typeId")));   // itemtype. for example: sword,ammo,ring,food,
                    protoItem.setUp     = Convert.ToByte(reader.GetString(reader.GetOrdinal("_setUp")));

                    protoItem.resourcePath  = reader.GetString(reader.GetOrdinal("_modelPath"));
                    protoItem.resourcePath1 = reader.GetString(reader.GetOrdinal("_logicPath"));

                    protoItem.shopIcon = reader.GetString(reader.GetOrdinal("servericon"));

                    string iconString = reader.GetString(reader.GetOrdinal("_iconId"));
                    if (!string.IsNullOrEmpty(iconString))
                    {
                        protoItem.icon = iconString.Split(',');
                    }
                    //f_TD.effectSoundId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effectSound")));
                    protoItem.placeSoundID = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_placeSound")));
                    //f_TD.m_Explain = reader.GetString(reader.GetOrdinal("_explain"));
                    protoItem.englishDescription  = "";//reader.GetString(reader.GetOrdinal("_engExplain"));
                    protoItem.descriptionStringId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_engExplain")));
                    //f_TD.m_AttachBone = reader.GetString(reader.GetOrdinal("_bindNode"));
                    protoItem.equipReplacePos  = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_replacePos")));
                    protoItem.durabilityFactor = Convert.ToSingle(reader.GetString(reader.GetOrdinal("durDec")));
                    protoItem.equipPos         = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_position")));
                    protoItem.buffId           = Convert.ToInt32(reader.GetString(reader.GetOrdinal("buffId")));
                    protoItem.skillId          = Convert.ToInt32(reader.GetString(reader.GetOrdinal("skillId")));
                    protoItem.towerEntityId    = Convert.ToInt32(reader.GetString(reader.GetOrdinal("turret_id")));
                    //f_TD.m_TaskID = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_taskId")));
                    protoItem.durabilityMax = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_durability")));

                    string tmp = reader.GetString(reader.GetOrdinal("_property"));
                    if (!string.IsNullOrEmpty(tmp) && tmp != InvalidStr)
                    {
                        string[] tmpArray = tmp.Split(',');
                        if (tmpArray.Length > 0)
                        {
                            foreach (string s in tmpArray)
                            {
                                string[] sArray = s.Split(':');
                                if (sArray.Length == 2 && sArray[0] == "EnergyMax")
                                {
                                    protoItem.engergyMax = Convert.ToInt32(sArray[1]);
                                }
                            }
                        }
                    }

                    protoItem.currencyValue  = Convert.ToInt32(reader.GetString(reader.GetOrdinal("currency_value")));
                    protoItem.currencyValue2 = Convert.ToInt32(reader.GetString(reader.GetOrdinal("currency_value2")));

                    //protoItem.disappearTime = Convert.ToSingle(reader.GetString(reader.GetOrdinal("disappear_time")));
                    protoItem.maxStackNum = Convert.ToInt32(reader.GetString(reader.GetOrdinal("stacking_num")));
                    protoItem.equipSex    = Pathea.PeGender.Convert(Convert.ToInt32(reader.GetString(reader.GetOrdinal("sex"))));
                    protoItem.tabIndex    = Convert.ToInt32(reader.GetString(reader.GetOrdinal("tab")));

                    //f_TD.m_OpType = (ItemOperationType)Convert.ToInt32(reader.GetString(reader.GetOrdinal("_oprationType")));
                    protoItem.itemClassId = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_function")));
                    protoItem.equipType   = (EquipType)Convert.ToInt32(reader.GetString(reader.GetOrdinal("_WeaponType")));
                    protoItem.repairLevel = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_repair")));
                    //f_TD.bind = Convert.ToBoolean(Convert.ToInt32(reader.GetString(reader.GetOrdinal("bind"))));
                    protoItem.sortLabel = Convert.ToInt32(reader.GetString(reader.GetOrdinal("sort")));

                    string str = reader.GetString(reader.GetOrdinal("learn"));
                    if (str != InvalidStr)
                    {
                        string[] strList = str.Split(',');
                        protoItem.replicatorFormulaIds = new int[strList.Length];
                        for (int i = 0; i < strList.Length; i++)
                        {
                            protoItem.replicatorFormulaIds[i] = Convert.ToInt32(strList[i]);
                        }
                    }

                    protoItem.propertyList = PropertyList.LoadFromDb(reader);

                    str = reader.GetString(reader.GetOrdinal("_repairMax"));
                    protoItem.repairMaterialList = ConvertToMaterialItems(str);

                    str = reader.GetString(reader.GetOrdinal("_strengthen"));
                    protoItem.strengthenMaterialList = ConvertToMaterialItems(str);

                    str = reader.GetString(reader.GetOrdinal("bundle"));
                    protoItem.bundle    = Bundle.Load(str);
                    protoItem.category  = reader.GetString(reader.GetOrdinal("category"));
                    protoItem.isFormula = Convert.ToInt32(reader.GetString(reader.GetOrdinal("is_formula"))) != 0;
                    //f_TD.mPlayerStateActive = Convert.ToInt32(reader.GetOrdinal(23));
                    protoItem.editorTypeId = reader.GetInt32(reader.GetOrdinal("item_editor_type"));

                    protoItem.color = m_ItemEditorTypes[protoItem.editorTypeId].color;

                    //str = reader.GetString(reader.GetOrdinal("AttackMode"));
                    if (weaponInfos.ContainsKey(protoItem.id))
                    {
                        protoItem.weaponInfo = weaponInfos[protoItem.id];
                    }

                    mList.Add(protoItem);
                }
            }
Пример #10
0
        public static byte GetSetUp(int id)
        {
            ItemProto data = ItemProto.Mgr.Instance.Get(id);

            return((data != null) ? data.setUp : (byte)0);
        }
Пример #11
0
        public static string[] GetIconName(int id)
        {
            ItemProto data = ItemProto.Mgr.Instance.Get(id);

            return((data != null) ? data.icon : null);
        }
Пример #12
0
        public static string GetName(int id)
        {
            ItemProto data = ItemProto.Mgr.Instance.Get(id);

            return((data != null) ? data.name : "");
        }
Пример #13
0
        public static byte[] GetBuffer(ItemProto data)
        {
            if (null == data)
            {
                return(null);
            }

            using (MemoryStream ms = new MemoryStream())
                using (BinaryWriter bw = new BinaryWriter(ms))
                {
                    bw.Write(data.id);
                    bw.Write(data.itemLabel);
                    bw.Write(data.setUp);
                    //bw.Write(data.m_AttachBone);
                    bw.Write(data.equipPos);
                    bw.Write(data.buffId);
                    bw.Write(data.durabilityMax);
                    bw.Write(data.currencyValue);
                    bw.Write(data.currencyValue2);
                    bw.Write(data.maxStackNum);
                    bw.Write((int)data.equipSex);
                    bw.Write(data.tabIndex);
                    //bw.Write(data.actionSkill);
                    //bw.Write(data.playerStateActive);
                    //bw.Write((int)data.m_OpType);
                    bw.Write((int)data.equipType);
                    bw.Write(data.itemClassId);
                    bw.Write(data.sortLabel);
                    bw.Write(data.engergyMax);

                    if (data.propertyList == null)
                    {
                        bw.Write((int)0);
                    }
                    else
                    {
                        bw.Write(data.propertyList.GetCount());
                        foreach (PropertyList.PropertyValue v in data.propertyList)
                        {
                            bw.Write((int)v.type);
                            bw.Write(v.value);
                        }
                    }

                    //bw.Write(data.mEquipRandomProperty.Count);
                    //foreach (KeyValuePair<ItemProperty, float> kv in data.mEquipRandomProperty)
                    //{
                    //    bw.Write((int)kv.Key);
                    //    bw.Write(kv.Value);
                    //}

                    if (data.repairMaterialList == null)
                    {
                        bw.Write((int)0);
                    }
                    else
                    {
                        bw.Write(data.repairMaterialList.Count);
                        foreach (MaterialItem item in data.repairMaterialList)
                        {
                            bw.Write(item.protoId);
                            bw.Write(item.count);
                        }
                    }

                    if (data.strengthenMaterialList == null)
                    {
                        bw.Write((int)0);
                    }
                    else
                    {
                        bw.Write(data.strengthenMaterialList.Count);
                        foreach (MaterialItem item in data.strengthenMaterialList)
                        {
                            bw.Write(item.protoId);
                            bw.Write(item.count);
                        }
                    }
                    bw.Write(data.durabilityFactor);
                    bw.Flush();
                    return(ms.ToArray());
                }
        }