Commit ddb4b8f1 authored by SherryChaos's avatar SherryChaos

fix SelectSum bug

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