private void OnCollectionUpdate(GameEvent ge, EventParameter parameter) { CollectionObj collection = CoreEntry.gEntityMgr.GetCollectionByServerID(parameter.longParameter) as CollectionObj; if (null != collection) { collection.Change((CollectionType)parameter.intParameter); } }
/// <summary> /// 添加一个采集点 /// </summary> /// <param name="entity"></param> /// <returns>是否添加成功</returns> public bool AddCollection(CollectionObj entity) { if (!mCollectionList.Contains(entity)) { mCollectionList.Add(entity); return(true); } return(false); }
/// <summary> /// 采集物信息销毁。 /// </summary> public void OnGameEventCollectInfoDestory(GameEvent ge, EventParameter parameter) { CollectionObj obj = parameter.objParameter as CollectionObj; if (obj == null || obj.ServerID == 0) { return; } //销毁采集物信息 CollectionInfo info; if (m_CollectionInfo.TryGetValue(obj.ServerID, out info)) { m_CollectionInfo.Remove(obj.ServerID); RemoveCollectionInfo(info); } }
/// <summary> /// 加载采集点 /// </summary> /// <param name="collectionStruct"></param> /// <returns></returns> public GameObject LoadCollection(MsgData_sSceneObjectEnterCollection collectionStruct) { LuaTable collectionCfg = ConfigManager.Instance.Map.GetCollectionConfig(collectionStruct.ConfigID); if (null == collectionCfg) { return(null); } Vector3 position = CommonTools.ServerPosToClient(collectionStruct.PosX, collectionStruct.PosY); Vector3 eulerAngle = CommonTools.ServerDirToClient(collectionStruct.Dir); GameObject obj = CreateGameObject(collectionCfg.Get <int>("modelId"), position, eulerAngle); if (obj == null) { return(null); } obj.name = collectionStruct.Guid.ToString(); float s = collectionCfg.Get <float>("scale"); obj.transform.localScale = new Vector3(s, s, s); ParticleScaler[] scalers = obj.GetComponentsInChildren <ParticleScaler>(true); for (int i = 0; i < scalers.Length; i++) { scalers[i].particleScale = s; } Entity actorObject = null; actorObject = obj.GetComponent <Entity>(); if (null != actorObject) { Object.DestroyImmediate(actorObject); } CollectionObj collection = obj.AddComponent <CollectionObj>(); collection.Init(collectionCfg.Get <int>("modelId"), collectionStruct.ConfigID, collectionStruct.Guid); collection.ConfigID = collectionStruct.ConfigID; CoreEntry.gEntityMgr.AddCollection(collection); return(obj); }
/// <summary> /// 采集物信息创建。 /// </summary> public void OnGameEventCollectInfoCreate(GameEvent ge, EventParameter parameter) { CollectionObj obj = parameter.objParameter as CollectionObj; if (obj == null || obj.ServerID == 0 || string.IsNullOrEmpty(obj.Name)) { return; } //创建采集物信息 CollectionInfo info; if (!m_CollectionInfo.TryGetValue(obj.ServerID, out info)) { info = GetCollectionInfo(); m_CollectionInfo.Add(obj.ServerID, info); } info.Init(obj.gameObject); }
private void OnLeaveScene(GameEvent ge, EventParameter parameter) { MsgData_sSceneObjectLeaveNotify data = parameter.msgParameter as MsgData_sSceneObjectLeaveNotify; long serverID = (long)data.ObjectID; if (mObjRecord.ContainsKey(serverID)) { mObjRecord.Remove(serverID); //Debug.LogError("怪物消失" + serverID); } if (mBackgroundPlayer.ContainsKey(serverID)) { mBackgroundPlayer.Remove(serverID); return; } for (int i = 0; i < mSceneDataList.Count; i++) { if (mSceneDataList[i].ObjGuid == serverID) { mSceneDataList.RemoveAt(i); break; } } for(int i = 0;i < mDeathCache.Count;i++) { if(serverID == mDeathCache[i].ID) { mDeathCache.RemoveAt(i); break; } } for (int i = 0; i < mSceneCache.Count; i++) { if (mSceneCache[i].ObjGuid == serverID) { mSceneCache.RemoveAt(i); return; } } if (!bSceneLoaded) { return; } if (data.ObjectType == (sbyte)EnEntType.EnEntType_Item) { EventParameter param = EventParameter.Get(); param.longParameter = serverID; CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_OBJ_ITEM_LEAVE, param); return; } else if (data.ObjectType == (sbyte)EnEntType.EnEntType_GatherObj) { CollectionObj collection = CoreEntry.gEntityMgr.GetCollectionByServerID(serverID) as CollectionObj; if (null != collection) { CoreEntry.gEntityMgr.RemoveCollectionByServerID(serverID); collection.RecycleObj(); } return; } else if (data.ObjectType == (sbyte)EnEntType.EnEntType_StaticObj) { PortalObj portal = CoreEntry.gEntityMgr.GetPortalByServerID(serverID) as PortalObj; if (null != portal) { CoreEntry.gEntityMgr.RemovePortalByServerID(serverID); portal.RecycleObj(); } return; } else if (data.ObjectType == (sbyte)EnEntType.EnEntType_Trap) { Trap trap = CoreEntry.gEntityMgr.GetTrapByServerID(serverID) as Trap; if (null != trap) { CoreEntry.gEntityMgr.RemoveTrapByServerID(serverID); trap.RecycleObj(); } return; } ActorObj actor = CoreEntry.gActorMgr.GetActorByServerID(serverID); if (null != actor) { if (!actor.mActorState.IsDeathEnd()) { if (!mLeaveCache.Contains(actor)) { mLeaveCache.Add(actor); } return; } CoreEntry.gActorMgr.RemoveActorByServerID(serverID); actor.RecycleObj(); EventParameter param = EventParameter.Get(); param.longParameter = serverID; CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_ACTOR_REMOVE, param); if (actor is OtherPlayer) { param = EventParameter.Get(); param.longParameter = serverID; CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_OTHERPLAYER_LEAVE, param); } //有后台玩家则切换进来 if (mBackgroundPlayer.Count > 0) { int num = CoreEntry.gActorMgr.GetAllPlayerActors().Count - 1 + GetCacheNumber(EnEntType.EnEntType_Player); if (num < CreateMaxPlayer) { var e = mBackgroundPlayer.GetEnumerator(); if (e.MoveNext()) { ScenePlayerData value = e.Current.Value; SceneObj sceneobj = CacheSceneObj(EnEntType.EnEntType_Player, value.Guid, value.EnterData); sceneobj.PlayerData = value; mBackgroundPlayer.Remove(value.Guid); } e.Dispose(); } } } }