string Repair(string param) { if (param == "") { return("Parameter excepted"); } string[] ps = param.Split(','); int id = Convert.ToInt32(ps[0]) + 100000000; CreationData crd = CreationMgr.GetCreation(id); if (crd != null) { float hp = crd.m_Attribute.m_Durability; if (ps.Length != 1) { hp *= Mathf.Clamp01(Convert.ToSingle(ps[1]) * 0.01f); } var itemObject = ItemAsset.ItemMgr.Instance.Get(id); var lifeCmpt = itemObject.GetCmpt <ItemAsset.LifeLimit>(); lifeCmpt.floatValue.current = hp; //Pathea.SkAliveEntity skAliveEntity = (DragArticleAgent.GetById(id) as DragArticleAgent).itemScript.GetComponent<Pathea.SkAliveEntity>(); //skAliveEntity.SetAttribute(Pathea.AttribType.Hp, hp, false); } return("ok"); }
string Recharge(string param) { if (param == "") { return("Parameter excepted"); } string[] ps = param.Split(','); int id = Convert.ToInt32(ps[0]) + 100000000; CreationData crd = CreationMgr.GetCreation(id); if (crd != null) { float fuel = crd.m_Attribute.m_MaxFuel; if (ps.Length != 1) { fuel *= Mathf.Clamp01(Convert.ToSingle(ps[1]) * 0.01f); } var itemObject = ItemAsset.ItemMgr.Instance.Get(id); var energyCmpt = itemObject.GetCmpt <ItemAsset.Energy>(); energyCmpt.floatValue.current = fuel; //Pathea.SkAliveEntity skAliveEntity = (DragArticleAgent.GetById(id) as DragArticleAgent).itemScript.GetComponent<Pathea.SkAliveEntity>(); //skAliveEntity.SetAttribute(Pathea.AttribType.Energy, fuel, false); } return("ok"); }
public static void CopyCretion(int instanceID) { CreationData new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; CreationData cd = CreationMgr.GetCreation(instanceID); if (null == cd) { return; } new_creation.m_Resource = cd.m_Resource; new_creation.ReadRes(); // Attr new_creation.GenCreationAttr(); if (new_creation.m_Attribute.m_Type == ECreation.Null) { Debug.LogWarning("Creation is not a valid type !"); new_creation.Destroy(); return; } // SaveRes if (new_creation.SaveRes()) { new_creation.BuildPrefab(); new_creation.Register(); CreationMgr.AddCreation(new_creation); ItemAsset.ItemObject item; int send_retval = new_creation.SendToPlayer(out item); Debug.Log("Make creation succeed !"); if (send_retval == 0) { return; // Error } else if (send_retval == -1) { return; // Item Package Full } else { return; // Succeed } } else { Debug.LogWarning("Save creation resource file failed !"); new_creation.Destroy(); return; } }
public static void RPC_S2C_RequestUGCData(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int[] objIDs = stream.Read <int[]>(); foreach (int id in objIDs) { CreationData data = CreationMgr.GetCreation(id); if (null == data) { CreationOriginData cData = CreationList.Find(iter => iter.ObjectID == id); if (cData != null) { CreationMgr.NewCreation(cData.ObjectID, cData.HashCode, (float)cData.Seed); } else { MessageBox_N.ShowOkBox(PELocalization.GetString(8000500)); LogManager.Error("Creation item create failed. ID:" + id); GameClientNetwork.Disconnect(); } return; } ItemProto item = ItemProto.GetItemData(id); if (null != item) { byte[] itemData = ItemProto.GetBuffer(item); NetworkManager.SyncServer(EPacketType.PT_Common_UGCItem, id, itemData); var components = from component in data.m_IsoData.m_Components where VCUtils.IsSeat(component.m_Type) select(int) component.m_Type; float hp = data.m_Attribute.m_Durability; float energy = data.m_Attribute.m_MaxFuel; if (components.Count() >= 1) { NetworkManager.SyncServer(EPacketType.PT_Common_UGCData, id, hp, energy, data.m_Attribute.m_Cost.Keys.ToArray(), data.m_Attribute.m_Cost.Values.ToArray(), true, components.ToArray()); } else { NetworkManager.SyncServer(EPacketType.PT_Common_UGCData, id, hp, energy, data.m_Attribute.m_Cost.Keys.ToArray(), data.m_Attribute.m_Cost.Values.ToArray(), false); } } } }
void Mission953(int nMissionID, int itemId) { if (nMissionID != MissionManager.m_SpecialMissionID93) { return; } ItemAsset.ItemObject itemObj = ItemAsset.ItemMgr.Instance.Get(itemId); if (itemObj == null) { return; } int itemid = 0; if (itemObj.protoId > 100000000) { itemid = StroyManager.Instance.ItemClassIdtoProtoId(itemObj.protoData.itemClassId); } else { itemid = itemObj.protoId; } if (nMissionID == MissionManager.m_SpecialMissionID93 && MissionManager.Instance.m_PlayerMission.IsSpecialID(itemid) == ECreation.SimpleObject) { CreationData creationData = CreationMgr.GetCreation(itemObj.instanceId); if (creationData != null) { int costNum = 0; foreach (var cost in creationData.m_Attribute.m_Cost.Values) { costNum += cost; } if (costNum <= 300) { StroyManager.Instance.GetMissionOrPlotById(10954); } else { StroyManager.Instance.GetMissionOrPlotById(10955); } } } }
public static ArmorType GetArmorType(int itemInstanceID) { var data = CreationMgr.GetCreation(itemInstanceID); if (data != null) { switch (data.m_Attribute.m_Type) { case ECreation.ArmorHead: return(ArmorType.Head); case ECreation.ArmorBody: return(ArmorType.Body); case ECreation.ArmorArmAndLeg: return(ArmorType.ArmAndLeg); case ECreation.ArmorHandAndFoot: return(ArmorType.HandAndFoot); case ECreation.ArmorDecoration: return(ArmorType.Decoration); } } return(ArmorType.None); }
void InitCreationID(int creationId) { if (m_Computer != null) { m_Computer.Destroy(); } CreationData crd = CreationMgr.GetCreation(creationId); if (crd != null) { m_CreationID = creationId; m_CreationData = crd; m_MeshMgr = GetComponent <VCMeshMgr>(); m_Computer = new VCMCComputer(); m_Computer.Init(new IntVector3(crd.m_IsoData.m_HeadInfo.xSize, crd.m_IsoData.m_HeadInfo.ySize, crd.m_IsoData.m_HeadInfo.zSize), m_MeshMgr, false); // [VCCase] - Create box collider if (crd.m_Attribute.m_Type == ECreation.Vehicle || crd.m_Attribute.m_Type == ECreation.Aircraft || crd.m_Attribute.m_Type == ECreation.Boat || crd.m_Attribute.m_Type == ECreation.SimpleObject || crd.m_Attribute.m_Type == ECreation.AITurret) { m_Computer.m_CreateBoxCollider = true; } } else { m_CreationID = 0; m_CreationData = null; m_Computer = null; m_MeshMgr = null; } }
public static CreationData GetCreation(int objId) { CreationOriginData cData = CreationList.Find(iter => iter.ObjectID == objId); if (cData != null) { ItemProto.Mgr.Instance.Remove(objId); /*CreationData data = */ CreationMgr.NewCreation(cData.ObjectID, cData.HashCode, (float)cData.Seed); // if(data != null && cData.HP != -1 && cData.Fuel != -1) // { // data.m_Hp = cData.HP; // data.m_Fuel = cData.Fuel; // } return(CreationMgr.GetCreation(objId)); } else { return(null); } }
void InitCreationIDClone(int creationId, VFCreationDataSource dataSource, VCMeshMgr mesh_mgr) { if (m_Computer != null) { m_Computer.Destroy(); } CreationData crd = CreationMgr.GetCreation(creationId); if (crd != null) { m_CreationID = creationId; m_CreationData = crd; m_MeshMgr = mesh_mgr; m_MeshMgr.m_LeftSidePos = !mesh_mgr.m_LeftSidePos; m_Computer = new VCMCComputer(); m_Computer.InitClone(dataSource, m_MeshMgr, false); if (crd.m_Attribute.m_Type == ECreation.Vehicle || crd.m_Attribute.m_Type == ECreation.Aircraft || crd.m_Attribute.m_Type == ECreation.Boat || crd.m_Attribute.m_Type == ECreation.SimpleObject || crd.m_Attribute.m_Type == ECreation.AITurret) { m_Computer.m_CreateBoxCollider = true; } } else { m_CreationID = 0; m_CreationData = null; m_Computer = null; m_MeshMgr = null; } }
public static void CopyCretion(ECreation type) { Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>(); if (null == pkg) { return; } List <int> creationInstanceid = pkg.package.GetCreationInstanceId(type); if (creationInstanceid == null || creationInstanceid.Count == 0) { return; } CreationData cd = CreationMgr.GetCreation(creationInstanceid[0]); if (Pathea.PeGameMgr.IsMulti) { ulong hash = CRC64.Compute(cd.m_Resource); ulong fileId = SteamWorkShop.GetFileHandle(hash); VCGameMediator.SendIsoDataToServer(cd.m_IsoData.m_HeadInfo.Name, cd.m_IsoData.m_HeadInfo.SteamDesc, cd.m_IsoData.m_HeadInfo.SteamPreview, cd.m_Resource, SteamWorkShop.AddNewVersionTag(cd.m_IsoData.m_HeadInfo.ScenePaths()), true, fileId, true); } else { CreationData new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; new_creation.m_Resource = cd.m_Resource; new_creation.ReadRes(); // Attr new_creation.GenCreationAttr(); if (new_creation.m_Attribute.m_Type == ECreation.Null) { Debug.LogWarning("Creation is not a valid type !"); new_creation.Destroy(); return; } // SaveRes if (new_creation.SaveRes()) { new_creation.BuildPrefab(); new_creation.Register(); CreationMgr.AddCreation(new_creation); ItemAsset.ItemObject item; int send_retval = new_creation.SendToPlayer(out item); Debug.Log("Make creation succeed !"); if (send_retval == 0) { return; // Error } else if (send_retval == -1) { return; // Item Package Full } else { return; // Succeed } } else { Debug.LogWarning("Save creation resource file failed !"); new_creation.Destroy(); return; } } }
// 快速装备. 查找一个骨骼用以装备装甲 // 优先选择无装备骨骼, 否则替换已装备骨骼 public void QuickEquipArmorPartFromPackage(ItemObject item) { ArmorType type = CreationHelper.GetArmorType(item.instanceId); if (type != ArmorType.None) { int boneGroup = 0; int boneIndex = 0; if (type != ArmorType.Decoration) { boneGroup = (int)type; // 优先选择设计的骨骼节点 boneIndex = CreationMgr.GetCreation(item.instanceId).creationController.armorBoneIndex; if (_boneNodes[boneGroup][boneIndex].normal != null) { // 其次找可用的空节点 boneIndex = Array.FindIndex(_boneNodes[boneGroup], node => node.normal == null); // 最后选择设计的节点 if (boneIndex < 0) { boneIndex = CreationMgr.GetCreation(item.instanceId).creationController.armorBoneIndex; } } } else { if (_decorationCount == _maxDecorationCount) { // 如果装饰装甲已经有 4 个, 则随机替换一个旧装饰装甲 int selected = UnityEngine.Random.Range(0, _maxDecorationCount); for (int i = 0; i < _armorObjects.Count; i++) { if (_armorObjects[i].data.type == ArmorType.Decoration) { if (selected == 0) { boneIndex = _armorObjects[i].data.boneIndex; boneGroup = _armorObjects[i].data.boneGroup; break; } else { selected--; } } } } else { for (boneGroup = 0; boneGroup < 4; boneGroup++) { boneIndex = Array.FindIndex(_boneNodes[boneGroup], node => node.decoration == null); if (boneIndex >= 0) { break; } } } } if (PeGameMgr.IsMulti) { if (hasRequest) { return; } C2S_EquipArmorPartFromPackage( item.instanceId, (int)type, boneGroup, boneIndex, null); } else { EquipArmorPartFromPackage( item, type, boneGroup, boneIndex); } } }