// Add a creation to CreationMgr (multi-player) public static CreationData NewCreation(int object_id, ulong res_hash, float rand_seed) { CreationData creation_data = new CreationData(); creation_data.m_ObjectID = object_id; creation_data.m_HashCode = res_hash; creation_data.m_RandomSeed = rand_seed; if (creation_data.LoadRes()) { creation_data.GenCreationAttr(); creation_data.BuildPrefab(); creation_data.Register(); CreationMgr.AddCreation(creation_data); //creation_data.m_Hp = creation_data.m_Attribute.m_Durability; //creation_data.m_Fuel = creation_data.m_Attribute.m_MaxFuel; Debug.Log("new creation succeed !"); creation_data.UpdateUseTime(); return(creation_data); } else { Debug.LogError("creation generate failed."); } return(null); }
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"); }
void Update() { if (GameConfig.IsMultiMode) { CreationMgr.CheckForDel(); } }
protected override void SetData(byte[] data) { if (null != data) { CreationMgr.Import(data); } }
void Start() { SetNPCsAtrribType(); StartCoroutine(MissionStart()); //Invoke("MissionStartSelf", 5); CreationMgr.Init(); ForceSetting.Instance.Load(Resources.Load("ForceSetting/ForceSettings_Story") as TextAsset); mWareHouse.SetActive(false); }
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; } }
void Start() { LoadSteamItems(); CreationMgr.Init(); _CurDownload = 0; _DownloadList.Clear(); StartCoroutine(DownLoadCoroutine()); _SteamPersonaName = "$sinwa$" + SteamFriends.GetPersonaName(); SteamFriends.SetListenForFriendsMessages(true); }
void ExportCreation() { if (VCEditor.s_Scene == null || VCEditor.s_Scene.m_IsoData == null) { Debug.Log("VCEditor IsoData is null!"); return; } new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; new_creation.m_Resource = VCEditor.s_Scene.m_IsoData.Export(); new_creation.ReadRes(); new_creation.GenCreationAttr(); // 计算属性 if (new_creation.SaveRes()) { new_creation.BuildPrefab(); new_creation.Register(); CreationMgr.AddCreation(new_creation); } else { Debug.Log("Save creation resource file failed !"); new_creation.Destroy(); return; } GameObject obj = CreationMgr.InstantiateCreation(new_creation.m_ObjectID, 0, true, null); if (obj != null) { if (new_creation.m_Attribute.m_Type == ECreation.Vehicle) { obj.transform.localPosition = ExportPosVehicle.position; } if (new_creation.m_Attribute.m_Type == ECreation.Aircraft) { obj.transform.localPosition = ExportPosAircraft.position; } if (new_creation.m_Attribute.m_Type == ECreation.Boat) { obj.transform.localPosition = ExportPosBoat.position; } ZXCameraCtrl ZXCamera = mMainCamera.GetComponent <ZXCameraCtrl>(); ZXCamera.Following = obj.transform; } creation_obj = obj; }
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); }
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 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; } }
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 int MakeCreation(string path) { TextAsset aseet = Resources.Load <TextAsset>(path); VCIsoData iso = new VCIsoData(); iso.Import(aseet.bytes, new VCIsoOption(false)); // Multi player if (s_MultiplayerMode) { if (!VCConfig.s_Categories.ContainsKey(iso.m_HeadInfo.Category)) { return(-1); } byte[] isodata = iso.Export(); if (isodata == null || isodata.Length <= 0) { return(-1); } ulong hash = CRC64.Compute(isodata); ulong fileId = SteamWorkShop.GetFileHandle(hash); VCGameMediator.SendIsoDataToServer(iso.m_HeadInfo.Name, iso.m_HeadInfo.SteamDesc, iso.m_HeadInfo.SteamPreview, isodata, SteamWorkShop.AddNewVersionTag(iso.m_HeadInfo.ScenePaths()), true, fileId, true); return(0); } else { CreationData new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; new_creation.m_Resource = iso.Export(); 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(-1); } // 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(-1); // Error } else if (send_retval == -1) { return(-4); // Item Package Full } else { if (OnMakeCreation != null) { OnMakeCreation(); } return(0); // Succeed } } else { Debug.LogWarning("Save creation resource file failed !"); new_creation.Destroy(); return(-3); } } }
void Start() { CreationMgr.Init(); }
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; } } }
void Init() { CreationMgr.Init(); }
// 快速装备. 查找一个骨骼用以装备装甲 // 优先选择无装备骨骼, 否则替换已装备骨骼 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); } } }
protected override void WriteData(BinaryWriter bw) { CreationMgr.Export(bw); }
public static void ExportRandIso(string fullpath, int dungeonId, int index) { if (fullpath == "") { return; } if (!File.Exists(fullpath)) { return; } ulong fileId = DungeonIsos.GetFileId(dungeonId, index); VCIsoData iso = new VCIsoData(); using (FileStream fs = new FileStream(fullpath, FileMode.Open, FileAccess.Read)) { byte[] iso_buffer = new byte[(int)(fs.Length)]; fs.Read(iso_buffer, 0, (int)(fs.Length)); fs.Close(); iso.Import(iso_buffer, new VCIsoOption(true)); if (Pathea.PeGameMgr.IsMulti) { ulong hash = CRC64.Compute(iso_buffer); VCGameMediator.SendIsoDataToServer(iso.m_HeadInfo.Name, iso.m_HeadInfo.SteamDesc, iso.m_HeadInfo.SteamPreview, iso_buffer, SteamWorkShop.AddNewVersionTag(iso.m_HeadInfo.ScenePaths()), true, fileId, true); NetworkManager.SyncServer(EPacketType.PT_Common_SendRandIsoHash, dungeonId, index, hash); } else { CreationData new_creation = new CreationData(); new_creation.m_ObjectID = CreationMgr.QueryNewId(); new_creation.m_RandomSeed = UnityEngine.Random.value; new_creation.m_Resource = iso_buffer; new_creation.ReadRes(); ulong hash = CRC64.Compute(iso_buffer); // 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); ItemObject item; new_creation.SendToPlayer(out item, false); Debug.Log("Make creation succeed !"); RandomDungenMgr.Instance.ReceiveIsoObj(dungeonId, hash, item.instanceId); } else { Debug.LogWarning("Save creation resource file failed !"); new_creation.Destroy(); return; } } } }