public void addMapWarp(MapWarp warp, int addOrDelete = OPERATE_ADD) { if (warpCollection.ContainsValue(warp) && addOrDelete == OPERATE_ADD) { Debug.Log("这个npc(boss)已经被添加过了"); } else if (warpCollection.ContainsValue(warp) && addOrDelete == OPERATE_DELETE) { warpCollection.Remove(warp.id); } else if (!warpCollection.ContainsValue(warp) && addOrDelete == OPERATE_ADD) { warpCollection[warp.id] = warp; } float h1 = terrainMan.GetHeight(warp.warpX, warp.warpY); Vector3 npcPos = new Vector3(warp.warpX, h1, warp.warpY); mapWarpMgr.Preload("scene_portal_e", npcPos, warp.id.ToString()); // mapNpcMgr.ShowSkillFx((GameObject.Find(RoleCtrl) as RoleCtrl), "n_fujiaertongnv"); mapWarpMgr.ShowSkillFx(null, "scene_portal_e", npcPos); }
void Start() { Timer2Runner timer2 = base.gameObject.GetComponent <Timer2Runner>(); if (timer2 == null) { GameObject.Destroy(timer2); timer2 = null; } base.gameObject.AddComponent <Timer2Runner>(); mainRoleCtrl = mainRole.AddComponent <RoleCtrlDemo>(); #if UNITY_EDITOR AssetLoader2.m_SimulateAssetBundleInEditor = true; #endif //base.gameObject.AddComponent<AssetLoader>(); base.gameObject.AddComponent <AssetLoader2>(); terrainMan = new TestTerrainManager(); fxMan = new TestFxManager(); #if UNITY_EDITOR getMapId(); #endif EditMapCameraManager.Instance.mapResId = mapResId; //EditMapCameraManager.Instance.use_tile_101002 = true; //AssetLoader.Instance.LoadBytes("/data/config_" + ConfigAsset.Instance.VERSION + ".dat", onLoadConfig, null); //AssetLoader2.Instance.LoadAsset("map/" + mapId , mapId, typeof(TextAsset), onLoadMap); onloadTitle(); Vector3 pos = mainRole.transform.position; pos.y = terrainMan.GetHeight(pos.x, pos.z); mainRole.transform.position = pos; mainRoleCtrl.terrainMan = terrainMan; mainRoleCtrl.fxMan = fxMan; jueseMan = new jueseFxManager(); mainRoleCtrl.jueseMan = jueseMan; curRole = "z_women1"; EventDelegate.Add(skillButton[0].GetComponent <UIEventTrigger>().onClick, onClickSkillBtn0); EventDelegate.Add(skillButton[1].GetComponent <UIEventTrigger>().onClick, onClickSkillBtn1); EventDelegate.Add(skillButton[2].GetComponent <UIEventTrigger>().onClick, onClickSkillBtn2); EventDelegate.Add(skillButton[3].GetComponent <UIEventTrigger>().onClick, onClickSkillBtn3); EventDelegate.Add(skillButton[4].GetComponent <UIEventTrigger>().onClick, onClickSkillBtn4); EventDelegate.Add(skillButton[5].GetComponent <UIEventTrigger>().onClick, onClickSkillBtn5); EventDelegate.Add(zuoqi.GetComponent <UIEventTrigger>().onClick, onZuoqi); EventDelegate.Add(huanjue.GetComponent <UIEventTrigger>().onClick, onHuanjue); //AssetLoader2.Instance.LoadAsset("data/config_" + ConfigAsset.Instance.VERSION + ".dat", "data/config_" + ConfigAsset.Instance.VERSION + ".dat", typeof(TextAsset), onLoadConfig); StartCoroutine(InitModel()); }
void UpdateWalk() { if (curStep == null) { return; } float tm = Time.realtimeSinceStartup; float ratio = (tm - startTm) / stepTm; //LoggerHelper.Debug("lerp ratio:" + ratio); Vector3 pos = destPos; if (ratio >= 1) { curStep = DequeueStep(); if (curStep == null) { OnWalkEnd(); } else { startPos = destPos; destPos = PathUtilEdit.LogicCenter2Real(curStep.pt); stepTm = (destPos - startPos).sqrMagnitude / moveSpeed; startTm = Time.realtimeSinceStartup; } } else { pos = Vector3.Lerp(startPos, destPos, ratio); } pos.y = terrainMan.GetHeight(pos.x, pos.z); // LoggerHelper.Debug("pos:" + pos); trans.position = pos; LODLoader.rolePos = pos; }
/** * 渲染网格 */ void OnTDrawGizmos() { CreateLineMaterial(); // set the current material lineMaterial.SetPass(0); GL.Begin(GL.LINES); GL.Color(new Color(1, 1, 1, 1)); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; LayerMask nl = LayerConst.MASK_GROUND; if (Physics.Raycast(ray, out hit, 1500.0f, nl)) { } if (isMouseGrid && terrainMan != null) { camposx = (hit.point.x - terrainMan.pathFinder.origin_x) / ConstantsRes.GRID_SIZE - 1; camposz = (-(hit.point.z - terrainMan.pathFinder.origin_z)) / ConstantsRes.GRID_SIZE - 1; } else if (terrainMan != null) { camposx = (hit.point.x - terrainMan.pathFinder.origin_x) / ConstantsRes.GRID_SIZE; camposz = (-(hit.point.z - terrainMan.pathFinder.origin_z)) / ConstantsRes.GRID_SIZE; } else { return; } // Debug.Log("camposx:" + camposx + ",camposz:" + camposz + ",mapWidth:" + terrainMan.pathFinder.mapWidth + "," + terrainMan.pathFinder.mapHeight); for (uint i = 0; i < terrainMan.pathFinder.mapWidth; i++) { for (uint j = 0; j < terrainMan.pathFinder.mapHeight; j++) { if (isMouseGrid) { if (camposx - i > (int)(terrainMan.pathFinder.edit_col_num / 2) || camposx - i < -(int)(terrainMan.pathFinder.edit_col_num / 2)) { continue; } if (camposz - j > (int)(terrainMan.pathFinder.edit_col_num / 2) || camposz - j < -(int)(terrainMan.pathFinder.edit_col_num / 2)) { continue; } if (terrainMan.pathFinder.edit_flag == 0) { GL.Color(new Color(0f, 1f, 0f, 1f)); } else { GL.Color(new Color(1f, 0f, 0f, 1f)); } } else { if (camposx - i > gridSize || camposx - i < -gridSize) { continue; } if (camposz - j > gridSize || camposz - j < -gridSize) { continue; } GL.Color(GetColor((int)i, (int)j)); } //GL.Vertex3(i * Constants.GRID_SIZE, heightOff + terrainMan.GetHeight(i, j), -j * Constants.GRID_SIZE); //GL.Vertex3(i * Constants.GRID_SIZE, heightOff + terrainMan.GetHeight(i, (j + 1)), -(j + 1) * Constants.GRID_SIZE); float h1 = terrainMan.GetHeight(i, j); if (Mathf.Abs(h1 - target.position.y) > 1) { h1 = target.position.y; } float h2 = terrainMan.GetHeight(i, (j + 1)); if (Mathf.Abs(h2 - target.position.y) > 1) { h2 = target.position.y; } GL.Vertex3(i * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_x, heightOff + h1, -j * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_z); GL.Vertex3(i * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_x, heightOff + h2, -(j + 1) * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_z); } } for (uint i = 0; i < terrainMan.pathFinder.mapWidth; i++) { for (uint j = 0; j < terrainMan.pathFinder.mapHeight; j++) { if (isMouseGrid) { if (camposx - i > (int)(terrainMan.pathFinder.edit_col_num / 2) || camposx - i < -(int)(terrainMan.pathFinder.edit_col_num / 2)) { continue; } if (camposz - j > (int)(terrainMan.pathFinder.edit_col_num / 2) || camposz - j < -(int)(terrainMan.pathFinder.edit_col_num / 2)) { continue; } if (terrainMan.pathFinder.edit_flag == 0) { GL.Color(new Color(0f, 1f, 0f, 1f)); } else { GL.Color(new Color(1f, 0f, 0f, 1f)); } } else { if (camposx - i > gridSize || camposx - i < -gridSize) { continue; } if (camposz - j > gridSize || camposz - j < -gridSize) { continue; } GL.Color(GetColor((int)i, (int)j)); } //GL.Vertex3(i * Constants.GRID_SIZE, heightOff + terrainMan.GetHeight(i, j), -j * Constants.GRID_SIZE); //GL.Vertex3((i + 1) * Constants.GRID_SIZE, heightOff + terrainMan.GetHeight(i + 1, j), -j * Constants.GRID_SIZE); float h1 = terrainMan.GetHeight(i, j); if (Mathf.Abs(h1 - target.position.y) > 1) { h1 = target.position.y; } float h2 = terrainMan.GetHeight(i + 1, j); if (Mathf.Abs(h2 - target.position.y) > 1) { h2 = target.position.y; } GL.Vertex3(i * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_x, heightOff + h1, -j * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_z); GL.Vertex3((i + 1) * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_x, heightOff + h2, -j * ConstantsRes.GRID_SIZE + terrainMan.pathFinder.origin_z); } } GL.End(); // DrawSelectState(); //DrawPath(); }