Exemple #1
0
    public void GetItemMaterialFromFactory(CSFactory factory, List <ItemIdCount> itemsNeedToGet, ref bool transferedItem)
    {
        foreach (ItemIdCount iic in itemsNeedToGet)
        {
            Replicator.KnownFormula[] msList = UIGraphControl.GetReplicator().GetKnowFormulasByProductItemId(iic.protoId);
            if (msList == null || msList.Length == 0)
            {
                continue;
            }

            Replicator.Formula ms = Replicator.Formula.Mgr.Instance.Find(msList[0].id);
            foreach (Replicator.Formula.Material mt in ms.materials)
            {
                int itemCount = factory.GetCompoundEndItemCount(mt.itemId);
                if (itemCount > 0)
                {
                    if (CSUtils.AddToStorage(mt.itemId, itemCount, core))
                    {
                        factory.CountDownItem(mt.itemId, itemCount);
                        transferedItem = true;
                    }
                }
            }
        }
    }
Exemple #2
0
    public static List <int> resolveProtoIdToProcess(List <int> protoIds)
    {
        List <int> resourceId = new List <int> ();

        foreach (int protoId in protoIds)
        {
            if (CSProcessing.CanProcessItem(protoId))
            {
                resourceId.Add(protoId);
                continue;
            }
            List <int> needReplicate = new List <int> ();
            needReplicate.Add(protoId);
            do
            {
                List <int> tempNeed = new List <int> ();
                tempNeed.AddRange(needReplicate);
                foreach (int tempProtoId in tempNeed)
                {
                    Replicator.KnownFormula[] msList = UIGraphControl.GetReplicator().GetKnowFormulasByProductItemId(tempProtoId);
                    if (msList == null || msList.Length == 0)
                    {
                        needReplicate.Remove(tempProtoId);
                        //Debug.LogError("can't get "+tempProtoId+" for colony");
                        continue;
                    }
                    //--to do: temp_ only use script 01
                    Replicator.Formula ms = Replicator.Formula.Mgr.Instance.Find(msList[0].id);
                    foreach (Replicator.Formula.Material mt in ms.materials)
                    {
                        if (CSProcessing.CanProcessItem(mt.itemId))
                        {
                            if (!resourceId.Contains(mt.itemId))
                            {
                                resourceId.Add(mt.itemId);
                            }
                        }
                        else
                        {
                            if (!needReplicate.Contains(mt.itemId))
                            {
                                needReplicate.Add(mt.itemId);
                            }
                        }
                    }
                    needReplicate.Remove(tempProtoId);
                }
            }while(needReplicate.Count > 0);
        }
        return(resourceId);
    }
Exemple #3
0
    public void ReplicateItem(ItemIdCount iic, List <int> replicatingItems, out List <ItemIdCount> materialList, out int productItemCount)
    {
        Replicator.KnownFormula[] msList = UIGraphControl.GetReplicator().GetKnowFormulasByProductItemId(iic.protoId);
        materialList     = new List <ItemIdCount> ();
        productItemCount = 0;
        if (msList == null || msList.Length == 0)
        {
            return;
        }

        //--to do: temp,only use formula 01?
        Replicator.Formula ms = Replicator.Formula.Mgr.Instance.Find(msList[0].id);
        foreach (Replicator.Formula.Material mt in ms.materials)
        {
            materialList.Add(new ItemIdCount(mt.itemId, mt.itemCount));
        }
        productItemCount = ms.m_productItemCount;
        int productCount = Mathf.CeilToInt(iic.count * 1.0f / ms.m_productItemCount);

        //2.replicate it and count down material in storage
        int countCanGet = CSUtils.GetMaterialListCount(materialList, Assembly);

        if (countCanGet == 0)
        {
            return;
        }
        if (countCanGet >= productCount)
        {
            if (SetCompoudItemAuto(iic.protoId, productCount * ms.m_productItemCount, ms.timeNeed * productCount))
            {
                iic.count = 0;
                foreach (ItemIdCount countDownItem in materialList)
                {
                    CSUtils.CountDownItemFromFactoryAndAllStorage(countDownItem.protoId, countDownItem.count * productCount, Assembly);
                }
                replicatingItems.Add(iic.protoId);
            }
        }
        else
        {
            if (SetCompoudItemAuto(iic.protoId, countCanGet * ms.m_productItemCount, ms.timeNeed * countCanGet))
            {
                iic.count -= countCanGet * ms.m_productItemCount;
                foreach (ItemIdCount countDownItem in materialList)
                {
                    CSUtils.CountDownItemFromFactoryAndAllStorage(countDownItem.protoId, countDownItem.count * countCanGet, Assembly);
                }
                replicatingItems.Add(iic.protoId);
            }
        }
    }
Exemple #4
0
    public static ItemProto StaticGenItemData(int obj_id, VCIsoHeadData headinfo, CreationAttr attr)
    {
        if (attr.m_Type == ECreation.Null)
        {
            return(null);
        }

        ItemProto item = new ItemProto();

        item.name = headinfo.Name;
//		item.nameStringId = 0;
        item.englishDescription = headinfo.Desc;
        item.itemLabel          = 100;
        item.setUp           = 0;
        item.resourcePath    = AssetsLoader.InvalidAssetPath;
        item.resourcePath1   = AssetsLoader.InvalidAssetPath;
        item.equipReplacePos = 0;
        item.currencyValue   = Mathf.CeilToInt(attr.m_SellPrice);
        item.currencyValue2  = Mathf.CeilToInt(attr.m_SellPrice);
        item.durabilityMax   = Mathf.CeilToInt(attr.m_Durability);
        item.repairLevel     = 1;
        item.maxStackNum     = 1;
        item.equipSex        = Pathea.PeSex.Undefined;
        item.id    = obj_id;
        item.level = 1;

        item.repairMaterialList     = new List <MaterialItem>(attr.m_Cost.Count);
        item.strengthenMaterialList = new List <MaterialItem>(attr.m_Cost.Count);

        Dictionary <int, int> repairItemDic = new Dictionary <int, int>();

        foreach (KeyValuePair <int, int> kvp in attr.m_Cost)
        {
            if (kvp.Value != 0)
            {
                Replicator.Formula formula = Replicator.Formula.Mgr.Instance.FindByProductId(kvp.Key);
                int itemID    = kvp.Key;
                int itemCount = kvp.Value;
                if (null == formula)
                {
                    if (repairItemDic.ContainsKey(itemID))
                    {
                        repairItemDic[itemID] += itemCount;
                    }
                    else
                    {
                        repairItemDic[itemID] = itemCount;
                    }
                }
                else
                {
                    for (int i = 0; i < formula.materials.Count; ++i)
                    {
                        itemID    = formula.materials[i].itemId;
                        itemCount = formula.materials[i].itemCount * Mathf.CeilToInt((float)kvp.Value / formula.m_productItemCount);
                        if (repairItemDic.ContainsKey(itemID))
                        {
                            repairItemDic[itemID] += itemCount;
                        }
                        else
                        {
                            repairItemDic[itemID] = itemCount;
                        }
                    }
                }
            }
        }

        foreach (KeyValuePair <int, int> kvp in repairItemDic)
        {
            int finalCount = kvp.Value / 2;
            if (finalCount > 0)
            {
                item.repairMaterialList.Add(new MaterialItem()
                {
                    protoId = kvp.Key, count = finalCount
                });
                item.strengthenMaterialList.Add(new MaterialItem()
                {
                    protoId = kvp.Key, count = finalCount
                });
            }
        }

        // [VCCase] - Generate item data, different types of creations
        switch (attr.m_Type)
        {
        // 剑 ------------------------
        case ECreation.Sword:

            item.equipType = EquipType.Sword;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos    = 16;
            item.itemClassId = (int)CreationItemClass.Sword;
            item.tabIndex    = 1;
            item.sortLabel   = 9910;
            //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100);
            item.durabilityFactor = 1f;
            item.editorTypeId     = 4;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack);
            item.buffId = 30200087;
            break;

        //双手与双持
        case ECreation.SwordLarge:
        case ECreation.SwordDouble:
            item.icon = new string[3] {
                "0", "0", "0"
            };
            item.equipPos    = 528;
            item.itemClassId = (int)CreationItemClass.Sword;
            item.tabIndex    = 1;
            item.sortLabel   = 9910;
            //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100);
            item.durabilityFactor = 1f;
            item.editorTypeId     = 4;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack);
            item.buffId = 30200087;
            break;

        // 弓 ------------------------
        case ECreation.Bow:
            item.equipType = EquipType.Bow;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos    = 528;
            item.itemClassId = (int)CreationItemClass.Bow;
            item.tabIndex    = 1;
            item.sortLabel   = 9914;
            //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100);
            item.durabilityFactor = 1f;
            item.editorTypeId     = 10;
            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack);
            item.buffId = 30200087;
            break;

        // 斧 ------------------------
        case ECreation.Axe:
            item.equipType = EquipType.Axe;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos    = 16;
            item.itemClassId = (int)CreationItemClass.Axe;
            item.tabIndex    = 1;
            item.sortLabel   = 9912;
            //item.level = Mathf.Clamp((int)((attr.m_Attack - 8f) / 2.5f), 1, 100);
            item.durabilityFactor = 1f;
            item.editorTypeId     = 7;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack * WhiteCat.PEVCConfig.instance.axeAttackScale);
            item.propertyList.AddProperty(Pathea.AttribType.CutDamage, attr.m_Attack * WhiteCat.PEVCConfig.instance.axeCutDamageScale);
            item.propertyList.AddProperty(Pathea.AttribType.CutBouns, 0.03f);
            item.buffId = 30200092;
            break;

        // 盾 ------------------------
        case ECreation.Shield:
            item.equipType = EquipType.Shield_Hand;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos    = 512;
            item.itemClassId = (int)CreationItemClass.Shield;
            item.tabIndex    = 1;
            item.sortLabel   = 9920;
            //item.level = Mathf.Clamp((int)((attr.m_Defense + 2f) / 2f), 1, 100);
            item.durabilityFactor = 0.01f;
            item.editorTypeId     = 9;
            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.Def, attr.m_Defense);
            item.propertyList.AddProperty(Pathea.AttribType.ShieldMeleeProtect, Mathf.Clamp(attr.m_Defense / 330 + 0.2f, 0.2f, 0.87f));
            item.buffId = 30200093;
            break;


        // 手枪/单手枪 ------------------------
        case ECreation.HandGun:
            item.equipType = EquipType.HandGun;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos    = 528;
            item.itemClassId = (int)CreationItemClass.HandGun;
            item.tabIndex    = 1;
            item.sortLabel   = 9930;
            //item.level = Mathf.Clamp((int)((attr.m_Attack - 4f) / 2f), 1, 70);
            item.durabilityFactor = 1f;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack);
            item.buffId       = 30200095;
            item.editorTypeId = 11;
            break;


        // 步枪/双手枪 ------------------------
        case ECreation.Rifle:
            item.equipType = EquipType.Rifle;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos    = 528;
            item.itemClassId = (int)CreationItemClass.Rifle;
            item.tabIndex    = 1;
            item.sortLabel   = 9940;
            //item.level = Mathf.Clamp((int)((attr.m_Attack - 4f) / 2f), 1, 70);
            item.durabilityFactor = 1f;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.Atk, attr.m_Attack);
            item.buffId       = 30200095;
            item.editorTypeId = 11;
            break;

        // 车 ------------------------
        case ECreation.Vehicle:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "leftup_putdown", "0"
            };
            item.equipPos    = 0;
            item.itemClassId = (int)CreationItemClass.Vehicle;
            item.tabIndex    = 0;
            item.sortLabel   = 9950;
            //item.level = CalcCarrierLevel(attr.m_Durability);

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability);
            item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability);
            item.engergyMax = (int)attr.m_MaxFuel;
            break;

        // 飞机 ------------------------
        case ECreation.Aircraft:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "leftup_putdown", "0"
            };
            item.equipPos    = 0;
            item.itemClassId = (int)CreationItemClass.Aircraft;
            item.tabIndex    = 0;
            item.sortLabel   = 9960;
            //item.level = CalcCarrierLevel(attr.m_Durability);

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability);
            item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability);
            item.engergyMax = (int)attr.m_MaxFuel;
            break;

        // 船 ------------------------
        case ECreation.Boat:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "leftup_putdown", "0"
            };
            item.equipPos    = 0;
            item.itemClassId = (int)CreationItemClass.Boat;
            item.tabIndex    = 0;
            item.sortLabel   = 9970;
            //item.level = CalcCarrierLevel(attr.m_Durability);

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability);
            item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability);
            item.engergyMax = (int)attr.m_MaxFuel;
            break;

        // 简单物体 ------------------------
        case ECreation.SimpleObject:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "leftup_putdown", "0"
            };
            item.equipPos    = 0;
            item.itemClassId = (int)CreationItemClass.SimpleObject;
            item.sortLabel   = 9980;
            item.tabIndex    = 0;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability);
            item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability);
            break;

        // 装甲 ------------------------
        case ECreation.ArmorHead:
        case ECreation.ArmorBody:
        case ECreation.ArmorArmAndLeg:
        case ECreation.ArmorHandAndFoot:
        case ECreation.ArmorDecoration:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos         = 0;
            item.itemClassId      = (int)CreationItemClass.Armor;
            item.sortLabel        = 9990 + (int)attr.m_Type;
            item.tabIndex         = 3;
            item.durabilityFactor = 0.01f;
            break;

        // 机器人 ------------------------
        case ECreation.Robot:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "leftup_putdown", "0"
            };
            item.equipPos    = 0;
            item.itemClassId = (int)CreationItemClass.Robot;
            item.tabIndex    = 0;
            item.sortLabel   = 9945;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability);
            item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability);
            item.engergyMax = (int)attr.m_MaxFuel;
            break;

        // 炮台 ------------------------
        case ECreation.AITurret:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "leftup_putdown", "0"
            };
            item.equipPos    = 0;
            item.itemClassId = (int)CreationItemClass.AITurret;
            item.tabIndex    = 0;
            item.sortLabel   = 9946;

            if (item.propertyList == null)
            {
                item.propertyList = new ItemProto.PropertyList();
            }
            item.propertyList.AddProperty(Pathea.AttribType.HpMax, attr.m_Durability);
            item.propertyList.AddProperty(Pathea.AttribType.Hp, attr.m_Durability);
            item.engergyMax   = (int)attr.m_MaxFuel;
            item.unchargeable = attr.m_Defense < 0.5f;
            break;

        default:
            item.equipType = EquipType.Null;
            item.icon      = new string[3] {
                "0", "0", "0"
            };
            item.equipPos  = 0;
            item.sortLabel = 10000;
            item.tabIndex  = 0;
            break;
        }
        return(item);
    }
Exemple #5
0
    public static List <ItemIdCount> ResolveItemsToProcess(List <ItemIdCount> itemsNeedToGet, CSAssembly core = null, CSFactory factory = null)
    {
        List <ItemIdCount> resourceItems  = new List <ItemIdCount> ();
        List <ItemIdCount> ItemsOwnRecord = new List <ItemIdCount> ();

        foreach (ItemIdCount iic in itemsNeedToGet)
        {
            if (CSProcessing.CanProcessItem(iic.protoId))
            {
                resourceItems.Add(iic);
                continue;
            }
            List <ItemIdCount> needReplicate = new List <ItemIdCount> ();
            needReplicate.Add(iic);
            do
            {
                List <ItemIdCount> tempNeed = new List <ItemIdCount> ();
                tempNeed.AddRange(needReplicate);
                foreach (ItemIdCount tempIic in tempNeed)
                {
                    Replicator.KnownFormula[] msList = UIGraphControl.GetReplicator().GetKnowFormulasByProductItemId(tempIic.protoId);
                    if (msList == null || msList.Length == 0)
                    {
                        needReplicate.Remove(tempIic);
                        //Debug.LogError("can't get "+tempIic.protoId+"for colony");
                        continue;
                    }
                    //--to do: temp_ only use script 01
                    Replicator.Formula ms = Replicator.Formula.Mgr.Instance.Find(msList[0].id);
                    foreach (Replicator.Formula.Material mt in ms.materials)
                    {
                        int needCount = mt.itemCount * Mathf.CeilToInt(tempIic.count * 1.0f / ms.m_productItemCount);
                        if (core != null)
                        {
                            int ownMaterialCount = CSUtils.GetItemCountFromAllStorage(mt.itemId, core);
                            if (factory != null)
                            {
                                ownMaterialCount += factory.GetAllCompoundItemCount(mt.itemId);
                            }

                            ItemIdCount ownRecord = ItemsOwnRecord.Find(it => it.protoId == mt.itemId);
                            if (ownMaterialCount > 0)
                            {
                                if (ownRecord == null || ownRecord.count < ownMaterialCount)
                                {
                                    int leftRecordCount = 0;
                                    if (ownRecord == null)
                                    {
                                        leftRecordCount = ownMaterialCount;
                                    }
                                    else
                                    {
                                        leftRecordCount = ownMaterialCount - ownRecord.count;
                                    }
                                    int addRecordCount = 0;
                                    if (needCount > leftRecordCount)
                                    {
                                        needCount     -= leftRecordCount;
                                        addRecordCount = leftRecordCount;
                                    }
                                    else
                                    {
                                        needCount      = 0;
                                        addRecordCount = needCount;
                                    }
                                    if (ownRecord == null)
                                    {
                                        ItemsOwnRecord.Add(new ItemIdCount(mt.itemId, addRecordCount));
                                    }
                                    else
                                    {
                                        ownRecord.count += addRecordCount;
                                    }
                                    if (needCount == 0)
                                    {
                                        continue;
                                    }
                                }
                            }
                        }

                        if (CSProcessing.CanProcessItem(mt.itemId))
                        {
                            CSUtils.AddItemIdCount(resourceItems, mt.itemId, needCount);
                        }
                        else
                        {
                            CSUtils.AddItemIdCount(needReplicate, mt.itemId, needCount);
                        }
                    }
                    needReplicate.Remove(tempIic);
                }
            }while(needReplicate.Count > 0);
        }

        return(resourceItems);
    }
    void UpdateItemsTrackState(Replicator.Formula ms)
    {
        bool containe = GameUI.Instance.mItemsTrackWnd.ContainsScript(ms.id);

        ckItemTrack.isChecked = containe;
    }
