WIP: Transmit services

This commit is contained in:
Le Duc Anh
2026-04-30 17:40:26 +07:00
parent aaf421d345
commit 7853bd2dd6
8 changed files with 332 additions and 10 deletions
@@ -12,9 +12,21 @@ namespace BrewMonster.UI
{
[SerializeField] private Image mapImage;
[SerializeField] private Image _hostPlayerPositionImage;
[Space(10)]
[SerializeField] private float _positionFactor = 2f;
[SerializeField] private Button _closeButton;
[Space(10)]
[Header("Transmit Points")]
[SerializeField] private RectTransform _transPointButtonParent;
// this is the prefab for the trans point button
[SerializeField] private WorldMapTransPoint _transPointButtonPrefab;
private Dictionary<int, WorldMapTransPoint> _transPoints = new();
// 世界 / World
const int MAJOR_MAP = 1;
@@ -66,7 +78,7 @@ namespace BrewMonster.UI
Vector3 _hostPlayerPosition;
Quaternion _hostPlayerRotation;
private void UpdateHostPlayerPositionImage()
private void UpdateHostPlayerPositionImage()
{
if (_hostPlayerPositionImage == null)
{
@@ -95,6 +107,35 @@ namespace BrewMonster.UI
hostPlayerRectTransform.localRotation = Quaternion.Euler(0, 0, -_hostPlayerRotation.eulerAngles.y);
}
/// <summary>
/// If use use Transmit Scroll or Transmit Service, we have to show the transmit points on the map.
/// </summary>
private void ShowTranPoints()
{
CECGameUIMan pGameUI = CECUIManager.Instance.GetInGameUIMan();
var transPoints = pGameUI.GetMapDlgsMgr().m_transPoints;
WorldMapTransPoint transPointObject = null;
int currentMapId = (int)GetDataPtr("WorldID");
foreach(var transPointPair in transPoints)
{
// check if the trans point is already created. If not, create it.
if(_transPoints.TryGetValue(transPointPair.Key, out transPointObject))
{
// now enable the trans point object
transPointObject.gameObject.SetActive(true);
}
else
{
// create the trans point object
transPointObject = Instantiate(_transPointButtonPrefab, _transPointButtonParent);
transPointObject.Init(this, transPointPair.Key);
transPointObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(transPointPair.Value.vecPos.x / _positionFactor, transPointPair.Value.vecPos.z / _positionFactor);
_transPoints[transPointPair.Key] = transPointObject;
transPointObject.gameObject.SetActive(true);
}
}
}
private bool TryGetHostPlayerPosition(out Vector3 hostPlayerPosition, out Quaternion hostPlayerRotation)
{
hostPlayerPosition = Vector3.zero;
@@ -134,9 +175,10 @@ namespace BrewMonster.UI
var worldInstanceName = UnityGameSession.Instance.GetWorldInstanceName((int)serviceData.id);
// save the worldid
// SetDataPtr((void*)worldid, "WorldID");
SetDataPtr(worldid, "WorldID");
// pMgr->LoadMapTexture(m_pA3DDevice, pImage, CECMapDlgsMgr::MAP_TYPE_TRANSMIT);
ShowTranPoints();
}
else if(dwType == (uint)DATA_TYPE.DT_TRANSMITSCROLL_ESSENCE)
{
@@ -166,6 +208,18 @@ namespace BrewMonster.UI
OnCloseButtonClicked();
}
public void OnTransPointClicked(int id)
{
var transPoints = CECUIManager.Instance.GetInGameUIMan().GetMapDlgsMgr().m_transPoints;
if(transPoints.TryGetValue(id, out var transPoint))
{
UnityGameSession.c2s_CmdGoto(transPoint.vecPos.x, transPoint.vecPos.y, transPoint.vecPos.z);
// close the map
OnCloseButtonClicked();
}
}
private void OnCloseButtonClicked()
{
CloseDialogue();
@@ -12,6 +12,10 @@ namespace BrewMonster.UI
public DlgWorldMap dlgWorldMap;
// if true, user can click on the map to move the host player to the clicked position.
// ideally we only enble this for testing/development.
[SerializeField] private bool _enableClickToMove = true;
// The host player player (0,0,0) is not at the center of the map. It usually has an offset that we have to calculate at Awake
private Vector2 _hostPlayerOffsetPosition;
@@ -38,6 +42,8 @@ namespace BrewMonster.UI
// This triggers automatically when the user clicks/taps on this Image
public void OnPointerClick(PointerEventData eventData)
{
if(!_enableClickToMove) return;
Vector2 localCursorPosition;
// Convert the screen click position to local anchored position inside the Map
@@ -0,0 +1,26 @@
using UnityEngine;
namespace BrewMonster.UI
{
/// <summary>
/// This script should be attached to the trans point button in the world map.
/// A Transmit Point will show up when user use Transmit Scroll or Transmit Service. (Dịch vụ dịch chuyển ở NPC)
/// </summary>
public class WorldMapTransPoint : MonoBehaviour
{
[HideInInspector] public int id;
private DlgWorldMap _dlgWorldMap;
public void Init(DlgWorldMap dlgWorldMap, int id)
{
_dlgWorldMap = dlgWorldMap;
this.id = id;
}
public void OnClick()
{
_dlgWorldMap.OnTransPointClicked(id);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 252f6fb85c7e72d49b2e8ea20c2d59c8
@@ -6,7 +6,7 @@ TextureImporter:
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
@@ -37,13 +37,13 @@ TextureImporter:
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
@@ -52,9 +52,9 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
@@ -139,7 +139,7 @@ TextureImporter:
customData:
physicsShape: []
bones: []
spriteID:
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 34c21eadb8c5ac749a341f92da503988
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -75,6 +75,153 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &222794976166085183
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8205908652006291613}
- component: {fileID: 701947802954970172}
- component: {fileID: 4401574036847015979}
- component: {fileID: 6841128026403163401}
- component: {fileID: 2537562987844392478}
m_Layer: 0
m_Name: TransmitPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &8205908652006291613
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 222794976166085183}
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: 6891421740142056974}
m_Father: {fileID: 7169122999130120872}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.518}
m_AnchorMax: {x: 0.5, y: 0.518}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 12, y: 12.000002}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &701947802954970172
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 222794976166085183}
m_CullTransparentMesh: 1
--- !u!114 &4401574036847015979
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 222794976166085183}
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: bd0c1ffed4c1947fe817f36f72257283, 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!114 &6841128026403163401
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 222794976166085183}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 0
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 4401574036847015979}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2537562987844392478}
m_TargetAssemblyTypeName: BrewMonster.UI.WorldMapTransPoint, Assembly-CSharp
m_MethodName: OnClick
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &2537562987844392478
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 222794976166085183}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 252f6fb85c7e72d49b2e8ea20c2d59c8, type: 3}
m_Name:
m_EditorClassIdentifier:
id: 0
--- !u!1 &936441858863998774
GameObject:
m_ObjectHideFlags: 0
@@ -232,6 +379,81 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &3185449669602415166
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6891421740142056974}
- component: {fileID: 4819673339622355777}
- component: {fileID: 603420354022532661}
m_Layer: 0
m_Name: hitbox
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6891421740142056974
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3185449669602415166}
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: 8205908652006291613}
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: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4819673339622355777
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3185449669602415166}
m_CullTransparentMesh: 1
--- !u!114 &603420354022532661
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3185449669602415166}
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: 0.003921569}
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!1 &4370684628053341786
GameObject:
m_ObjectHideFlags: 0
@@ -363,6 +585,8 @@ MonoBehaviour:
_hostPlayerPositionImage: {fileID: 4036230907032538800}
_positionFactor: 1.8
_closeButton: {fileID: 8858186809287203567}
_transPointButtonParent: {fileID: 7169122999130120872}
_transPointButtonPrefab: {fileID: 2537562987844392478}
--- !u!1 &8308536083041954008
GameObject:
m_ObjectHideFlags: 0
@@ -547,6 +771,7 @@ RectTransform:
- {fileID: 5906545349664091413}
- {fileID: 1510574663178069641}
- {fileID: 9142400375056319150}
- {fileID: 8205908652006291613}
m_Father: {fileID: 7323734624486819451}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
@@ -606,3 +831,4 @@ MonoBehaviour:
m_EditorClassIdentifier:
_hostPlayerPositionImage: {fileID: 5906545349664091413}
dlgWorldMap: {fileID: 135853640611757204}
_enableClickToMove: 1