// public static PeEntity CreateNetRandTerDoodadWithPlayerId(int entityId, int protoId, Vector3 pos, Vector3 scl, Quaternion rot, int townId = -1, int campId = SceneDoodadDesc.c_neutralCamp, int damageId = SceneDoodadDesc.c_neutralDamage,int playerId = -1) // { // return CreateDoodad(true, new AgentInfo(townId, true, campId, damageId), protoId, pos, scl, rot, entityId); // } public static PeEntity CreateStoryDoodadNet(int assetId, int entityId) { SceneDoodadDesc doodad = StoryDoodadMap.Get(assetId); if (null == doodad) { return(null); } AgentInfo spInfo = new AgentInfo(doodad._id, doodad._isShown, doodad._campId, doodad._damageId); return(CreateDoodad(true, spInfo, doodad._protoId, doodad._pos, doodad._scl, doodad._rot, entityId));; }
protected override void OnPEInstantiate(uLink.NetworkMessageInfo info) { objType = (DoodadType)info.networkView.initialData.Read <int>(); int playerId = info.networkView.initialData.Read <int>(); _teamId = info.networkView.initialData.Read <int>(); _assetId = info.networkView.initialData.Read <int>(); _id = info.networkView.initialData.Read <int>(); _protoTypeId = info.networkView.initialData.Read <int>(); Vector3 scale = info.networkView.initialData.Read <Vector3>(); string param = info.networkView.initialData.Read <string>(); SceneDoodadDesc doodad = null; _pos = transform.position; rot = transform.rotation; if (null == ParentTrans) { ParentTrans = new GameObject("DoodadNetworkMgr").transform; } transform.parent = ParentTrans; if (PeGameMgr.IsMultiStory) { doodad = StoryDoodadMap.Get(_assetId); } if (objType == DoodadType.DoodadType_Drop || objType == DoodadType.DoodadType_Dead) { itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, playerId, _pos, this); } else if (objType == DoodadType.DoodadType_SceneBox) { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } if (entity != null) { WareHouseObject script = entity.gameObject.GetComponent <WareHouseObject>(); if (script != null) { script._id = _assetId; } } } else if (objType == DoodadType.DoodadType_SceneItem) { string[] str = param.Split('|'); if (str.Length != 2) { return; } _sceneItemName = str[1]; if (_sceneItemName == "ash_box") { itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, _assetId, _pos, this); } else if (_sceneItemName == "ash_ball") { itemBox = ItemBoxMgr.Instance.AddItemMultiPlay(OwnerView.viewID.id, _assetId, _pos, this); } else { RequestItemList(); } } else if (objType == DoodadType.DoodadType_Repair) { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } } else if (objType == DoodadType.DoodadType_Power) { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } } else if (objType == DoodadType.DoodadType_RandomBuilding || objType == DoodadType.DoodadType_RandomBuilding_Repair || objType == DoodadType.DoodadType_RandomBuilding_Power) { ExtractParam(param, out townId, out _campId, out _damageId, out _dPlayerId); if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateNetRandTerDoodad(Id, _protoTypeId, _pos, scale, rot, townId, _campId, _damageId, _dPlayerId); } } else { if (doodad != null) { entity = DoodadEntityCreator.CreateStoryDoodadNet(_assetId, Id); } else { entity = DoodadEntityCreator.CreateDoodadNet(_protoTypeId, _pos, scale, rot, Id); } } if (entity != null) { OnSpawned(entity.gameObject); } mapObjNetworkMgr.Add(this); gameObject.name = string.Format("Mapobj assetId:{0}, protoTypeId:{1}, objType:{2}, entityId:{3}", _assetId, _protoTypeId, objType, _id); }