Commit 585fec25 authored by Senator John's avatar Senator John 💬

Merge branch 'patch' into 'master'

Patch

See merge request !39
parents 7c15b217 4005b33f
...@@ -56,6 +56,87 @@ namespace MDPro3 ...@@ -56,6 +56,87 @@ namespace MDPro3
manager.GetElement<RawImage>("Card").material = mat; manager.GetElement<RawImage>("Card").material = mat;
} }
private static bool IsPendulumEffectContext(Card data, GPS p)
{
return p != null
&& (((p.location & (uint)CardLocation.PendulumZone) > 0)
|| ((p.location & (uint)CardLocation.SpellZone) > 0
&& !data.HasType(CardType.Equip)
&& !data.HasType(CardType.Continuous)
&& !data.HasType(CardType.Trap)));
}
private static string WrapInactiveText(string text)
{
return string.IsNullOrEmpty(text) ? string.Empty : "<color=#666666>" + text + "</color>";
}
private static string BuildPendulumDescription(Card data, Card origin, GPS p)
{
var inPendulumContext = IsPendulumEffectContext(data, p);
var inMonsterContext = p != null && (p.location & (uint)CardLocation.MonsterZone) > 0;
if (!inPendulumContext && !inMonsterContext)
return data.GetDescription(true);
var setName = data.GetSetNameWithColor();
var pendulumText = origin.GetPendulumDescription()?.Trim('\r', '\n');
var monsterText = origin.GetMonsterDescription()?.Trim('\r', '\n');
if (Language.GetConfig() == Language.Korean)
{
var monsterHeader = InterString.Get("【怪兽效果】");
if (!data.HasType(CardType.Effect))
monsterHeader = InterString.Get("【怪兽描述】");
monsterHeader = Card.NormalizeBracketLabel(monsterHeader);
var pendulumHeader = Card.NormalizeBracketLabel(InterString.Get("【灵摆效果】"));
var pendulumBlock = pendulumHeader + "\n" + (pendulumText ?? string.Empty);
var monsterBlock = monsterHeader + "\n" + (monsterText ?? string.Empty);
if (inPendulumContext)
return setName + pendulumBlock + "\n" + WrapInactiveText(monsterBlock);
if (inMonsterContext)
return setName + monsterBlock + "\n" + WrapInactiveText(pendulumBlock);
return data.GetDescription(true);
}
var pendulumHeaderDefault = Card.NormalizeBracketLabel(InterString.Get("【灵摆效果】"));
var result = setName;
if (!string.IsNullOrEmpty(monsterText))
result += inPendulumContext ? WrapInactiveText(monsterText) : monsterText;
if (!string.IsNullOrEmpty(pendulumText))
{
var pendulumBlock = pendulumHeaderDefault + "\n" + pendulumText;
if (!string.IsNullOrEmpty(monsterText))
{
if (inMonsterContext)
{
result += "\n" + WrapInactiveText(Card.PendulumSeparatorLine + "\n" + pendulumBlock);
}
else if (inPendulumContext)
{
result += WrapInactiveText("\n" + Card.PendulumSeparatorLine) + "\n" + pendulumBlock;
}
else
{
result += "\n" + Card.PendulumSeparatorLine + "\n" + pendulumBlock;
}
}
else
{
if (!string.IsNullOrEmpty(result))
result += "\n";
result += inMonsterContext ? WrapInactiveText(pendulumBlock) : pendulumBlock;
}
}
return result;
}
public void Show(GameCard card, Material mat, int code = -1, GPS gps = null) public void Show(GameCard card, Material mat, int code = -1, GPS gps = null)
{ {
Card data; Card data;
...@@ -124,26 +205,7 @@ namespace MDPro3 ...@@ -124,26 +205,7 @@ namespace MDPro3
manager.GetElement<Text>("TextType").text = data.GetTypeForUI(); manager.GetElement<Text>("TextType").text = data.GetTypeForUI();
if (data.HasType(CardType.Pendulum)) if (data.HasType(CardType.Pendulum))
{ manager.GetElement<TextMeshProUGUI>("TextDescription").text = tails + BuildPendulumDescription(data, origin, p);
var texts = origin.GetDescriptionSplit();
string monster = InterString.Get("【怪兽效果】");
if (!data.HasType(CardType.Effect))
monster = InterString.Get("【怪兽描述】");
if (p != null
&& ((p.location & (uint)CardLocation.PendulumZone) > 0 ||
((p.location & (uint)CardLocation.SpellZone) > 0
&& !data.HasType(CardType.Equip)
&& !data.HasType(CardType.Continuous)
&& !data.HasType(CardType.Trap))))
manager.GetElement<TextMeshProUGUI>("TextDescription").text = tails + data.GetSetNameWithColor() + InterString.Get("【灵摆效果】") + "\n" + texts[0] + "\n"
+ "<color=#666666>" + monster + "\n" + texts[1] + "</color>";
else if (p != null && (p.location & (uint)CardLocation.MonsterZone) > 0)
manager.GetElement<TextMeshProUGUI>("TextDescription").text = tails + data.GetSetNameWithColor() + monster + "\n" + texts[1] + "\n"
+ "<color=#666666>" + InterString.Get("【灵摆效果】") + "\n" + texts[0] + "</color>";
else
manager.GetElement<TextMeshProUGUI>("TextDescription").text = tails + data.GetSetNameWithColor() + InterString.Get("【灵摆效果】") + "\n" + texts[0] + "\n"
+ monster + "\n" + texts[1];
}
else else
manager.GetElement<TextMeshProUGUI>("TextDescription").text = tails + data.GetSetNameWithColor() + data.Desc; manager.GetElement<TextMeshProUGUI>("TextDescription").text = tails + data.GetSetNameWithColor() + data.Desc;
......
...@@ -1607,7 +1607,7 @@ namespace MDPro3 ...@@ -1607,7 +1607,7 @@ namespace MDPro3
if (model == null) if (model == null)
return; return;
var mode = CurrentReplayGodView && p.InLocation(CardLocation.Hand) && !p.InMyControl() var mode = p.InLocation(CardLocation.Hand) && !p.InMyControl()
? ShadowCastingMode.Off ? ShadowCastingMode.Off
: ShadowCastingMode.On; : ShadowCastingMode.On;
var cardModel = manager.GetElement<Transform>("CardModel"); var cardModel = manager.GetElement<Transform>("CardModel");
......
...@@ -84,6 +84,7 @@ namespace MDPro3.Duel ...@@ -84,6 +84,7 @@ namespace MDPro3.Duel
opActivated.Clear(); opActivated.Clear();
Program.instance.ocgcore.GetUI<OcgCoreUI>().CardDescription.Hide(); Program.instance.ocgcore.GetUI<OcgCoreUI>().CardDescription.Hide();
Program.instance.ocgcore.GetUI<OcgCoreUI>().CardList.Hide(); Program.instance.ocgcore.GetUI<OcgCoreUI>().CardList.Hide();
Program.instance.ocgcore.GetUI<OcgCoreUI>().ResetBgDetailState();
surrendered = false; surrendered = false;
tagSurrendered = false; tagSurrendered = false;
deckReserved = false; deckReserved = false;
...@@ -818,6 +819,7 @@ namespace MDPro3.Duel ...@@ -818,6 +819,7 @@ namespace MDPro3.Duel
mySummonCount++; mySummonCount++;
else else
opSummonCount++; opSummonCount++;
Core.GetUI<OcgCoreUI>().RefreshBgDetail();
var se = "SE_LAND_NORMAL"; var se = "SE_LAND_NORMAL";
...@@ -910,6 +912,7 @@ namespace MDPro3.Duel ...@@ -910,6 +912,7 @@ namespace MDPro3.Duel
mySpSummonCount++; mySpSummonCount++;
else else
opSpSummonCount++; opSpSummonCount++;
Core.GetUI<OcgCoreUI>().RefreshBgDetail();
if (card.GetData().HasType(CardType.Token)) if (card.GetData().HasType(CardType.Token))
goto TokenPass; goto TokenPass;
...@@ -1968,6 +1971,7 @@ namespace MDPro3.Duel ...@@ -1968,6 +1971,7 @@ namespace MDPro3.Duel
mySpSummonCount = 0; mySpSummonCount = 0;
opSummonCount = 0; opSummonCount = 0;
opSpSummonCount = 0; opSpSummonCount = 0;
Core.GetUI<OcgCoreUI>().RefreshBgDetail();
turns++; turns++;
myTurn = isFirst ? (turns % 2 != 0) : (turns % 2 == 0); myTurn = isFirst ? (turns % 2 != 0) : (turns % 2 == 0);
duelBGManager.OnNewTurn(myTurn, turns); duelBGManager.OnNewTurn(myTurn, turns);
......
...@@ -262,7 +262,7 @@ namespace MDPro3.Duel.YGOSharp ...@@ -262,7 +262,7 @@ namespace MDPro3.Duel.YGOSharp
return normalized == UNKNOWN_BATTLE_VALUE ? "?" : normalized.ToString(); return normalized == UNKNOWN_BATTLE_VALUE ? "?" : normalized.ToString();
} }
private static readonly string PendulumSeparatorLine = new string('─', 14); internal static readonly string PendulumSeparatorLine = new string('─', 14);
public string GetDescription(bool withSetName = false) public string GetDescription(bool withSetName = false)
{ {
...@@ -311,7 +311,7 @@ namespace MDPro3.Duel.YGOSharp ...@@ -311,7 +311,7 @@ namespace MDPro3.Duel.YGOSharp
+ "\n" + monsterHeader + "\n" + (monsterText ?? string.Empty); + "\n" + monsterHeader + "\n" + (monsterText ?? string.Empty);
} }
private static string NormalizeBracketLabel(string label) internal static string NormalizeBracketLabel(string label)
{ {
if (string.IsNullOrEmpty(label)) if (string.IsNullOrEmpty(label))
return string.Empty; return string.Empty;
......
...@@ -7,6 +7,7 @@ using System.IO; ...@@ -7,6 +7,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
...@@ -224,16 +225,19 @@ namespace MDPro3 ...@@ -224,16 +225,19 @@ namespace MDPro3
#region Online #region Online
public static async Task<Texture2D> DownloadImageAsync(string url) public static async Task<Texture2D> DownloadImageAsync(string url, CancellationToken cancellationToken = default)
{ {
using var request = UnityWebRequestTexture.GetTexture(url); using var request = UnityWebRequestTexture.GetTexture(url);
request.SetRequestHeader("User-Agent", "MDPro3/" + Application.version + " (" + System.Environment.OSVersion.ToString() + "); Unity/" + Application.unityVersion); request.SetRequestHeader("User-Agent", "MDPro3/" + Application.version + " (" + System.Environment.OSVersion.ToString() + "); Unity/" + Application.unityVersion);
var send = request.SendWebRequest(); var send = request.SendWebRequest();
await TaskUtility.WaitUntil(() => send.isDone); while (!send.isDone)
await TaskUtility.WaitOneFrame(cancellationToken);
if (!Application.isPlaying) if (!Application.isPlaying)
return null; return null;
cancellationToken.ThrowIfCancellationRequested();
if (request.result == UnityWebRequest.Result.Success) if (request.result == UnityWebRequest.Result.Success)
{ {
return DownloadHandlerTexture.GetContent(request); return DownloadHandlerTexture.GetContent(request);
......
...@@ -144,7 +144,7 @@ namespace MDPro3.Duel ...@@ -144,7 +144,7 @@ namespace MDPro3.Duel
var tempStrings = new List<string>(); var tempStrings = new List<string>();
foreach (var e in entry.rawKvp) foreach (var e in entry.rawKvp)
if (e.Value.situations != null && e.Value.situations.Length > 0) if (e.Value.situations != null && e.Value.situations.Length > 0)
if (Array.IndexOf(e.Value.situations, situation) > 0) if (Array.IndexOf(e.Value.situations, situation) >= 0)
tempStrings.Add(e.Value.shortName); tempStrings.Add(e.Value.shortName);
if (tempStrings.Count > 0) if (tempStrings.Count > 0)
returnValue = tempStrings[UnityEngine.Random.Range(0, tempStrings.Count)]; returnValue = tempStrings[UnityEngine.Random.Range(0, tempStrings.Count)];
......
using System; using System;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
...@@ -113,8 +114,10 @@ namespace MDPro3.Net ...@@ -113,8 +114,10 @@ namespace MDPro3.Net
} }
} }
public static async UniTask<Texture2D> GetAvatarAsync(string userName) public static async UniTask<Texture2D> GetAvatarAsync(string userName, CancellationToken cancellationToken = default)
{ {
cancellationToken.ThrowIfCancellationRequested();
if(!Directory.Exists(avatarSavePath)) if(!Directory.Exists(avatarSavePath))
Directory.CreateDirectory(avatarSavePath); Directory.CreateDirectory(avatarSavePath);
...@@ -137,6 +140,7 @@ namespace MDPro3.Net ...@@ -137,6 +140,7 @@ namespace MDPro3.Net
return cachedAvatars[avatarName]; return cachedAvatars[avatarName];
var pic = await TextureManager.LoadPicFromFileAsync(fullPath); var pic = await TextureManager.LoadPicFromFileAsync(fullPath);
cancellationToken.ThrowIfCancellationRequested();
lock (cachedAvatars) lock (cachedAvatars)
if (!cachedAvatars.ContainsKey(avatarName)) if (!cachedAvatars.ContainsKey(avatarName))
...@@ -148,7 +152,7 @@ namespace MDPro3.Net ...@@ -148,7 +152,7 @@ namespace MDPro3.Net
using(var request = UnityWebRequest.Get(userUrl.Replace("{username}", userName))) using(var request = UnityWebRequest.Get(userUrl.Replace("{username}", userName)))
{ {
await request.SendWebRequest(); await request.SendWebRequest().WithCancellation(cancellationToken);
if (request.result == UnityWebRequest.Result.Success) if (request.result == UnityWebRequest.Result.Success)
{ {
avatarAddress = JsonUtility.FromJson<MyCardRoomUserInfo>(request.downloadHandler.text).user.avatar; avatarAddress = JsonUtility.FromJson<MyCardRoomUserInfo>(request.downloadHandler.text).user.avatar;
...@@ -160,8 +164,11 @@ namespace MDPro3.Net ...@@ -160,8 +164,11 @@ namespace MDPro3.Net
} }
} }
var requestAvatar = Tools.DownloadImageAsync(avatarAddress); cancellationToken.ThrowIfCancellationRequested();
var requestAvatar = Tools.DownloadImageAsync(avatarAddress, cancellationToken);
await requestAvatar; await requestAvatar;
cancellationToken.ThrowIfCancellationRequested();
Texture2D downloadImage = requestAvatar.Result; Texture2D downloadImage = requestAvatar.Result;
if (downloadImage == null) if (downloadImage == null)
return null; return null;
......
...@@ -22,6 +22,7 @@ namespace MDPro3 ...@@ -22,6 +22,7 @@ namespace MDPro3
public static PlayerInput PlayerInput; public static PlayerInput PlayerInput;
public static string KeyboardSchemeName = "Keyboard&Mouse"; public static string KeyboardSchemeName = "Keyboard&Mouse";
public static string GamepadSchemeName = "Gamepad"; public static string GamepadSchemeName = "Gamepad";
public static string TouchSchemeName = "Touch";
public static bool NextSelectionIsAxis; public static bool NextSelectionIsAxis;
public static GameObject HoverObject; public static GameObject HoverObject;
...@@ -124,6 +125,7 @@ namespace MDPro3 ...@@ -124,6 +125,7 @@ namespace MDPro3
private float downPressingTime; private float downPressingTime;
private const float moveRepeatDelay = 0.4f; private const float moveRepeatDelay = 0.4f;
private const float moveRepeatRate = 0.2f; private const float moveRepeatRate = 0.2f;
private const float moveInputDeadzone = 0.35f;
private void Awake() private void Awake()
{ {
...@@ -157,17 +159,25 @@ namespace MDPro3 ...@@ -157,17 +159,25 @@ namespace MDPro3
private void Update() private void Update()
{ {
MoveInput = moveAction.ReadValue<Vector2>(); var hasTouchInput = TryGetTouchState(out var touchPosition, out var touchPressed, out var touchPressing, out var touchReleased);
MousePos = mouseAction.ReadValue<Vector2>(); if (hasTouchInput)
{
EnsureTouchControlScheme();
if (Cursor.lockState == CursorLockMode.Locked)
ShowCursorForTouch();
}
MoveInput = ApplyMoveDeadzone(moveAction.ReadValue<Vector2>());
MousePos = hasTouchInput ? touchPosition : mouseAction.ReadValue<Vector2>();
LeftScrollWheel = leftScrollAction.ReadValue<Vector2>(); LeftScrollWheel = leftScrollAction.ReadValue<Vector2>();
RightScrollWheel = rightScrollAction.ReadValue<Vector2>(); RightScrollWheel = rightScrollAction.ReadValue<Vector2>();
if (MousePos != lastMousePos) if (MousePos != lastMousePos || touchPressed)
{ {
MouseMovedEvent(); MouseMovedEvent();
} }
if(MoveInput != Vector2.zero && !InputFieldActivating()) if (MoveInput != Vector2.zero && !hasTouchInput && !InputFieldActivating())
{ {
if (Cursor.lockState == CursorLockMode.None) if (Cursor.lockState == CursorLockMode.None)
{ {
...@@ -193,13 +203,13 @@ namespace MDPro3 ...@@ -193,13 +203,13 @@ namespace MDPro3
#region Mouse #region Mouse
MouseLeftDown = leftClickAction.WasPressedThisFrame(); MouseLeftDown = leftClickAction.WasPressedThisFrame() || touchPressed;
MouseRightDown = rightClickAction.WasPressedThisFrame(); MouseRightDown = rightClickAction.WasPressedThisFrame();
MouseMiddleDown = middleClickAction.WasPressedThisFrame(); MouseMiddleDown = middleClickAction.WasPressedThisFrame();
MouseLeftPressing = leftClickAction.IsPressed(); MouseLeftPressing = leftClickAction.IsPressed() || touchPressing;
MouseMiddlePressing = middleClickAction.IsPressed(); MouseMiddlePressing = middleClickAction.IsPressed();
MouseRightPressing = rightClickAction.IsPressed(); MouseRightPressing = rightClickAction.IsPressed();
MouseLeftUp = leftClickAction.WasReleasedThisFrame(); MouseLeftUp = leftClickAction.WasReleasedThisFrame() || touchReleased;
MouseRightUp = rightClickAction.WasReleasedThisFrame(); MouseRightUp = rightClickAction.WasReleasedThisFrame();
MouseMiddleUp = middleClickAction.WasReleasedThisFrame(); MouseMiddleUp = middleClickAction.WasReleasedThisFrame();
...@@ -334,9 +344,70 @@ namespace MDPro3 ...@@ -334,9 +344,70 @@ namespace MDPro3
} }
private static Vector2 ApplyMoveDeadzone(Vector2 input)
{
input.x = ApplyMoveDeadzone(input.x);
input.y = ApplyMoveDeadzone(input.y);
return input;
}
private static float ApplyMoveDeadzone(float input)
{
if (Mathf.Abs(input) < moveInputDeadzone)
return 0f;
return Mathf.Sign(input);
}
private static bool TryGetTouchState(out Vector2 touchPosition, out bool touchPressed, out bool touchPressing, out bool touchReleased)
{
touchPosition = default;
touchPressed = false;
touchPressing = false;
touchReleased = false;
var touchscreen = Touchscreen.current;
if (touchscreen == null)
return false;
var touch = touchscreen.primaryTouch;
touchPressed = touch.press.wasPressedThisFrame;
touchPressing = touch.press.isPressed;
touchReleased = touch.press.wasReleasedThisFrame;
if (!touchPressed && !touchPressing && !touchReleased)
return false;
touchPosition = touch.position.ReadValue();
return true;
}
private static bool TouchInputActive()
{
var touchscreen = Touchscreen.current;
if (touchscreen == null)
return false;
var touch = touchscreen.primaryTouch;
return touch.press.wasPressedThisFrame || touch.press.isPressed || touch.press.wasReleasedThisFrame;
}
private void EnsureTouchControlScheme()
{
if (PlayerInput == null || Touchscreen.current == null || PlayerInput.currentControlScheme == TouchSchemeName)
return;
try
{
PlayerInput.SwitchCurrentControlScheme(TouchSchemeName, Touchscreen.current);
}
catch (InvalidOperationException)
{
}
}
private void MouseMovedEvent() private void MouseMovedEvent()
{ {
if(PlayerInput.currentControlScheme != GamepadSchemeName) if (PlayerInput.currentControlScheme != GamepadSchemeName || TouchInputActive())
OnMouseMovedAction?.Invoke(); OnMouseMovedAction?.Invoke();
} }
...@@ -365,6 +436,8 @@ namespace MDPro3 ...@@ -365,6 +436,8 @@ namespace MDPro3
public static bool NeedDefaultSelect() public static bool NeedDefaultSelect()
{ {
if (TouchInputActive())
return false;
if (PlayerInput.currentControlScheme == GamepadSchemeName) if (PlayerInput.currentControlScheme == GamepadSchemeName)
return true; return true;
else if (Cursor.lockState == CursorLockMode.Locked) else if (Cursor.lockState == CursorLockMode.Locked)
...@@ -449,6 +522,15 @@ namespace MDPro3 ...@@ -449,6 +522,15 @@ namespace MDPro3
ignoreNextCursorMove = true; ignoreNextCursorMove = true;
} }
} }
private void ShowCursorForTouch()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
hasCursorRestorePos = false;
ignoreNextCursorMove = false;
}
private void HideCursor() private void HideCursor()
{ {
cursorRestorePos = MousePos; cursorRestorePos = MousePos;
......
...@@ -2,9 +2,11 @@ using MDPro3.Net; ...@@ -2,9 +2,11 @@ using MDPro3.Net;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using MDPro3.Servant; using MDPro3.Servant;
using MDPro3.UI.ServantUI; using MDPro3.UI.ServantUI;
...@@ -62,15 +64,34 @@ namespace MDPro3.UI ...@@ -62,15 +64,34 @@ namespace MDPro3.UI
protected override async UniTask RefreshAsync() protected override async UniTask RefreshAsync()
{ {
refreshed = false; refreshed = false;
var cancellationToken = cts?.Token ?? destroyCancellationToken;
var face0 = Manager.GetElement<RawImage>("Face0");
var face1 = Manager.GetElement<RawImage>("Face1");
Manager.GetElement<RawImage>("Face0").texture = Appearance.defaultFace0.texture; if (face0 != null)
Manager.GetElement<RawImage>("Face1").texture = Appearance.defaultFace1.texture; face0.texture = Appearance.defaultFace0.texture;
if (face1 != null)
face1.texture = Appearance.defaultFace1.texture;
Manager.GetElement<RawImage>("Face0").texture = await MyCard.GetAvatarAsync(player0Name); try
Manager.GetElement<RawImage>("Face1").texture = await MyCard.GetAvatarAsync(player1Name); {
var avatar0 = await MyCard.GetAvatarAsync(player0Name, cancellationToken);
if (!cancellationToken.IsCancellationRequested && face0 != null)
face0.texture = avatar0;
var avatar1 = await MyCard.GetAvatarAsync(player1Name, cancellationToken);
if (!cancellationToken.IsCancellationRequested && face1 != null)
face1.texture = avatar1;
refreshed = true; refreshed = true;
} }
catch (OperationCanceledException)
{
}
catch (MissingReferenceException)
{
}
}
protected override void CallToggleOnEvent() protected override void CallToggleOnEvent()
{ {
......
...@@ -621,35 +621,20 @@ namespace MDPro3.UI.ServantUI ...@@ -621,35 +621,20 @@ namespace MDPro3.UI.ServantUI
} }
private bool bgDetailShowing; private bool bgDetailShowing;
public void SwitchBgDetail(bool show) public void RefreshBgDetail()
{
if (show)
ShowBgDetail();
else
HideBgDetail();
}
private void ShowBgDetail()
{ {
var core = Program.instance.ocgcore; var core = Program.instance.ocgcore;
var info = Program.instance.ocgcore.messageDispatcher.duel.duelBGManager.fieldSummonRightInfo; var info = core?.messageDispatcher?.duel?.duelBGManager?.fieldSummonRightInfo;
if (info == null)
if (bgDetailShowing)
return; return;
bgDetailShowing = true;
foreach (var card in cards)
card.ShowHiddenLabel();
if (info != null)
{
CameraManager.DuelOverlay3DPlus();
info.SetActive(true);
var summonInfoManager = info.GetComponent<ElementObjectManager>(); var summonInfoManager = info.GetComponent<ElementObjectManager>();
if (summonInfoManager == null)
return;
var nearManager = summonInfoManager.GetElement<ElementObjectManager>("RootNear"); var nearManager = summonInfoManager.GetElement<ElementObjectManager>("RootNear");
var farManager = summonInfoManager.GetElement<ElementObjectManager>("RootFar"); var farManager = summonInfoManager.GetElement<ElementObjectManager>("RootFar");
nearManager.GetElement<TextMeshPro>("TextSummon").text = mySummonCount.ToString(); nearManager.GetElement<TextMeshPro>("TextSummon").text = mySummonCount.ToString();
nearManager.GetElement<TextMeshPro>("TextSpSummon").text = mySpSummonCount.ToString(); nearManager.GetElement<TextMeshPro>("TextSpSummon").text = mySpSummonCount.ToString();
farManager.GetElement<TextMeshPro>("TextSummon").text = opSummonCount.ToString(); farManager.GetElement<TextMeshPro>("TextSummon").text = opSummonCount.ToString();
farManager.GetElement<TextMeshPro>("TextSpSummon").text = opSpSummonCount.ToString(); farManager.GetElement<TextMeshPro>("TextSpSummon").text = opSpSummonCount.ToString();
...@@ -668,6 +653,47 @@ namespace MDPro3.UI.ServantUI ...@@ -668,6 +653,47 @@ namespace MDPro3.UI.ServantUI
summonInfoManager.GetElement<TextMeshPro>("HandNear").text = core.GetLocationCardCount(CardLocation.Hand, 0).ToString(); summonInfoManager.GetElement<TextMeshPro>("HandNear").text = core.GetLocationCardCount(CardLocation.Hand, 0).ToString();
summonInfoManager.GetElement<TextMeshPro>("HandFar").text = core.GetLocationCardCount(CardLocation.Hand, 1).ToString(); summonInfoManager.GetElement<TextMeshPro>("HandFar").text = core.GetLocationCardCount(CardLocation.Hand, 1).ToString();
} }
public void ResetBgDetailState()
{
var wasShowing = bgDetailShowing;
bgDetailShowing = false;
foreach (var card in cards)
card.HideHiddenLabel();
var info = Program.instance.ocgcore?.messageDispatcher?.duel?.duelBGManager?.fieldSummonRightInfo;
if (info != null)
{
if (wasShowing || info.activeSelf)
CameraManager.DuelOverlay3DMinus();
info.SetActive(false);
}
}
public void SwitchBgDetail(bool show)
{
if (show)
ShowBgDetail();
else
HideBgDetail();
}
private void ShowBgDetail()
{
var info = Program.instance.ocgcore.messageDispatcher.duel.duelBGManager.fieldSummonRightInfo;
if (bgDetailShowing)
return;
bgDetailShowing = true;
foreach (var card in cards)
card.ShowHiddenLabel();
if (info != null)
{
CameraManager.DuelOverlay3DPlus();
info.SetActive(true);
RefreshBgDetail();
}
} }
private void HideBgDetail() private void HideBgDetail()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment