Commit ea749636 authored by mercury233's avatar mercury233

format deckmanager code

parent 8ae57b1a
...@@ -646,7 +646,17 @@ public class DeckManager : ServantWithCardDescription ...@@ -646,7 +646,17 @@ public class DeckManager : ServantWithCardDescription
UIInput_search.isSelected = true; UIInput_search.isSelected = true;
} }
public YGOSharp.Banlist currentBanlist = null; public YGOSharp.Banlist currentBanlist = null;
bool checkBanlistAvail(int cardid)
{
return deck.GetCardCount(cardid) < currentBanlist.GetQuantity(cardid);
}
bool isBanned(int cardid)
{
return currentBanlist.GetQuantity(cardid) == 0;
}
List<YGOSharp.Card> PrintedResult = new List<YGOSharp.Card>(); List<YGOSharp.Card> PrintedResult = new List<YGOSharp.Card>();
...@@ -1228,15 +1238,15 @@ public class DeckManager : ServantWithCardDescription ...@@ -1228,15 +1238,15 @@ public class DeckManager : ServantWithCardDescription
public override void ES_HoverOverGameObject(GameObject gameObject) public override void ES_HoverOverGameObject(GameObject gameObject)
{ {
MonoCardInDeckManager MonoCardInDeckManager_ = gameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>();
if (MonoCardInDeckManager_ != null) if (cardInDeck != null)
{ {
((CardDescription)(Program.I().cardDescription)).setData(MonoCardInDeckManager_.cardData, GameTextureManager.myBack); ((CardDescription)(Program.I().cardDescription)).setData(cardInDeck.cardData, GameTextureManager.myBack);
} }
cardPicLoader cardPicLoader_ = gameObject.GetComponent<cardPicLoader>(); cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>();
if (cardPicLoader_ != null) if (cardInSearchResult != null)
{ {
((CardDescription)(Program.I().cardDescription)).setData(cardPicLoader_.data, GameTextureManager.myBack); ((CardDescription)(Program.I().cardDescription)).setData(cardInSearchResult.data, GameTextureManager.myBack);
} }
} }
...@@ -1256,15 +1266,15 @@ public class DeckManager : ServantWithCardDescription ...@@ -1256,15 +1266,15 @@ public class DeckManager : ServantWithCardDescription
} }
goLast = gameObject; goLast = gameObject;
timeLastDown = Program.TimePassed(); timeLastDown = Program.TimePassed();
MonoCardInDeckManager MonoCardInDeckManager_ = gameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>();
cardPicLoader cardPicLoader_ = gameObject.GetComponent<cardPicLoader>(); cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>();
if (MonoCardInDeckManager_ != null && !MonoCardInDeckManager_.dying) if (cardInDeck != null && !cardInDeck.dying)
{ {
if (doubleClick && condition == Condition.editDeck && deck.GetCardCount(MonoCardInDeckManager_.cardData.Id) < currentBanlist.GetQuantity(MonoCardInDeckManager_.cardData.Id)) if (doubleClick && condition == Condition.editDeck && checkBanlistAvail(cardInDeck.cardData.Id))
{ {
MonoCardInDeckManager card = createCard(); MonoCardInDeckManager card = createCard();
card.transform.position = MonoCardInDeckManager_.transform.position; card.transform.position = cardInDeck.transform.position;
MonoCardInDeckManager_.cardData.cloneTo(card.cardData); cardInDeck.cardData.cloneTo(card.cardData);
card.gameObject.layer = 16; card.gameObject.layer = 16;
deck.IMain.Add(card); deck.IMain.Add(card);
deckDirty = true; deckDirty = true;
...@@ -1273,21 +1283,21 @@ public class DeckManager : ServantWithCardDescription ...@@ -1273,21 +1283,21 @@ public class DeckManager : ServantWithCardDescription
} }
else else
{ {
cardInDragging = MonoCardInDeckManager_; cardInDragging = cardInDeck;
MonoCardInDeckManager_.beginDrag(); cardInDeck.beginDrag();
} }
} }
else if (cardPicLoader_ != null) else if (cardInSearchResult != null)
{ {
if (condition == Condition.editDeck) if (condition == Condition.editDeck)
{ {
if (deck.GetCardCount(cardPicLoader_.data.Id) < currentBanlist.GetQuantity(cardPicLoader_.data.Id)) if (checkBanlistAvail(cardInSearchResult.data.Id))
{ {
if ((cardPicLoader_.data.Type & (UInt32)CardType.Token) == 0) if ((cardInSearchResult.data.Type & (UInt32)CardType.Token) == 0)
{ {
MonoCardInDeckManager card = createCard(); MonoCardInDeckManager card = createCard();
card.transform.position = card.getGoodPosition(4); card.transform.position = card.getGoodPosition(4);
card.cardData = cardPicLoader_.data; card.cardData = cardInSearchResult.data;
card.gameObject.layer = 16; card.gameObject.layer = 16;
deck.IMain.Add(card); deck.IMain.Add(card);
cardInDragging = card; cardInDragging = card;
...@@ -1324,61 +1334,52 @@ public class DeckManager : ServantWithCardDescription ...@@ -1324,61 +1334,52 @@ public class DeckManager : ServantWithCardDescription
{ {
if (condition == Condition.editDeck) if (condition == Condition.editDeck)
{ {
MonoCardInDeckManager MonoCardInDeckManager_ = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (MonoCardInDeckManager_ != null) if (cardInDeck != null)
{ {
MonoCardInDeckManager_.killIt(); cardInDeck.killIt();
ArrangeObjectDeck(true); ArrangeObjectDeck(true);
ShowObjectDeck(); ShowObjectDeck();
} }
cardPicLoader cardPicLoader_ = Program.pointedGameObject.GetComponent<cardPicLoader>(); cardPicLoader cardInSearchResult = Program.pointedGameObject.GetComponent<cardPicLoader>();
if (cardPicLoader_ != null) if (cardInSearchResult != null)
{ {
CreateMonoCard(cardPicLoader_.data); CreateMonoCard(cardInSearchResult.data);
ShowObjectDeck(); ShowObjectDeck();
} }
} }
else else
{ {
MonoCardInDeckManager MonoCardInDeckManager_ = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>(); MonoCardInDeckManager cardInDeck = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (MonoCardInDeckManager_ != null) if (cardInDeck != null)
{ {
bool isSide = false; bool isSide = false;
for (int i = 0; i < deck.ISide.Count; i++) for (int i = 0; i < deck.ISide.Count; i++)
{ {
if (MonoCardInDeckManager_== deck.ISide[i]) if (cardInDeck== deck.ISide[i])
{ {
isSide = true; isSide = true;
} }
} }
if (isSide) if (isSide)
{ {
if ( if (cardInDeck.cardData.IsExtraCard())
(MonoCardInDeckManager_.cardData.Type & (UInt32)CardType.Fusion) > 0
||
(MonoCardInDeckManager_.cardData.Type & (UInt32)CardType.Synchro) > 0
||
(MonoCardInDeckManager_.cardData.Type & (UInt32)CardType.Xyz) > 0
||
(MonoCardInDeckManager_.cardData.Type & (UInt32)CardType.Link) > 0
)
{ {
deck.IExtra.Add(MonoCardInDeckManager_); deck.IExtra.Add(cardInDeck);
deck.ISide.Remove(MonoCardInDeckManager_); deck.ISide.Remove(cardInDeck);
} }
else else
{ {
deck.IMain.Add(MonoCardInDeckManager_); deck.IMain.Add(cardInDeck);
deck.ISide.Remove(MonoCardInDeckManager_); deck.ISide.Remove(cardInDeck);
} }
} }
else else
{ {
deck.ISide.Add(MonoCardInDeckManager_); deck.ISide.Add(cardInDeck);
deck.IMain.Remove(MonoCardInDeckManager_); deck.IMain.Remove(cardInDeck);
deck.IExtra.Remove(MonoCardInDeckManager_); deck.IExtra.Remove(cardInDeck);
} }
deckDirty = true;
ShowObjectDeck(); ShowObjectDeck();
} }
} }
...@@ -1387,21 +1388,13 @@ public class DeckManager : ServantWithCardDescription ...@@ -1387,21 +1388,13 @@ public class DeckManager : ServantWithCardDescription
private void CreateMonoCard(YGOSharp.Card data) private void CreateMonoCard(YGOSharp.Card data)
{ {
if (deck.GetCardCount(data.Id) < currentBanlist.GetQuantity(data.Id)) if (checkBanlistAvail(data.Id))
{ {
MonoCardInDeckManager card = createCard(); MonoCardInDeckManager card = createCard();
card.transform.position = card.getGoodPosition(4); card.transform.position = card.getGoodPosition(4);
card.cardData = data; card.cardData = data;
card.gameObject.layer = 16; card.gameObject.layer = 16;
if ( if (data.IsExtraCard())
(data.Type & (UInt32)CardType.Fusion) > 0
||
(data.Type & (UInt32)CardType.Synchro) > 0
||
(data.Type & (UInt32)CardType.Xyz) > 0
||
(data.Type & (UInt32)CardType.Link) > 0
)
{ {
deck.IExtra.Add(card); deck.IExtra.Add(card);
deck.Extra.Add(card.cardData.Id); deck.Extra.Add(card.cardData.Id);
...@@ -1581,15 +1574,7 @@ public class DeckManager : ServantWithCardDescription ...@@ -1581,15 +1574,7 @@ public class DeckManager : ServantWithCardDescription
{ {
if (p.z > -8) if (p.z > -8)
{ {
if ( if (deckTemp[i].cardData.IsExtraCard())
(deckTemp[i].cardData.Type & (UInt32)CardType.Fusion) > 0
||
(deckTemp[i].cardData.Type & (UInt32)CardType.Synchro) > 0
||
(deckTemp[i].cardData.Type & (UInt32)CardType.Xyz) > 0
||
(deckTemp[i].cardData.Type & (UInt32)CardType.Link) > 0
)
{ {
deck.IExtra.Add(deckTemp[i]); deck.IExtra.Add(deckTemp[i]);
} }
......
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