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;
using YgomGame.Duel;
using YgomSystem.ElementSystem;
using static MDPro3.Servant.OcgCore;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
namespace MDPro3
{
......@@ -141,48 +142,57 @@ namespace MDPro3
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 (!hover) hoving = false;
if(p.InMyControl() && HideMyHandCard)
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)
OnClick();
else if (!hover && UserInput.MouseLeftUp)
{
if (UserInput.HoverObject == null)
NotClickThis();
else if (UserInput.HoverObject.name != "PlaceSelector")
NotClickThis();
clicked = true;
handDefault = false;
AnimationHandAppeal();
}
if (Math.Abs(handOffset - lastHandOffset) > 10)
NotClickThis();
if ((p.location & (uint)CardLocation.Hand) > 0)
if (!hover && UserInput.MouseLeftDown)
{
if (hover && hoving == 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();
clicked = false;
}
if (!hover && !clicked && !handDefault)
{
AnimationHandDefault(0.1f);
}
if (Math.Abs(handOffset - lastHandOffset) > 10)
SetHandDefault();
}
}
......@@ -506,13 +516,16 @@ namespace MDPro3
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)
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
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))
{
......@@ -1818,9 +1831,10 @@ namespace MDPro3
model.transform.SetParent(null, true);
handDefault = true;
appealed = false;
MoveToHandDefault(time);
var targetPosition = GetCardPosition(p, this);
var x = targetPosition.x;
model.transform.DOLocalMove(targetPosition, time);
Transform pivot = manager.GetElement<Transform>("Pivot");
Transform offset = manager.GetElement<Transform>("Offset");
......@@ -1838,9 +1852,20 @@ namespace MDPro3
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()
{
if (model == null || (p.location & (uint)CardLocation.Hand) == 0 || inAnimation)
if (model == null || !p.InLocation(CardLocation.Hand) || inAnimation)
return;
clicked = false;
......@@ -1849,8 +1874,8 @@ namespace MDPro3
public void SetHandDefault()
{
if (model == null || (p.location & (uint)CardLocation.Hand) == 0)
return;
if (model == null || !p.InLocation(CardLocation.Hand))
return;
appealed = false;
model.transform.localPosition = GetCardPosition(p, this);
float x = model.transform.localPosition.x;
......
......@@ -3190,8 +3190,24 @@ namespace MDPro3.Duel
min = 1;
ES_min = min;
var filter = ~reader.ReadUInt32();
bool haveMySpellZone = false;
bool haveOpSpellZone = false;
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)
{
......
......@@ -164,6 +164,26 @@ namespace MDPro3.Servant
public static float lastHandOffset;
public static bool clickingHandCard;
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
......@@ -292,12 +312,11 @@ namespace MDPro3.Servant
if (GetMyHandCount() > 10)
{
if (UserInput.HoverObject != null
if (UserInput.MouseLeftDown
&& UserInput.HoverObject != null
&& UserInput.HoverObject.name == "CardModel"
&& UserInput.HoverObject.GetComponent<GameCardMono>().cookieCard.p.controller == 0
&& (UserInput.HoverObject.GetComponent<GameCardMono>().cookieCard.p.location & (uint)CardLocation.Hand) > 0
&& UserInput.MouseLeftDown
)
&& (UserInput.HoverObject.GetComponent<GameCardMono>().cookieCard.p.location & (uint)CardLocation.Hand) > 0)
{
clickInPosition = UserInput.MousePos.x;
clickingHandCard = true;
......@@ -1621,6 +1640,7 @@ namespace MDPro3.Servant
private void RefreshHandCardPositionInstant()
{
hideMyHandCard = false;
if (showing)
foreach (var card in cards)
card.SetHandDefault();
......@@ -1633,6 +1653,23 @@ namespace MDPro3.Servant
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;
int fieldMin;
int fieldMax;
......
......@@ -214,7 +214,26 @@ namespace MDPro3.UI
}
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();
if (card != null)
......@@ -447,7 +466,7 @@ namespace MDPro3.UI
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++)
{
......@@ -466,6 +485,7 @@ namespace MDPro3.UI
{
ShowSelectZoneHighlight();
selecting = true;
return p;
}
}
}
......@@ -478,10 +498,12 @@ namespace MDPro3.UI
{
ShowSelectZoneHighlight();
selecting = true;
return p;
}
}
}
}
return null;
}
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