diff --git a/xiaofang/Assets/ProtoBuf/Proto/Join.cs b/xiaofang/Assets/ProtoBuf/Proto/Join.cs index a72b8e1a..e008f776 100644 --- a/xiaofang/Assets/ProtoBuf/Proto/Join.cs +++ b/xiaofang/Assets/ProtoBuf/Proto/Join.cs @@ -30,29 +30,29 @@ public static partial class JoinReflection { "ZXNwb25zZRgLIAEoCzIRLlRhc2tJbmZvUmVzcG9uc2USKwoOb2JqZWN0UmVz", "cG9uc2UYDCABKAsyEy5PYmplY3RJbmZvUmVzcG9uc2UiNwoQUm9vbVVzZXJS", "ZXNwb25zZRIjCgh1c2VyTGlzdBgBIAMoCzIRLlVzZXJKb2luUmVzcG9uc2Ui", - "ogIKEFRhc2tJbmZvUmVzcG9uc2USDgoGVGFza0lkGAEgASgJEg4KBlN0YXR1", + "tgIKEFRhc2tJbmZvUmVzcG9uc2USDgoGVGFza0lkGAEgASgJEg4KBlN0YXR1", "cxgCIAEoCRIOCgZSb29tSWQYAyABKAkSCQoBWBgEIAEoAhIJCgFZGAUgASgC", "EgkKAVoYBiABKAISDAoEVHlwZRgHIAEoCRIRCglUaW1lTGltaXQYCCABKAMS", "DAoERGVzYxgJIAEoCRIPCgdUcmlnZ2VyGAogASgJEhEKCU5leHRUYXNrcxgL", "IAEoCRISCgpUYXJnZXRUeXBlGAwgASgJEg4KBlJld2FyZBgNIAEoCRIMCgRO", "b3RlGA4gASgJEhIKCkNyZWF0ZVRpbWUYDyABKAkSEgoKVXBkYXRlVGltZRgQ", - "IAEoCRIQCghUb1VzZXJJZBgRIAEoCSKvAwoST2JqZWN0SW5mb1Jlc3BvbnNl", - "Eg4KBlJvb21JZBgBIAEoCRIKCgJJZBgCIAEoCRIQCghPYmplY3RJZBgDIAEo", - "CRIMCgROb3RlGAQgASgJEgwKBFR5cGUYBSABKAkSDAoETmFtZRgGIAEoCRIW", - "Cg5OYW1lU2hvd09mZnNldBgHIAEoAxISCgpTaG93UmFkaXVzGAggASgDEgwK", - "BEljb24YCSABKAkSDAoEUm9sZRgKIAEoCRISCgpJdGVtRGVwZW5kGAsgASgJ", - "EhAKCFRha2VUaW1lGAwgASgDEhMKC05lZWRQbGF5ZXJzGA0gASgJEhIKClRh", - "c2tTdGF0dXMYDiABKAkSEgoKU2VsZWN0TGlzdBgPIAEoCRINCgVPbk9mZhgQ", - "IAEoAxIOCgZTdGF0dXMYESABKAkSEQoJUmVzQ2hhbmdlGBIgASgJEhcKD1Bh", - "cmFsbGVsQ29udHJvbBgTIAEoAxISCgpFeHRyYVZhbHVlGBQgASgJEg8KB1Vz", - "ZXJJZHMYFSABKAkSEgoKQ3JlYXRlVGltZRgWIAEoCRISCgpVcGRhdGVUaW1l", - "GBcgASgJQgdaBS4vO3BiYgZwcm90bzM=")); + "IAEoCRIQCghUb1VzZXJJZBgRIAEoCRISCgpCYXNlVGFza0lkGBIgASgJIq8D", + "ChJPYmplY3RJbmZvUmVzcG9uc2USDgoGUm9vbUlkGAEgASgJEgoKAklkGAIg", + "ASgJEhAKCE9iamVjdElkGAMgASgJEgwKBE5vdGUYBCABKAkSDAoEVHlwZRgF", + "IAEoCRIMCgROYW1lGAYgASgJEhYKDk5hbWVTaG93T2Zmc2V0GAcgASgDEhIK", + "ClNob3dSYWRpdXMYCCABKAMSDAoESWNvbhgJIAEoCRIMCgRSb2xlGAogASgJ", + "EhIKCkl0ZW1EZXBlbmQYCyABKAkSEAoIVGFrZVRpbWUYDCABKAMSEwoLTmVl", + "ZFBsYXllcnMYDSABKAkSEgoKVGFza1N0YXR1cxgOIAEoCRISCgpTZWxlY3RM", + "aXN0GA8gASgJEg0KBU9uT2ZmGBAgASgDEg4KBlN0YXR1cxgRIAEoCRIRCglS", + "ZXNDaGFuZ2UYEiABKAkSFwoPUGFyYWxsZWxDb250cm9sGBMgASgDEhIKCkV4", + "dHJhVmFsdWUYFCABKAkSDwoHVXNlcklkcxgVIAEoCRISCgpDcmVhdGVUaW1l", + "GBYgASgJEhIKClVwZGF0ZVRpbWUYFyABKAlCB1oFLi87cGJiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::UserJoinResponse), global::UserJoinResponse.Parser, new[]{ "UserId", "NickName", "RoleName", "RoomId", "Online", "MessageType", "Cmd", "IncidentPosition", "FireRadius", "FireValue", "TaskResponse", "ObjectResponse" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::RoomUserResponse), global::RoomUserResponse.Parser, new[]{ "UserList" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::TaskInfoResponse), global::TaskInfoResponse.Parser, new[]{ "TaskId", "Status", "RoomId", "X", "Y", "Z", "Type", "TimeLimit", "Desc", "Trigger", "NextTasks", "TargetType", "Reward", "Note", "CreateTime", "UpdateTime", "ToUserId" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::TaskInfoResponse), global::TaskInfoResponse.Parser, new[]{ "TaskId", "Status", "RoomId", "X", "Y", "Z", "Type", "TimeLimit", "Desc", "Trigger", "NextTasks", "TargetType", "Reward", "Note", "CreateTime", "UpdateTime", "ToUserId", "BaseTaskId" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::ObjectInfoResponse), global::ObjectInfoResponse.Parser, new[]{ "RoomId", "Id", "ObjectId", "Note", "Type", "Name", "NameShowOffset", "ShowRadius", "Icon", "Role", "ItemDepend", "TakeTime", "NeedPlayers", "TaskStatus", "SelectList", "OnOff", "Status", "ResChange", "ParallelControl", "ExtraValue", "UserIds", "CreateTime", "UpdateTime" }, null, null, null, null) })); } @@ -961,6 +961,7 @@ public sealed partial class TaskInfoResponse : pb::IMessage createTime_ = other.createTime_; updateTime_ = other.updateTime_; toUserId_ = other.toUserId_; + baseTaskId_ = other.baseTaskId_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -1225,6 +1226,21 @@ public sealed partial class TaskInfoResponse : pb::IMessage } } + /// Field number for the "BaseTaskId" field. + public const int BaseTaskIdFieldNumber = 18; + private string baseTaskId_ = ""; + /// + /// 鍩虹浠诲姟id + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public string BaseTaskId { + get { return baseTaskId_; } + set { + baseTaskId_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] public override bool Equals(object other) { @@ -1257,6 +1273,7 @@ public sealed partial class TaskInfoResponse : pb::IMessage if (CreateTime != other.CreateTime) return false; if (UpdateTime != other.UpdateTime) return false; if (ToUserId != other.ToUserId) return false; + if (BaseTaskId != other.BaseTaskId) return false; return Equals(_unknownFields, other._unknownFields); } @@ -1281,6 +1298,7 @@ public sealed partial class TaskInfoResponse : pb::IMessage if (CreateTime.Length != 0) hash ^= CreateTime.GetHashCode(); if (UpdateTime.Length != 0) hash ^= UpdateTime.GetHashCode(); if (ToUserId.Length != 0) hash ^= ToUserId.GetHashCode(); + if (BaseTaskId.Length != 0) hash ^= BaseTaskId.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -1367,6 +1385,10 @@ public sealed partial class TaskInfoResponse : pb::IMessage output.WriteRawTag(138, 1); output.WriteString(ToUserId); } + if (BaseTaskId.Length != 0) { + output.WriteRawTag(146, 1); + output.WriteString(BaseTaskId); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -1445,6 +1467,10 @@ public sealed partial class TaskInfoResponse : pb::IMessage output.WriteRawTag(138, 1); output.WriteString(ToUserId); } + if (BaseTaskId.Length != 0) { + output.WriteRawTag(146, 1); + output.WriteString(BaseTaskId); + } if (_unknownFields != null) { _unknownFields.WriteTo(ref output); } @@ -1506,6 +1532,9 @@ public sealed partial class TaskInfoResponse : pb::IMessage if (ToUserId.Length != 0) { size += 2 + pb::CodedOutputStream.ComputeStringSize(ToUserId); } + if (BaseTaskId.Length != 0) { + size += 2 + pb::CodedOutputStream.ComputeStringSize(BaseTaskId); + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -1569,6 +1598,9 @@ public sealed partial class TaskInfoResponse : pb::IMessage if (other.ToUserId.Length != 0) { ToUserId = other.ToUserId; } + if (other.BaseTaskId.Length != 0) { + BaseTaskId = other.BaseTaskId; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -1656,6 +1688,10 @@ public sealed partial class TaskInfoResponse : pb::IMessage ToUserId = input.ReadString(); break; } + case 146: { + BaseTaskId = input.ReadString(); + break; + } } } #endif @@ -1743,6 +1779,10 @@ public sealed partial class TaskInfoResponse : pb::IMessage ToUserId = input.ReadString(); break; } + case 146: { + BaseTaskId = input.ReadString(); + break; + } } } } diff --git a/xiaofang/Assets/ProtoBuf/test.cs b/xiaofang/Assets/ProtoBuf/test.cs index 6be6ea28..5e29497f 100644 --- a/xiaofang/Assets/ProtoBuf/test.cs +++ b/xiaofang/Assets/ProtoBuf/test.cs @@ -510,7 +510,7 @@ public class test : MonoBehaviour TaskInfoResponse taskInfoResponse = userJoinResponse.TaskResponse; if (long.Parse(taskInfoResponse.ToUserId) == userJoinResponse.UserId)//当这个任务是当前玩家的任务时显示任务 { - //TaskPanel.instance.SetInfo(int.Parse(taskInfoResponse.TaskId)); + TaskPanel.instance.Taskad(int.Parse(taskInfoResponse.TaskId)); } } diff --git a/xiaofang/Assets/Res/HYLUI/TaskPanel.cs b/xiaofang/Assets/Res/HYLUI/TaskPanel.cs index ef08aa81..caf5060d 100644 --- a/xiaofang/Assets/Res/HYLUI/TaskPanel.cs +++ b/xiaofang/Assets/Res/HYLUI/TaskPanel.cs @@ -30,21 +30,30 @@ public class TaskPanel : Base { instance = this; hideBtn.onClick.AddListener(OnClickHideButton); - InitList(); + //InitList(); + //InitTask(taskIDs); + } + + //public void InitList() + //{ + // foreach (Task_ task in JSONReader.TaskDictionary.Values) + // { + // if (int.TryParse(task.ID, out int taskId)) + // { + // // 转换成功,添加到 taskIDs 列表 + // taskIDs.Add(taskId); + // } + // } + //} + + //添加任务 + public void Taskad(int id) + { + taskIDs.Add(id); InitTask(taskIDs); } - public void InitList() - { - foreach (Task_ task in JSONReader.TaskDictionary.Values) - { - if (int.TryParse(task.ID, out int taskId)) - { - // 转换成功,添加到 taskIDs 列表 - taskIDs.Add(taskId); - } - } - } + // 将任务栏收起或显示 public void OnClickHideButton() { @@ -72,13 +81,14 @@ public class TaskPanel : Base } } - // 添加新任务 + // 将每条任务实例化 public void AddTask(int taskId) { GameObject go = Instantiate(taskPrefab, contentTrans); TaskItem taskItem = go.GetComponent(); taskItem.SetInfo(taskId, JSONReader); taskItems.Add(taskItem); + } // 更新任务UI diff --git a/xiaofang/Assets/Scenes/Tmap 1.unity b/xiaofang/Assets/Scenes/Tmap 1.unity index e94456c4..94e2d123 100644 --- a/xiaofang/Assets/Scenes/Tmap 1.unity +++ b/xiaofang/Assets/Scenes/Tmap 1.unity @@ -205,6 +205,160 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: -7087271138916236341, guid: 00003e04dc9a2534eb207f108c7b0cd3, type: 3} +--- !u!1 &14477921 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 14477922} + - component: {fileID: 14477924} + - component: {fileID: 14477923} + m_Layer: 5 + m_Name: targetIcon + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &14477922 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14477921} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1414618301} + m_Father: {fileID: 491544196} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &14477923 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14477921} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &14477924 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 14477921} + m_CullTransparentMesh: 1 +--- !u!1 &18751072 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 18751073} + - component: {fileID: 18751075} + - component: {fileID: 18751074} + m_Layer: 5 + m_Name: jiantou + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &18751073 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 18751072} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1368271978} + m_Father: {fileID: 491544196} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -508, y: 0} + m_SizeDelta: {x: 120, y: 120} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &18751074 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 18751072} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: f98eeb33f86380d43a36894653996414, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &18751075 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 18751072} + m_CullTransparentMesh: 1 --- !u!1 &19367787 GameObject: m_ObjectHideFlags: 0 @@ -6209,7 +6363,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &335603113 RectTransform: m_ObjectHideFlags: 0 @@ -8349,6 +8503,66 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: 8538053082472352065, guid: 00003e04dc9a2534eb207f108c7b0cd3, type: 3} +--- !u!1 &491544195 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 491544196} + - component: {fileID: 491544197} + m_Layer: 5 + m_Name: TargetPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &491544196 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 491544195} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 14477922} + - {fileID: 18751073} + m_Father: {fileID: 1039624185} + m_RootOrder: 18 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &491544197 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 491544195} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f85bf68c934cac1449aee6d0b622d9f9, type: 3} + m_Name: + m_EditorClassIdentifier: + mainCamera: {fileID: 1068997306} + target: {fileID: 1288237632} + uiCanvas: {fileID: 1039624185} + targetIcon: {fileID: 14477922} + distanceText: {fileID: 1414618302} + arrowIcon: {fileID: 18751073} + arrowDistanceText: {fileID: 1368271979} + edgePadding: 50 + textOffset: {x: 0, y: -30} --- !u!1 &496425324 GameObject: m_ObjectHideFlags: 0 @@ -13081,10 +13295,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} m_Name: m_EditorClassIdentifier: - m_UiScaleMode: 0 + m_UiScaleMode: 1 m_ReferencePixelsPerUnit: 100 m_ScaleFactor: 1 - m_ReferenceResolution: {x: 800, y: 600} + m_ReferenceResolution: {x: 1920, y: 1080} m_ScreenMatchMode: 0 m_MatchWidthOrHeight: 0 m_PhysicalUnit: 3 @@ -13144,6 +13358,7 @@ RectTransform: - {fileID: 1469343111} - {fileID: 1081784991} - {fileID: 1359335859} + - {fileID: 491544196} m_Father: {fileID: 0} m_RootOrder: 15 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -22064,6 +22279,86 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: -4669020800935709084, guid: 00003e04dc9a2534eb207f108c7b0cd3, type: 3} +--- !u!1 &1368271977 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1368271978} + - component: {fileID: 1368271980} + - component: {fileID: 1368271979} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1368271978 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1368271977} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 18751073} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1368271979 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1368271977} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 36 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: New Text +--- !u!222 &1368271980 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1368271977} + m_CullTransparentMesh: 1 --- !u!1001 &1379519406 PrefabInstance: m_ObjectHideFlags: 0 @@ -22516,6 +22811,86 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: -2183719134944184998, guid: 00003e04dc9a2534eb207f108c7b0cd3, type: 3} +--- !u!1 &1414618300 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1414618301} + - component: {fileID: 1414618303} + - component: {fileID: 1414618302} + m_Layer: 5 + m_Name: disText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1414618301 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1414618300} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 14477922} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1414618302 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1414618300} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 37 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 86 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: New Text +--- !u!222 &1414618303 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1414618300} + m_CullTransparentMesh: 1 --- !u!64 &1422177304 MeshCollider: m_ObjectHideFlags: 0 @@ -29044,52 +29419,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 24 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1909673636 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1909673638} - - component: {fileID: 1909673637} - m_Layer: 0 - m_Name: BurstCollisionWorld - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1909673637 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1909673636} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3} - m_Name: - m_EditorClassIdentifier: - cellSpans: - m_AlignBytes: 16 ---- !u!4 &1909673638 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1909673636} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 38 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1912789160 PrefabInstance: m_ObjectHideFlags: 0 @@ -29330,6 +29659,52 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: 8711619002567319047, guid: 0c9b084f2070bda45b87da961d2eb0f6, type: 3} +--- !u!1 &1955451351 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1955451353} + - component: {fileID: 1955451352} + m_Layer: 0 + m_Name: BurstCollisionWorld + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1955451352 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1955451351} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3} + m_Name: + m_EditorClassIdentifier: + cellSpans: + m_AlignBytes: 16 +--- !u!4 &1955451353 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1955451351} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 38 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1955845891 PrefabInstance: m_ObjectHideFlags: 0 @@ -40830,7 +41205,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0.0010070801} + m_AnchoredPosition: {x: 0, y: 0.0009460449} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 1} --- !u!1 &5723411037200588897 @@ -43967,10 +44342,15 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4e3938570b1787843b6fe76c1c2b9651, type: 3} m_Name: m_EditorClassIdentifier: - joystickBackground: {fileID: 8163955216411254552} + isDrag: 0 + joystickBackground: {fileID: 8163955216392696351} joystick: {fileID: 8163955215854446702} playerCamera: {fileID: 1068997306} - rotationSpeed: 10 + rotationSpeed: 0.5 + horizontalMinRotation: -75 + horizontalMaxRotation: 75 + verticalMinRotation: -75 + verticalMaxRotation: 75 --- !u!224 &8163955216411254552 RectTransform: m_ObjectHideFlags: 0 diff --git a/xiaofang/Assets/Script/hylScripts/JoystickController.cs b/xiaofang/Assets/Script/hylScripts/JoystickController.cs index cf3e8569..3951f590 100644 --- a/xiaofang/Assets/Script/hylScripts/JoystickController.cs +++ b/xiaofang/Assets/Script/hylScripts/JoystickController.cs @@ -9,14 +9,30 @@ public class JoystickController : MonoBehaviour, IDragHandler, IEndDragHandler public RectTransform joystickBackground; // 摇杆背景 public RectTransform joystick; // 摇杆 public Camera playerCamera; // 摄像机 - public float rotationSpeed = 5f; // 摄像机旋转速度 + public float rotationSpeed = 0.5f; // 摄像机旋转速度 + + // 旋转角度限制 + public float horizontalMinRotation = -75f; // 水平旋转最小值 + public float horizontalMaxRotation = 75f; // 水平旋转最大值 + public float verticalMinRotation = -75f; // 垂直旋转最小值 + public float verticalMaxRotation = 75f; // 垂直旋转最大值 private Vector2 joystickInput = Vector2.zero; + private float currentXRotation = 0f; // 当前的水平旋转角度 + private float currentYRotation = 0f; // 当前的垂直旋转角度 + + private float targetXRotation = 0f; // 目标水平旋转角度 + private float targetYRotation = 0f; // 目标垂直旋转角度 + void Start() { // 初始化摇杆的位置 joystick.anchoredPosition = Vector2.zero; + + // 初始化摄像机的旋转角度 + targetXRotation = playerCamera.transform.eulerAngles.y; + targetYRotation = playerCamera.transform.eulerAngles.x; } // 每帧更新摇杆的输入 @@ -25,28 +41,28 @@ public class JoystickController : MonoBehaviour, IDragHandler, IEndDragHandler if (joystickInput.magnitude > 0) { // 根据摇杆的输入控制摄像机旋转 - float horizontal = joystickInput.x; - float vertical = joystickInput.y; + targetXRotation += joystickInput.x * rotationSpeed * Time.deltaTime; + targetYRotation -= joystickInput.y * rotationSpeed * Time.deltaTime; - // 水平旋转 - playerCamera.transform.Rotate(Vector3.up, horizontal * rotationSpeed * Time.deltaTime); + // 限制水平旋转范围,防止摄像机旋转过头 + targetXRotation = Mathf.Clamp(targetXRotation, horizontalMinRotation, horizontalMaxRotation); - // 垂直旋转 - playerCamera.transform.Rotate(Vector3.left, vertical * rotationSpeed * Time.deltaTime); + // 限制垂直旋转范围,防止摄像机翻转 + targetYRotation = Mathf.Clamp(targetYRotation, verticalMinRotation, verticalMaxRotation); + + // 使用 Quaternion 来平滑过渡到目标旋转角度 + playerCamera.transform.localRotation = Quaternion.Euler(targetYRotation, targetXRotation, 0f); } } // 摇杆拖动时更新摇杆位置和输入 public void OnDrag(PointerEventData eventData) { - isDrag = true; - // 更新摇杆的位置 - joystick.anchoredPosition = joystickInput; - Vector2 localPoint; + // 将触摸位置从屏幕坐标转换为UI本地坐标 RectTransformUtility.ScreenPointToLocalPointInRectangle(joystickBackground, eventData.position, eventData.pressEventCamera, out localPoint); - + // 计算摇杆的输入方向 joystickInput = localPoint.normalized; @@ -56,13 +72,16 @@ public class JoystickController : MonoBehaviour, IDragHandler, IEndDragHandler joystickInput = localPoint.normalized * (joystickBackground.sizeDelta.x / 2); } - + // 更新摇杆的位置 + joystick.anchoredPosition = joystickInput; } // 摇杆松开时重置摇杆位置 public void OnEndDrag(PointerEventData eventData) { isDrag = false; + + // 摇杆松开后重置位置 joystick.anchoredPosition = Vector2.zero; joystickInput = Vector2.zero; } diff --git a/xiaofang/Assets/Script/hylScripts/PlayerState.cs b/xiaofang/Assets/Script/hylScripts/PlayerState.cs index 1400cafb..0ffb3153 100644 --- a/xiaofang/Assets/Script/hylScripts/PlayerState.cs +++ b/xiaofang/Assets/Script/hylScripts/PlayerState.cs @@ -8,6 +8,8 @@ public class PlayerState : MonoBehaviour + + [Header("玩家总血量")] public float totalHp = 100; [Header("玩家当前血量")] diff --git a/xiaofang/Assets/Script/hylScripts/TargetIndicator.cs b/xiaofang/Assets/Script/hylScripts/TargetIndicator.cs new file mode 100644 index 00000000..8234d8c7 --- /dev/null +++ b/xiaofang/Assets/Script/hylScripts/TargetIndicator.cs @@ -0,0 +1,112 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class TargetIndicator : MonoBehaviour +{ + public Camera mainCamera; // 玩家摄像机 + public Transform target; // 目标点 + public RectTransform uiCanvas; // UI Canvas 的 RectTransform + public RectTransform targetIcon; // 目标图标的 UI + public Text distanceText; // 屏幕内显示的距离文本 + public RectTransform arrowIcon; // 屏幕外箭头图标 + public Text arrowDistanceText; // 屏幕外箭头后面的距离文本 + + public float edgePadding = 50f; // 箭头距离屏幕边缘的间距 + public Vector2 textOffset = new Vector2(0, -30); // 文本相对箭头的偏移 + + void Update() + { + // 将目标点从世界坐标转换到屏幕坐标 + Vector3 screenPoint = mainCamera.WorldToScreenPoint(target.position); + + // 检查目标是否在屏幕内 + if (screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < Screen.width && screenPoint.y > 0 && screenPoint.y < Screen.height) + { + // 目标在屏幕内,显示目标图标 + targetIcon.gameObject.SetActive(true); + arrowIcon.gameObject.SetActive(false); // 隐藏箭头 + arrowDistanceText.gameObject.SetActive(false); // 隐藏箭头距离文本 + + // 更新图标位置 + targetIcon.position = screenPoint; + + // 更新屏幕内距离文本 + float distance = Vector3.Distance(mainCamera.transform.position, target.position); + distanceText.text = $"{distance:F1}m"; + } + else + { + // 目标在屏幕外,显示箭头 + targetIcon.gameObject.SetActive(false); + arrowIcon.gameObject.SetActive(true); // 显示箭头 + arrowDistanceText.gameObject.SetActive(true); // 显示箭头距离文本 + + // 如果目标在玩家后方,翻转方向 + if (screenPoint.z < 0) + { + screenPoint.x = Screen.width - screenPoint.x; // 水平翻转 + screenPoint.y = Screen.height - screenPoint.y; // 垂直翻转 + } + + // 计算目标点相对于屏幕中心的方向 + Vector3 direction = (screenPoint - new Vector3(Screen.width / 2, Screen.height / 2, 0)).normalized; + + // 计算箭头在屏幕边界的位置 + Vector3 edgePosition = GetScreenEdgePosition(direction); + + // 设置箭头位置 + arrowIcon.position = edgePosition; + + // 设置距离文本位置(在箭头下方或后面) + Vector3 textPosition = edgePosition + (Vector3)textOffset; + textPosition = ClampToScreenBounds(textPosition); // 限制文本在屏幕范围内 + arrowDistanceText.transform.position = textPosition; + + // 保持距离文本水平显示 + arrowDistanceText.transform.rotation = Quaternion.identity; + + // 更新距离文本内容 + float distance = Vector3.Distance(mainCamera.transform.position, target.position); + arrowDistanceText.text = $"{distance:F1}m"; + + // 旋转箭头使其指向目标方向 + float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; + arrowIcon.rotation = Quaternion.Euler(0, 0, angle); + } + } + + // 计算箭头在屏幕边界的位置 + private Vector3 GetScreenEdgePosition(Vector3 direction) + { + // 计算屏幕宽高 + float halfScreenWidth = Screen.width / 2 - edgePadding; + float halfScreenHeight = Screen.height / 2 - edgePadding; + + // 判断箭头是否应该在屏幕的上下边缘 + float slope = direction.y / direction.x; + if (Mathf.Abs(slope) > halfScreenHeight / halfScreenWidth) + { + // 在上下边缘 + float edgeY = Mathf.Sign(direction.y) * halfScreenHeight + Screen.height / 2; + float edgeX = (edgeY - Screen.height / 2) / slope + Screen.width / 2; + return new Vector3(edgeX, edgeY, 0); + } + else + { + // 在左右边缘 + float edgeX = Mathf.Sign(direction.x) * halfScreenWidth + Screen.width / 2; + float edgeY = slope * (edgeX - Screen.width / 2) + Screen.height / 2; + return new Vector3(edgeX, edgeY, 0); + } + } + + // 限制文本在屏幕范围内 + private Vector3 ClampToScreenBounds(Vector3 position) + { + position.x = Mathf.Clamp(position.x, edgePadding, Screen.width - edgePadding); + position.y = Mathf.Clamp(position.y, edgePadding, Screen.height - edgePadding); + return position; + } +} diff --git a/xiaofang/Assets/Script/hylScripts/TargetIndicator.cs.meta b/xiaofang/Assets/Script/hylScripts/TargetIndicator.cs.meta new file mode 100644 index 00000000..0276be98 --- /dev/null +++ b/xiaofang/Assets/Script/hylScripts/TargetIndicator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f85bf68c934cac1449aee6d0b622d9f9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: