public void SetCameraDistance() { table.MapDataBase mapdb = null; IMapSystem mapSys = Client.ClientGlobal.Instance().GetMapSystem(); if (mapSys != null) { mapdb = GameTableManager.Instance.GetTableItem <table.MapDataBase>(mapSys.GetMapID()); CameraFollow.Instance.SetCameraDis(isFarDisCamera ? mapdb.farDistance : mapdb.CamDis); } }
public void SetupMainCamera(IPlayer player) { float fRotateX = 38.0f; float fRotateY = 45.0f; table.MapDataBase mapdb = null; IMapSystem mapSys = Client.ClientGlobal.Instance().GetMapSystem(); if (mapSys != null) { mapdb = GameTableManager.Instance.GetTableItem <table.MapDataBase>(mapSys.GetMapID()); if (mapdb != null) { fRotateX = mapdb.RotateX; fRotateY = mapdb.RotateY; } } // 发送事件 CreateEntity string strCameraName = "MainCamera"; Engine.ICamera cam = Engine.RareEngine.Instance().GetRenderSystem().GetCamera(ref strCameraName); if (cam != null) { CameraFollow.Instance.camera = cam; CameraFollow.Instance.target = player; CameraFollow.Instance.SetCameraOffset(fRotateX, fRotateY, isFarDisCamera ? mapdb.CamDis : mapdb.farDistance); cam.SetCameraCtrl(CameraFollow.Instance); } if (cam != null) { if (cam.GetNode().GetTransForm().gameObject.GetComponent <PostRenderOcclusionEffect>() == null) { //PostRenderOcclusionEffect pEffect = cam.GetNode().GetTransForm().gameObject.AddComponent<PostRenderOcclusionEffect>(); //SeeThroughSystem pEffect = cam.GetNode().GetTransForm().gameObject.AddComponent<SeeThroughSystem>(); } if (cam.GetNode().GetTransForm().gameObject.GetComponent <PostRenderOutlineEffect>() == null) { //PostRenderOutlineEffect pEffect = cam.GetNode().GetTransForm().gameObject.AddComponent<PostRenderOutlineEffect>(); //SeeThroughSystem pEffect = cam.GetNode().GetTransForm().gameObject.AddComponent<SeeThroughSystem>(); } } // 设置场景方向光参数 需要根据Camera来 Shader.SetGlobalColor("g_LightColor", Color.white); // 设置方向 Shader.SetGlobalVector("g_LightDirection", -GetMainCamDir()); }
private void CreateTextureEvent(ITexture obj, object param = null) { IMapSystem mapsys = Client.ClientGlobal.Instance().GetMapSystem(); if (mapsys == null) { Engine.Utility.Log.Error("Mapsystem is null"); return; } if (m_texture != null) { mapTex.mainTexture = m_texture.GetTexture(); mapTex.MakePixelPerfect(); } else { string texpath = (string)param; Log.Error("texture is null texpath is " + texpath); } m_mapid = mapsys.GetMapID(); table.MapDataBase mdb = GameTableManager.Instance.GetTableItem <table.MapDataBase>(m_mapid); if (mdb != null) { string pos = mdb.uioffset; string[] xy = pos.Split('_'); float x = 0, y = 0; if (xy.Length == 2) { if (float.TryParse(xy[0], out x)) { if (float.TryParse(xy[1], out y)) { originPos = new Vector3(x, y, 0); } } } } m_mapTextureWidth = mdb.textureWidth; m_mapTextureHeight = mdb.textureWidth; mapTex.width = (int)m_mapTextureWidth; mapTex.height = (int)m_mapTextureHeight; mapTex.transform.localPosition = originPos; }
/// <summary> /// 点击事件 /// </summary> /// <param name="eventType"></param> /// <param name="data"></param> /// <param name="param"></param> private void OnReliveGridEventDlg(UIEventType eventType, object data, object param) { if (eventType == UIEventType.Click) { UIReliveGrid grid = data as UIReliveGrid; if (grid == null) { return; } if (grid.m_info.reliveId == 1) { IMapSystem mapSys = ClientGlobal.Instance().GetMapSystem(); if (mapSys == null) { return; } uint uCurMapID = mapSys.GetMapID(); table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(uCurMapID); if (mapDB == null) { return; } uint rebackMapID = mapDB.rebackMapID; if (!KHttpDown.Instance().SceneFileExists(rebackMapID)) { // 复活点复活 DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.DownloadPanel); HideSelf(); return; } } GameCmd.stOKReliveUserCmd_C cmd = new GameCmd.stOKReliveUserCmd_C(); cmd.byType = grid.m_info.reliveId; cmd.dwUserTempID = ClientGlobal.Instance().MainPlayer.GetID(); cmd.dwNpcID = 0; NetService.Instance.Send(cmd); } }
//------------------------------------------------------------------------------------------------------- /** * @brief 播放背景音乐 * @param */ private void PlayBGMusic() { table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(mapID); if (mapDB == null) { Engine.Utility.Log.Error("MapSystem:找不到地图配置数据{0}", mapID); return; } table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(mapDB.dwbgm); if (resDB == null) { Engine.Utility.Log.Error("MapSystem:找不到地图资源路径配置{0}", mapDB.dwResPath); return; } Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio(); if (audio != null) { audio.PlayMusic(resDB.strPath); } }
//------------------------------------------------------------------------------------------------------- /** * @brief 进入地图 * @param nMapID 地图ID */ public void EnterMap(uint nMapID, Vector3 pos) { // 读取地图配置表 Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem(); Engine.Utility.Log.Info("EnterMapStart"); if (rs != null) { if (nMapID == mapID) { return; } Engine.Utility.Log.Info("EnterMapStart mapID"); // 停止背景音乐 Engine.IAudio audio = Engine.RareEngine.Instance().GetAudio(); if (audio != null) { audio.StopMusic(); } // 离开当前场景 Process = 0f; Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ENTITYSYSTEM_LEAVEMAP, mapID); //进入下一个地图 Engine.Utility.Log.Info("EnterMapStart 离开当前场景"); table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(nMapID); if (mapDB == null) { Engine.Utility.Log.Error("MapSystem:找不到地图配置数据{0}", nMapID); return; } Engine.Utility.Log.Info("EnterMapStart 离开当前场景 table.MapDataBase mapDB "); table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(mapDB.dwResPath); if (resDB == null) { Engine.Utility.Log.Error("MapSystem:找不到地图资源路径配置{0}", mapDB.dwResPath); return; } temptime = Time.realtimeSinceStartup; lastInfo = "none"; // 创建寻路模块 mapID = nMapID; // 预加载 mapName = mapDB.strName;// string.Format("{0}({1})", mapDB.strName, uCountryid); // 不是中转空场景 if (nMapID != GameTableManager.Instance.GetClientGlobalConst <int>("map", "emptyid")) { Engine.Utility.Log.Info("EnterMapStart 读取地图配置表 "); // 读取地图配置表 string strMapName = resDB.strPath.ToLower(); m_strMapTexturePath = strMapName.Replace(".map", "").Substring(strMapName.LastIndexOf('/') + 1); Engine.IScene scene = rs.EnterScene(ref strMapName, this); if (scene != null) { scene.StartLoad(pos); } Engine.Utility.Log.Info("EnterMapStart EnterScene name:{0} ", strMapName); // 场景npc配置 LoadClientMap(mapDB.miniMapInfo.ToLower()); //LoadClienMapArea(strMapName.ToLower().Replace(".map", ".ar")); //SpanUtil.Start(); //if (Application.platform == RuntimePlatform.WindowsEditor) //{ Profiler.BeginSample("LoadARFile"); MapAreaDisplay.Instance.LoadARFile(strMapName.ToLower().Replace(".map", ".ar")); Profiler.EndSample(); //} //SpanUtil.Stop(strMapName + " ar "); string strMPSName = strMapName.Replace(".map", ".mps").ToLower(); // 读取地表障碍信息 LoadObstacle(strMPSName); //SpanUtil.Stop(strMapName + " 地表障碍信息 "); } } else { Engine.Utility.Log.Error("MapSystem:IRenderSystem为空"); } Engine.Utility.EventEngine.Instance().DispatchEvent((int)(int)Client.GameEventID.ENTITYSYSTEM_ENTERMAP, mapID); }
//----------------------------------------------------------------------------------------------- public void AddTransmitMsg(GameCmd.stInviteGoMapRequestUserCmd_CS cmd) { PushMsg msg = new PushMsg(); if (cmd.type == (int)GameCmd.FeiLeiType.FeiLeiType_Clan) { msg.msgType = PushMsg.MsgType.ClanTransmit; msg.cd = (float)GameTableManager.Instance.GetGlobalConfig <int>("ClanTransmitMsgCD"); } else if (cmd.type == (int)GameCmd.FeiLeiType.FeiLeiType_Couple) { msg.msgType = PushMsg.MsgType.CoupleTransmit; msg.cd = (float)GameTableManager.Instance.GetGlobalConfig <int>("CoupleTransmitMsgCD"); } else if (cmd.type == (int)GameCmd.FeiLeiType.FeiLeiType_Team) { msg.msgType = PushMsg.MsgType.TeamTransmit; msg.cd = (float)GameTableManager.Instance.GetGlobalConfig <int>("TeamTransmitMsgCD"); } else if (cmd.type == (int)GameCmd.FeiLeiType.CallUp_CityWarClan) { msg.msgType = PushMsg.MsgType.CityWarClan; msg.cd = (float)GameTableManager.Instance.GetGlobalConfig <int>("ClanTransmitMsgCD"); } else if (cmd.type == (int)GameCmd.FeiLeiType.CallUp_CityWarTeam) { msg.msgType = PushMsg.MsgType.CityWarTeam; msg.cd = (float)GameTableManager.Instance.GetGlobalConfig <int>("ClanTransmitMsgCD"); } msg.senderId = cmd.userid; msg.sendName = cmd.username; msg.sendTime = UnityEngine.Time.realtimeSinceStartup; msg.vector = cmd.pos; table.MapDataBase mdb = GameTableManager.Instance.GetTableItem <table.MapDataBase>(cmd.mapid); if (mdb != null) { msg.map = mdb.strName; msg.mapId = cmd.mapid; } if (DataManager.Manager <ClanManger>().ClanInfo != null) { GameCmd.stClanMemberInfo clanInfo = DataManager.Manager <ClanManger>().ClanInfo.GetMemberInfo(cmd.userid); if (clanInfo != null) { msg.level = (int)clanInfo.level; SelectRoleDataBase data = table.SelectRoleDataBase.Where((GameCmd.enumProfession)clanInfo.job, (GameCmd.enmCharSex) 1); if (data != null) { msg.profession = data.professionName; } } } TeamMemberInfo info = DataManager.Manager <TeamDataManager>().GetTeamMember(cmd.userid); if (info != null) { msg.level = (int)info.lv; SelectRoleDataBase data = table.SelectRoleDataBase.Where((GameCmd.enumProfession)info.job, (GameCmd.enmCharSex) 1); if (data != null) { msg.profession = data.professionName; } } AddSysMsg(msg); if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MessagePushPanel) == false) { if (!DataManager.Manager <ComBatCopyDataManager>().IsEnterCopy) { DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.MessagePushPanel); } } Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.REFRESHTRANSMITPUSHMSGSTATUS, null); }
protected override void OnShow(object data) { base.OnShow(data); UIEventListener.Get(m__wordBg.gameObject).onClick = OnWorldMapClick; IMapSystem mapsys = Client.ClientGlobal.Instance().GetMapSystem(); if (mapsys == null) { Engine.Utility.Log.Error("Mapsystem is null"); return; } if (m_mapid != mapsys.GetMapID()) { if (m_texture == null) { string path = MINIMAP_TEXTURE_PATH + mapsys.GetMapTextureName() + ".unity3d"; Engine.RareEngine.Instance().GetRenderSystem().CreateTexture(ref path, ref m_texture, CreateTextureEvent, path, Engine.TaskPriority.TaskPriority_Immediate); } ClearShowIcon(); mapSize = mapsys.GetMapSize(); if (m_label_MapName != null) { m_label_MapName.text = mapsys.GetMapName(); } m_mapid = mapsys.GetMapID(); table.MapDataBase mdb = GameTableManager.Instance.GetTableItem <table.MapDataBase>(m_mapid); if (mdb != null) { ShowIconOnMap(mdb); } } int count = m__wordBg.transform.childCount; for (int i = 0; i < count; i++) { Transform subItem = m__wordBg.transform.GetChild(i); string[] nameArray = subItem.name.Split('_'); if (nameArray.Length > 1) { int index = 0; if (int.TryParse(nameArray[1], out index)) { if (!m_dicWorldMapTexture.ContainsKey(index)) { Transform texture = subItem.Find("Texture"); if (texture != null) { UITexture mapTex = texture.GetComponent <UITexture>(); if (mapTex != null) { m_dicWorldMapTexture.Add(index, mapTex.mainTexture); m_dicWorldMapTrans.Add(index, subItem); } } } } } } ShowCurrentMap(true); //InitNpcList(); ShowNpcNameOnMap(); ToggleCurMap(""); AddSelfIcon(); m_btn_npcitem.gameObject.SendMessage("OnClick", SendMessageOptions.RequireReceiver); m_label_line_label.text = DataManager.Manager <MapDataManager>().CurLineNum + "线"; NetService.Instance.Send(new GameCmd.stOpenSynTeamPosRelationUserCmd_C()); }
/// <summary> /// 请求读条上马 /// </summary> public bool TryUsingRide(Action <object> callback, object param) { Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem(); if (ms == null) { return(false); } table.MapDataBase mapdata = GameTableManager.Instance.GetTableItem <table.MapDataBase>(ms.GetMapID()); if (mapdata == null) { return(false); } if (mapdata.canUsingRide != 1) { TipsManager.Instance.ShowTips("该地图不能上马"); if (callback != null) { callback(param); } return(false); } Client.IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer; if (mainPlayer != null) { Client.ISkillPart skillpart = mainPlayer.GetPart(Client.EntityPart.Skill) as Client.ISkillPart; if (skillpart != null) { if (skillpart.GetCurSkillState() != (int)Client.SkillState.None) { TipsManager.Instance.ShowTips(LocalTextType.Ride_Commond_shifangjinengzhongwufashangma); if (callback != null) { callback(param); } return(false); } } bool isChangeBody = (bool)mainPlayer.SendMessage(Client.EntityMessage.EntityCommand_IsChange, null); if (isChangeBody) { if (callback != null) { callback(param); } return(false); } bool bRide = DataManager.Manager <RideManager>().IsRide; if (bRide) { if (callback != null) { callback(param); } return(false); } else if (Auto_Ride == 0) { if (callback != null) { callback(param); } return(false); } } UsingRideCallback = callback; UsingRideCallbackParam = param; if (Auto_Ride != 0) { //先发送读条 读条 结束在上马 Client.stUninterruptMagic stparam = new Client.stUninterruptMagic(); if (GetRideDataById(Auto_Ride) != null) { stparam.time = GetRideDataById(Auto_Ride).spellTime; } stparam.type = GameCmd.UninterruptActionType.UninterruptActionType_DEMON; stparam.uid = MainPlayerHelper.GetPlayerUID(); Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.SKILLGUIDE_PROGRESSSTART, stparam); //NetService.Instance.Send(new stUsingRideUserCmd_C()); } return(true); }
void OnLoadSceneCompelete(int nEventID, object param) { // 设置镜头 SetupMainCamera(ClientGlobal.Instance().MainPlayer); if (GameObject.Find("DirectionalLight1") == null) { // 灯光 GameObject pObject = new GameObject(); pObject.name = "DirectionalLight1"; pObject.transform.position = new Vector3(57.74f, 35.87f, -53); Quaternion rot = new Quaternion(); rot.eulerAngles = new Vector3(30f, 145f, 0f); pObject.transform.rotation = rot; Light pLight = pObject.AddComponent <Light>(); pLight.shadows = LightShadows.None; pLight.type = LightType.Directional; pLight.color = new Color(1, 1, 1, 1); pLight.intensity = 0.75f; if (Application.platform == RuntimePlatform.Android) { //pLight.intensity = 0.75f / 2f; } pLight.bounceIntensity = 1; pLight.cullingMask = (1 << LayerMask.NameToLayer("ShowModel")); //阴影 pLight.shadowStrength = 0.39f; pLight.shadowBias = 0.05f; pLight.shadowNormalBias = 0.4f; pLight.shadowNearPlane = 0.2f; pLight.cookieSize = 10; pLight.renderMode = LightRenderMode.Auto; } if (GameObject.Find("DirectionalLight2") == null) { // 灯光 GameObject pObjectLight2 = new GameObject(); pObjectLight2.name = "DirectionalLight2"; pObjectLight2.transform.position = new Vector3(57.74f, 35.87f, -53); Quaternion rot = new Quaternion(); rot.eulerAngles = new Vector3(15f, -95f, 0f); pObjectLight2.transform.rotation = rot; Light pLight = pObjectLight2.AddComponent <Light>(); pLight.shadows = LightShadows.None; pLight.type = LightType.Directional; pLight.color = new Color(74 / 255f, 99f / 255f, 180 / 255f, 1); pLight.intensity = 0.75f; if (Application.platform == RuntimePlatform.Android) { //pLight.intensity = 0.75f / 2f; } pLight.bounceIntensity = 1f; pLight.cullingMask = (1 << LayerMask.NameToLayer("ShowModel")); //阴影 pLight.shadowStrength = 0.39f; pLight.shadowBias = 0.05f; pLight.shadowNormalBias = 0.4f; pLight.shadowNearPlane = 0.2f; pLight.cookieSize = 10; pLight.renderMode = LightRenderMode.Auto; } if (GameObject.Find("DirectionalLight3") == null) { // 灯光 GameObject pObjectLight3 = new GameObject(); pObjectLight3.name = "DirectionalLight3"; pObjectLight3.transform.position = new Vector3(57.74f, 35.87f, -53); Quaternion rot = new Quaternion(); rot.eulerAngles = new Vector3(20f, 10f, 0f); pObjectLight3.transform.rotation = rot; Light pLight = pObjectLight3.AddComponent <Light>(); pLight.shadows = LightShadows.Hard; pLight.type = LightType.Directional; pLight.color = new Color(1, 223f / 255f, 201f / 255f, 1); pLight.intensity = 0.85f; if (Application.platform == RuntimePlatform.Android) { //pLight.intensity = 0.85f / 2f; } pLight.bounceIntensity = 1; pLight.cullingMask = (1 << LayerMask.NameToLayer("ShowModel")); //阴影 pLight.shadowStrength = 0.5f; pLight.shadowBias = 0.05f; pLight.shadowNormalBias = 0.4f; pLight.shadowNearPlane = 0.2f; pLight.cookieSize = 10; pLight.renderMode = LightRenderMode.Auto; } IMapSystem mapSys = ClientGlobal.Instance().GetMapSystem(); if (mapSys != null) { uint uMapID = mapSys.GetMapID(); table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(uMapID); if (mapDB == null) { Engine.Utility.Log.Error("MapSystem:找不到地图配置数据{0}", uMapID); return; } if (mapDB.WaveEffect == 1) { Camera cam = Camera.main; if (cam != null) { postHeatDistortionEffect = cam.GetComponent <PostRenderHeatDistortionEffect>(); if (postHeatDistortionEffect == null) { postHeatDistortionEffect = cam.transform.gameObject.AddComponent <PostRenderHeatDistortionEffect>(); } else { postHeatDistortionEffect.enabled = true; } } } else { Camera cam = Camera.main; if (cam != null) { postHeatDistortionEffect = cam.GetComponent <PostRenderHeatDistortionEffect>(); if (postHeatDistortionEffect != null) { postHeatDistortionEffect.enabled = false; } } } } }