Commit ddb4b8f1 authored by SherryChaos's avatar SherryChaos

fix SelectSum bug

parent 04980cd5
......@@ -4707,8 +4707,10 @@ namespace MDPro3
return new int[] { sum1, sum2 };
}
public static bool CheckSelectable(List<GameCard> cards, GameCard card, List<GameCard> selectedCards)
public static bool CheckSelectable(List<GameCard> cards, GameCard card, List<GameCard> selectedCards, int max)
{
if(selectedCards.Count >= max)
return false;
bool returnValue = false;
var sum = GetSelectLevelSum(selectedCards);
if (sum[0] + card.levelForSelect_1 == Program.I().ocgcore.ES_level || sum[1] + card.levelForSelect_2 == Program.I().ocgcore.ES_level)
......@@ -4723,7 +4725,7 @@ namespace MDPro3
foreach (var c in cards)
if (!newSelectedCards.Contains(c))
{
returnValue = CheckSelectable(cards, c, newSelectedCards);
returnValue = CheckSelectable(cards, c, newSelectedCards, max);
if (returnValue)
return true;
}
......@@ -5337,7 +5339,7 @@ namespace MDPro3
foreach (var place in places)
if (place.cardSelecting)
if (!place.cardSelected)
if (CheckSelectable(cardsInSelection, place.cookieCard, selected))
if (CheckSelectable(cardsInSelection, place.cookieCard, selected, ES_max))
place.CardInThisZoneSelectable();
else
place.CardInThisZoneUnselectable();
......
......@@ -6,6 +6,7 @@ using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.UI;
using MDPro3.YGOSharp.OCGWrapper.Enums;
using YgomSystem.UI;
namespace MDPro3.UI
......@@ -134,13 +135,27 @@ namespace MDPro3.UI
foreach (var mono in monos)
if (!mono.selected)
if (OcgCore.CheckSelectable(Program.I().ocgcore.cardsInSelection, mono.card, selected))
if (OcgCore.CheckSelectable(Program.I().ocgcore.cardsInSelection, mono.card, selected, max))
mono.SelectableThis();
else
mono.UnselectableThis();
}
title.text = hint + "-" + OcgCore.GetSelectLevelSum(GetSelected())[0].ToString() + "/" + core.ES_level;
var selectedSum = OcgCore.GetSelectLevelSum(GetSelected());
if (!core.ES_overFlow)
{
if (selectedSum[0] == core.ES_level || selectedSum[1] == core.ES_level)
btnConfirm.GetComponent<ButtonPress>().SetInteractable(true);
else
btnConfirm.GetComponent<ButtonPress>().SetInteractable(false);
}
else
{
if (selectedSum[0] > core.ES_level || selectedSum[1] > core.ES_level)
btnConfirm.GetComponent<ButtonPress>().SetInteractable(true);
else
btnConfirm.GetComponent<ButtonPress>().SetInteractable(false);
}
title.text = hint + "-" + selectedSum[0].ToString() + "/" + core.ES_level;
}
else
{
......
......@@ -125,7 +125,6 @@ namespace MDPro3.UI
void OnClick()
{
AudioManager.PlaySE("SE_MENU_SELECT_01");
if ((card.p.location & (uint)CardLocation.Onfield) > 0
&& (card.p.location & (uint)CardLocation.Overlay) == 0)
{
......@@ -143,6 +142,7 @@ namespace MDPro3.UI
}
Program.I().ocgcore.description.Show(card, cardFace.material);
if (selected)
{
if (!unselectable)
......@@ -176,6 +176,7 @@ namespace MDPro3.UI
}
}
}
}
void SelectThis()
......
......@@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 1.0.2.1
bundleVersion: 1.0.3
preloadedAssets:
- {fileID: 11400000, guid: 5fb02d2098f52054b89ce4a9f63ba9ee, type: 2}
metroInputSource: 0
......
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