Exemple #7
0
    public void OnCancelCompound(int index)
    {
        if (index < Data.m_CompoudItems.Count)
        {
            CompoudItem ci = Data.m_CompoudItems[index];
//			if(ci.IsFinished)
//				return;

            if (PeGameMgr.IsSingle)
            {
                //1.storage add materials
                // 0)get materials
                List <ItemIdCount> materialList = new List <ItemIdCount> ();
                Replicator.Formula ms           = Replicator.Formula.Mgr.Instance.FindByProductId(ci.itemID);
                foreach (Replicator.Formula.Material mt in ms.materials)
                {
                    materialList.Add(new ItemIdCount(mt.itemId, mt.itemCount * ci.itemCnt / ms.m_productItemCount));
                }
                // 1)storage not full
                if (!CSUtils.AddItemListToStorage(materialList, Assembly))
                // 2)storage full, gen object
                {
                    System.Random rand = new System.Random();
                    Vector3       pos;
                    if (gameLogic != null)
                    {
                        pos = Position + gameLogic.transform.rotation * (new Vector3(0, 0, 4));
                    }
                    else
                    {
                        pos = Position + new Vector3(0, 0, 6);
                    }
                    pos = pos + new Vector3((float)rand.NextDouble() * 0.1f, 0, (float)rand.NextDouble() * 0.1f);
                    while (RandomItemMgr.Instance.ContainsPos(pos))
                    {
                        pos += new Vector3(0, 0.01f, 0);
                    }
                    RandomItemMgr.Instance.GenFactoryCancel(pos, CSUtils.ItemIdCountListToIntArray(materialList));
                }
                if (m_CurCompoundIndex == index)
                {
                    if (m_Counter != null)
                    {
                        CSMain.Instance.DestoryCounter(m_Counter);
                        m_Counter = null;
                    }
                }
                if (m_CurCompoundIndex > index)
                {
                    m_CurCompoundIndex--;
                }
                Data.m_CompoudItems.Remove(ci);
            }
            else
            {
                _Net.RPCServer(EPacketType.PT_CL_FCT_GenFactoryCancel, index, ci);

                if (m_CurCompoundIndex == index)
                {
                    if (m_Counter != null)
                    {
                        CSMain.Instance.DestoryCounter(m_Counter);
                        m_Counter = null;
                    }
                }
                if (m_CurCompoundIndex > index)
                {
                    m_CurCompoundIndex--;
                }
                Data.m_CompoudItems.Remove(ci);
            }
        }
    }
Exemple #8
0
 public float GetCurOriginTime()
 {
     Replicator.Formula ms = Replicator.Formula.Mgr.Instance.FindByProductId(Data.m_CompoudItems[m_CurCompoundIndex].itemID);
     return(Data.m_CompoudItems[m_CurCompoundIndex].itemCnt * ms.timeNeed / ms.m_productItemCount);
 }