Commit dd104817 authored by SherryChaos's avatar SherryChaos

Add hand card hiding logic for spell zone selection

parent ac9a0bef
...@@ -16,6 +16,7 @@ using UnityEngine.Playables; ...@@ -16,6 +16,7 @@ using UnityEngine.Playables;
using YgomGame.Duel; using YgomGame.Duel;
using YgomSystem.ElementSystem; using YgomSystem.ElementSystem;
using static MDPro3.Servant.OcgCore; using static MDPro3.Servant.OcgCore;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
namespace MDPro3 namespace MDPro3
{ {
...@@ -141,48 +142,57 @@ namespace MDPro3 ...@@ -141,48 +142,57 @@ namespace MDPro3
private void LateUpdate() private void LateUpdate()
{ {
if (model != null) if (model == null)
return;
hover = UserInput.HoverObject == manager.GetElement("CardModel");
if (hover)
{ {
hover = UserInput.HoverObject == manager.GetElement("CardModel"); if(p.InMyControl() && HideMyHandCard)
if (!hover) hoving = false; HideMyHandCard = false;
else if(!p.InMyControl() && HideOpHandCard)
HideOpHandCard = false;
}
if (!hover) hoving = false;
if (hover && UserInput.MouseLeftUp && !handCardDraged)
OnClick();
else if (!hover && UserInput.MouseLeftUp)
{
if (UserInput.HoverObject == null)
NotClickThis();
else if (UserInput.HoverObject.name != "PlaceSelector")
NotClickThis();
}
if (Math.Abs(handOffset - lastHandOffset) > 10)
NotClickThis();
if (p.InLocation(CardLocation.Hand))
{
if (hover && hoving == false && clicked == false)
{
hoving = true;
handDefault = false;
AnimationHandHover();
MoveToHandDefault(0.1f);
}
if (hover && UserInput.MouseLeftUp && !handCardDraged) if (hover && UserInput.MouseLeftUp && !handCardDraged)
OnClick();
else if (!hover && UserInput.MouseLeftUp)
{ {
if (UserInput.HoverObject == null) clicked = true;
NotClickThis(); handDefault = false;
else if (UserInput.HoverObject.name != "PlaceSelector") AnimationHandAppeal();
NotClickThis();
} }
if (Math.Abs(handOffset - lastHandOffset) > 10) if (!hover && UserInput.MouseLeftDown)
NotClickThis();
if ((p.location & (uint)CardLocation.Hand) > 0)
{ {
if (hover && hoving == false && clicked == false) clicked = false;
{
hoving = true;
handDefault = false;
AnimationHandHover();
}
if (hover && UserInput.MouseLeftUp && !handCardDraged)
{
clicked = true;
handDefault = false;
AnimationHandAppeal();
}
if (!hover && UserInput.MouseLeftDown)
{
clicked = false;
}
if (!hover && !clicked && !handDefault)
{
AnimationHandDefault(0.1f);
}
if (Math.Abs(handOffset - lastHandOffset) > 10)
SetHandDefault();
} }
if (!hover && !clicked && !handDefault)
{
AnimationHandDefault(0.1f);
}
if (Math.Abs(handOffset - lastHandOffset) > 10)
SetHandDefault();
} }
} }
...@@ -506,13 +516,16 @@ namespace MDPro3 ...@@ -506,13 +516,16 @@ namespace MDPro3
float x = p.sequence * 4 - (handsCount - 1) * 2; float x = p.sequence * 4 - (handsCount - 1) * 2;
var z0 = -28 + (30 - Program.instance.camera_.cameraMain.fieldOfView) * 0.7f;
var z1 = 17 - (30 - Program.instance.camera_.cameraMain.fieldOfView) * 0.7f;
if (p.controller == 0) if (p.controller == 0)
return new Vector3(x + handOffset * UIManager.ScreenLengthWithoutScalerX(0.038f), 15, z0); {
var z = -28 + (30 - Program.instance.camera_.cameraMain.fieldOfView) * 0.7f;
return new Vector3(x + handOffset * UIManager.ScreenLengthWithoutScalerX(0.038f), 15, z);
}
else else
return new Vector3(-x, 15, z1); {
var z = 17 - (30 - Program.instance.camera_.cameraMain.fieldOfView) * 0.7f;
return new Vector3(-x, 15, z);
}
} }
else if (p.InLocation(CardLocation.Deck)) else if (p.InLocation(CardLocation.Deck))
{ {
...@@ -1818,9 +1831,10 @@ namespace MDPro3 ...@@ -1818,9 +1831,10 @@ namespace MDPro3
model.transform.SetParent(null, true); model.transform.SetParent(null, true);
handDefault = true; handDefault = true;
appealed = false; appealed = false;
MoveToHandDefault(time);
var targetPosition = GetCardPosition(p, this); var targetPosition = GetCardPosition(p, this);
var x = targetPosition.x; var x = targetPosition.x;
model.transform.DOLocalMove(targetPosition, time);
Transform pivot = manager.GetElement<Transform>("Pivot"); Transform pivot = manager.GetElement<Transform>("Pivot");
Transform offset = manager.GetElement<Transform>("Offset"); Transform offset = manager.GetElement<Transform>("Offset");
...@@ -1838,9 +1852,20 @@ namespace MDPro3 ...@@ -1838,9 +1852,20 @@ namespace MDPro3
turn.DOLocalRotate(Vector3.zero, time); turn.DOLocalRotate(Vector3.zero, time);
} }
private void MoveToHandDefault(float time)
{
var targetPosition = GetCardPosition(p, this);
var x = targetPosition.x;
if (HideMyHandCard && p.InMyControl())
targetPosition.z = -28f;
if (HideOpHandCard && !p.InMyControl())
targetPosition.z = 17f;
model.transform.DOLocalMove(targetPosition, time);
}
public void SetHandToDefault() public void SetHandToDefault()
{ {
if (model == null || (p.location & (uint)CardLocation.Hand) == 0 || inAnimation) if (model == null || !p.InLocation(CardLocation.Hand) || inAnimation)
return; return;
clicked = false; clicked = false;
...@@ -1849,8 +1874,8 @@ namespace MDPro3 ...@@ -1849,8 +1874,8 @@ namespace MDPro3
public void SetHandDefault() public void SetHandDefault()
{ {
if (model == null || (p.location & (uint)CardLocation.Hand) == 0) if (model == null || !p.InLocation(CardLocation.Hand))
return; return;
appealed = false; appealed = false;
model.transform.localPosition = GetCardPosition(p, this); model.transform.localPosition = GetCardPosition(p, this);
float x = model.transform.localPosition.x; float x = model.transform.localPosition.x;
......
...@@ -3190,8 +3190,24 @@ namespace MDPro3.Duel ...@@ -3190,8 +3190,24 @@ namespace MDPro3.Duel
min = 1; min = 1;
ES_min = min; ES_min = min;
var filter = ~reader.ReadUInt32(); var filter = ~reader.ReadUInt32();
bool haveMySpellZone = false;
bool haveOpSpellZone = false;
foreach (var place in duelBGManager.places) foreach (var place in duelBGManager.places)
place.HighlightThisZone(filter, min); {
var p = place.HighlightThisZone(filter, min);
if(p != null)
if (p.InLocation(CardLocation.SpellZone))
{
if (p.InMyControl())
haveMySpellZone = true;
else
haveOpSpellZone = true;
}
}
if (haveMySpellZone)
HideMyHandCard = true;
else if (haveOpSpellZone)
HideOpHandCard = true;
if (currentMessage == GameMessage.SelectPlace) if (currentMessage == GameMessage.SelectPlace)
{ {
......
...@@ -164,6 +164,26 @@ namespace MDPro3.Servant ...@@ -164,6 +164,26 @@ namespace MDPro3.Servant
public static float lastHandOffset; public static float lastHandOffset;
public static bool clickingHandCard; public static bool clickingHandCard;
public static bool handCardDraged; public static bool handCardDraged;
private static bool hideMyHandCard;
public static bool HideMyHandCard
{
get { return hideMyHandCard; }
set
{
hideMyHandCard = value;
Program.instance.ocgcore.RefreshMyHandCardPosition();
}
}
private static bool hideOpHandCard;
public static bool HideOpHandCard
{
get { return hideOpHandCard; }
set
{
hideOpHandCard = value;
Program.instance.ocgcore.RefreshOpHandCardPosition();
}
}
#endregion #endregion
...@@ -292,12 +312,11 @@ namespace MDPro3.Servant ...@@ -292,12 +312,11 @@ namespace MDPro3.Servant
if (GetMyHandCount() > 10) if (GetMyHandCount() > 10)
{ {
if (UserInput.HoverObject != null if (UserInput.MouseLeftDown
&& UserInput.HoverObject != null
&& UserInput.HoverObject.name == "CardModel" && UserInput.HoverObject.name == "CardModel"
&& UserInput.HoverObject.GetComponent<GameCardMono>().cookieCard.p.controller == 0 && UserInput.HoverObject.GetComponent<GameCardMono>().cookieCard.p.controller == 0
&& (UserInput.HoverObject.GetComponent<GameCardMono>().cookieCard.p.location & (uint)CardLocation.Hand) > 0 && (UserInput.HoverObject.GetComponent<GameCardMono>().cookieCard.p.location & (uint)CardLocation.Hand) > 0)
&& UserInput.MouseLeftDown
)
{ {
clickInPosition = UserInput.MousePos.x; clickInPosition = UserInput.MousePos.x;
clickingHandCard = true; clickingHandCard = true;
...@@ -1621,6 +1640,7 @@ namespace MDPro3.Servant ...@@ -1621,6 +1640,7 @@ namespace MDPro3.Servant
private void RefreshHandCardPositionInstant() private void RefreshHandCardPositionInstant()
{ {
hideMyHandCard = false;
if (showing) if (showing)
foreach (var card in cards) foreach (var card in cards)
card.SetHandDefault(); card.SetHandDefault();
...@@ -1633,6 +1653,23 @@ namespace MDPro3.Servant ...@@ -1633,6 +1653,23 @@ namespace MDPro3.Servant
card.SetHandToDefault(); card.SetHandToDefault();
} }
public void RefreshMyHandCardPosition()
{
if (showing)
foreach (var card in cards)
if(card.p.InMyControl())
card.SetHandToDefault();
}
public void RefreshOpHandCardPosition()
{
if (showing)
foreach (var card in cards)
if (!card.p.InMyControl())
card.SetHandToDefault();
}
string fieldHint; string fieldHint;
int fieldMin; int fieldMin;
int fieldMax; int fieldMax;
......
...@@ -214,7 +214,26 @@ namespace MDPro3.UI ...@@ -214,7 +214,26 @@ namespace MDPro3.UI
} }
else else
{ {
if ((p.location & (uint)CardLocation.Onfield) > 0) if (p.InLocation(CardLocation.SpellZone))
{
if (p.InMyControl())
{
OcgCore.HideMyHandCard = true;
OcgCore.HideOpHandCard = false;
}
else
{
OcgCore.HideOpHandCard = true;
OcgCore.HideMyHandCard = false;
}
}
else
{
OcgCore.HideMyHandCard = false;
OcgCore.HideOpHandCard = false;
}
if (p.InLocation(CardLocation.Onfield))
{ {
var card = FindCardInThisPlace(); var card = FindCardInThisPlace();
if (card != null) if (card != null)
...@@ -447,7 +466,7 @@ namespace MDPro3.UI ...@@ -447,7 +466,7 @@ namespace MDPro3.UI
selectCard.SetActive(false); selectCard.SetActive(false);
} }
public void HighlightThisZone(uint place, int min, bool needConfirm = false) public GPS HighlightThisZone(uint place, int min)
{ {
for (var i = 0; i < min; i++) for (var i = 0; i < min; i++)
{ {
...@@ -466,6 +485,7 @@ namespace MDPro3.UI ...@@ -466,6 +485,7 @@ namespace MDPro3.UI
{ {
ShowSelectZoneHighlight(); ShowSelectZoneHighlight();
selecting = true; selecting = true;
return p;
} }
} }
} }
...@@ -478,10 +498,12 @@ namespace MDPro3.UI ...@@ -478,10 +498,12 @@ namespace MDPro3.UI
{ {
ShowSelectZoneHighlight(); ShowSelectZoneHighlight();
selecting = true; selecting = true;
return p;
} }
} }
} }
} }
return null;
} }
public void ShowSelectZoneHighlight() public void ShowSelectZoneHighlight()
......
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