void OnTriggerExit(Collider other) { if (other.isTrigger) { return; } Transform targetObj = other.transform; while (null != targetObj && targetObj.name != "body") { targetObj = targetObj.parent; } if (null == targetObj) { return; } ActorProp prop = targetObj.parent.GetComponent <ActorProp>(); if (null == prop) { return; } if (!ClientNet.Singleton.IsConnected || prop.Type != ActorType.enMain) { return; } if (prop.ID != ActorManager.Singleton.MainActor.ID) { return; } SceneFuncPoint pointComp = gameObject.GetComponent <SceneFuncPoint>(); if (pointComp == null) { return; } if (pointComp.m_pointType != ENScenePointType.triggerArea) { return; } int triggerID = pointComp.m_triggerAreaInfo.m_triggerID; if (triggerID != 0) { //发送触发区域事件 modify by luozj //ClientNet.Singleton.SendPacket(new AreaOnTriggerPacket(ENTriggerOpt.enExit, triggerID)); } if (pointComp.m_triggerAreaInfo.m_triggerType == ENTriggerType.enOnceTrigger) { gameObject.GetComponent <Collider>().enabled = false; } }
public void OnTriggerEnter(Collider other) { if (other.isTrigger) { return; } Transform targetObj = other.transform; while (null != targetObj && targetObj.name != "body") { targetObj = targetObj.parent; } if (null == targetObj) { return; } ActorProp prop = targetObj.parent.GetComponent <ActorProp>(); if (null == prop) { return; } if (!ClientNet.Singleton.IsConnected || prop.Type != ActorType.enMain) { return; } if (prop.ID != ActorManager.Singleton.MainActor.ID) { return; } SceneFuncPoint pointComp = gameObject.GetComponent <SceneFuncPoint>(); if (pointComp == null) { return; } if (pointComp.m_pointType != ENScenePointType.triggerArea) { return; } //int triggerID = pointComp.m_triggerAreaInfo.m_triggerID; //UIPlayerGuide playerGuide = UIManager.Singleton.GetUI<UIPlayerGuide>(); //playerGuide.ShowWindow(); //playerGuide.SetTriggerID(triggerID); //if (triggerID != 0) //{ // //发送触发区域事件 // ClientNet.Singleton.SendPacket(new AreaOnTriggerPacket(ENTriggerOpt.enEnter, triggerID)); //} }
public static void SaveSceneAreas(GameObject monsterNode) { if (monsterNode == null) { return; } if (monsterNode.name == "") { Debug.Log("必须给物体起名,该名字将作为保存的二进制文件的名字"); } int areaCount = monsterNode.transform.childCount; SceneAreas sceneAreas = new SceneAreas(); for (int areaIndex = 0; areaIndex < areaCount; areaIndex++) { Transform tarAreaTrans = monsterNode.transform.GetChild(areaIndex); //一个区域 SceneArea newArea = new SceneArea(); newArea.m_areaName = tarAreaTrans.name; int funcPointCount = tarAreaTrans.childCount; for (int funcPointIndex = 0; funcPointIndex < funcPointCount; funcPointIndex++) { Transform tarPoint = tarAreaTrans.GetChild(funcPointIndex); SceneFuncPoint funcPoint = tarPoint.GetComponent <SceneFuncPoint>(); if (funcPoint == null || funcPoint.m_pointType == ENScenePointType.none) { Debug.Log(tarPoint.name + " has no component 'SceneFuncPoint' or it is 'none' "); return; } switch (funcPoint.m_pointType) { case ENScenePointType.normalNPC: FuncNPCInfo normalNpc = funcPoint.m_npcInfo; normalNpc.m_pos = tarPoint.localPosition; newArea.m_normalNpcList.Add(normalNpc); break; case ENScenePointType.blockNPC: FuncNPCInfo blockNpc = funcPoint.m_npcInfo; blockNpc.m_pos = tarPoint.localPosition; newArea.m_blockNpcList.Add(blockNpc); break; case ENScenePointType.triggerArea: TriggerAreaInfo triggerAreaInfo = funcPoint.m_triggerAreaInfo; triggerAreaInfo.m_pos = tarPoint.localPosition; newArea.m_triggerAreaList.Add(triggerAreaInfo); break; case ENScenePointType.spawnPoint: SpawnPointInfo spawnPointInfo = funcPoint.m_spawnPointInfo; spawnPointInfo.m_pos = tarPoint.localPosition; spawnPointInfo.m_areaScale = tarPoint.localScale; for (int index = 0; index < funcPoint.m_spawnPointInfo.m_spawnPointsId.Count; index++) { spawnPointInfo.m_spawnPointsId.Add(funcPoint.m_spawnPointInfo.m_spawnPointsId[index]); } newArea.m_spawnPointList.Add(spawnPointInfo); break; } } sceneAreas.m_areaList.Add(newArea); } using (FileStream targetFile = new FileStream("Assets/Resources/Prefabs/ScenePrefabs/" + monsterNode.name + ".bytes", FileMode.Create)) { BinaryHelper helper = new BinaryHelper(); sceneAreas.Save(helper); byte[] saveBytes = helper.GetBytes(); targetFile.Write(saveBytes, 0, saveBytes.Length); Debug.Log(monsterNode.name + ".bytes Success Saved"); } }