Commit fb815cfe authored by mercury233's avatar mercury233 Committed by Unicorn369

format deckmanager code

parent f5b446e0
......@@ -655,6 +655,16 @@ public class DeckManager : ServantWithCardDescription
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>();
void print(List<YGOSharp.Card> result)
......@@ -1257,15 +1267,15 @@ public class DeckManager : ServantWithCardDescription
public override void ES_HoverOverGameObject(GameObject gameObject)
{
MonoCardInDeckManager MonoCardInDeckManager_ = gameObject.GetComponent<MonoCardInDeckManager>();
if (MonoCardInDeckManager_ != null)
MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>();
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>();
if (cardPicLoader_ != null)
cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>();
if (cardInSearchResult != null)
{
((CardDescription)(Program.I().cardDescription)).setData(cardPicLoader_.data, GameTextureManager.myBack);
((CardDescription)(Program.I().cardDescription)).setData(cardInSearchResult.data, GameTextureManager.myBack);
}
}
......@@ -1285,15 +1295,15 @@ public class DeckManager : ServantWithCardDescription
}
goLast = gameObject;
timeLastDown = Program.TimePassed();
MonoCardInDeckManager MonoCardInDeckManager_ = gameObject.GetComponent<MonoCardInDeckManager>();
cardPicLoader cardPicLoader_ = gameObject.GetComponent<cardPicLoader>();
if (MonoCardInDeckManager_ != null && !MonoCardInDeckManager_.dying)
MonoCardInDeckManager cardInDeck = gameObject.GetComponent<MonoCardInDeckManager>();
cardPicLoader cardInSearchResult = gameObject.GetComponent<cardPicLoader>();
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();
card.transform.position = MonoCardInDeckManager_.transform.position;
MonoCardInDeckManager_.cardData.cloneTo(card.cardData);
card.transform.position = cardInDeck.transform.position;
cardInDeck.cardData.cloneTo(card.cardData);
card.gameObject.layer = 16;
deck.IMain.Add(card);
deckDirty = true;
......@@ -1302,21 +1312,21 @@ public class DeckManager : ServantWithCardDescription
}
else
{
cardInDragging = MonoCardInDeckManager_;
MonoCardInDeckManager_.beginDrag();
cardInDragging = cardInDeck;
cardInDeck.beginDrag();
}
}
else if (cardPicLoader_ != null)
else if (cardInSearchResult != null)
{
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();
card.transform.position = card.getGoodPosition(4);
card.cardData = cardPicLoader_.data;
card.cardData = cardInSearchResult.data;
card.gameObject.layer = 16;
deck.IMain.Add(card);
cardInDragging = card;
......@@ -1353,61 +1363,52 @@ public class DeckManager : ServantWithCardDescription
{
if (condition == Condition.editDeck)
{
MonoCardInDeckManager MonoCardInDeckManager_ = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (MonoCardInDeckManager_ != null)
MonoCardInDeckManager cardInDeck = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (cardInDeck != null)
{
MonoCardInDeckManager_.killIt();
cardInDeck.killIt();
ArrangeObjectDeck(true);
ShowObjectDeck();
}
cardPicLoader cardPicLoader_ = Program.pointedGameObject.GetComponent<cardPicLoader>();
if (cardPicLoader_ != null)
cardPicLoader cardInSearchResult = Program.pointedGameObject.GetComponent<cardPicLoader>();
if (cardInSearchResult != null)
{
CreateMonoCard(cardPicLoader_.data);
CreateMonoCard(cardInSearchResult.data);
ShowObjectDeck();
}
}
else
{
MonoCardInDeckManager MonoCardInDeckManager_ = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (MonoCardInDeckManager_ != null)
MonoCardInDeckManager cardInDeck = Program.pointedGameObject.GetComponent<MonoCardInDeckManager>();
if (cardInDeck != null)
{
bool isSide = false;
for (int i = 0; i < deck.ISide.Count; i++)
{
if (MonoCardInDeckManager_ == deck.ISide[i])
if (cardInDeck== deck.ISide[i])
{
isSide = true;
}
}
if (isSide)
{
if (
(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
)
if (cardInDeck.cardData.IsExtraCard())
{
deck.IExtra.Add(MonoCardInDeckManager_);
deck.ISide.Remove(MonoCardInDeckManager_);
deck.IExtra.Add(cardInDeck);
deck.ISide.Remove(cardInDeck);
}
else
{
deck.IMain.Add(MonoCardInDeckManager_);
deck.ISide.Remove(MonoCardInDeckManager_);
deck.IMain.Add(cardInDeck);
deck.ISide.Remove(cardInDeck);
}
}
else
{
deck.ISide.Add(MonoCardInDeckManager_);
deck.IMain.Remove(MonoCardInDeckManager_);
deck.IExtra.Remove(MonoCardInDeckManager_);
deck.ISide.Add(cardInDeck);
deck.IMain.Remove(cardInDeck);
deck.IExtra.Remove(cardInDeck);
}
deckDirty = true;
ShowObjectDeck();
}
}
......@@ -1416,26 +1417,13 @@ public class DeckManager : ServantWithCardDescription
private void CreateMonoCard(YGOSharp.Card data)
{
if (deck.GetCardCount(data.Id) < currentBanlist.GetQuantity(data.Id))
if (checkBanlistAvail(data.Id))
{
MonoCardInDeckManager card = createCard();
card.transform.position = card.getGoodPosition(4);
card.cardData = data;
card.gameObject.layer = 16;
if (Input.GetKey(KeyCode.LeftShift) || (Input.GetKey(KeyCode.RightShift)))
{
deck.ISide.Add(card);
deck.Side.Add(card.cardData.Id);
}
else if (
(data.Type & (UInt32)CardType.Fusion) > 0
||
(data.Type & (UInt32)CardType.Synchro) > 0
||
(data.Type & (UInt32)CardType.Xyz) > 0
||
(data.Type & (UInt32)CardType.Link) > 0
)
if (data.IsExtraCard())
{
deck.IExtra.Add(card);
deck.Extra.Add(card.cardData.Id);
......@@ -1497,33 +1485,26 @@ public class DeckManager : ServantWithCardDescription
{
switch (flag)
{
case 3:
case 1:
{
deck.Side.Add(code);
deck.Deck_O.Side.Add(code);
deck.Main.Add(code);
deck.Deck_O.Main.Add(code);
}
break;
default:
{
YGOSharp.Card card = YGOSharp.CardsManager.Get(code);
if ((card.Type & (UInt32)CardType.Fusion) > 0
||
(card.Type & (UInt32)CardType.Synchro) > 0
||
(card.Type & (UInt32)CardType.Xyz) > 0
||
(card.Type & (UInt32)CardType.Link) > 0)
case 2:
{
deck.Extra.Add(code);
deck.Deck_O.Extra.Add(code);
}
else
break;
case 3:
{
deck.Main.Add(code);
deck.Deck_O.Main.Add(code);
}
deck.Side.Add(code);
deck.Deck_O.Side.Add(code);
}
break;
default:
break;
}
}
}
......@@ -1622,15 +1603,7 @@ public class DeckManager : ServantWithCardDescription
{
if (p.z > -8)
{
if (
(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
)
if (deckTemp[i].cardData.IsExtraCard())
{
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