UserInput
public GameObject slot1;
void GetMouseClick ()内の
else if (hit.collider.CompareTag("Card"))内の中身を
UserInput
//clicked card
Card(hit.collider.gameObject);
に書き換える
void Card()を
UserInput
void Card(GameObject selected)
{
// Card click actions
print("Clicked on Card");
// if the card clicked on is facedown
// if the card clicked on is not blocked
// filp it over
// if the card clicked on is in the deck pile with the trips
// if it is not blocked
// select it
// if the card is face up
// if therer is no card currently selected
// select the card
// if there is already a card selected (and it is not the same card)
// if the new card is eligable to stack on the old card
//stack it
// else
//select the new card
//else if there is already a card selected and it is the same card
// if the time is short enough then it is a double click
// if the card is eligible to fly up top then do it
}
に書き換える
// if there is already a card selected (and it is not the same card)
の下に
UserInput
else if (slot1 != selected)
{
// if the new card is eligable to stack on the old card
//stack it
// else
//select the new card
slot1 = selected;
}
に書き換える
void Bottom()の下に
UserInput
bool Stackable(GameObject selected)
{
Selectable s1 = slot1.GetComponent<Selectable>();
Selectable s2 = selected.GetComponent<Selectable>();
// compare them to see if they stach
}
Selectable
public bool top = false;
public string suit;
public int value;
public int row;
public bool faceUp = false;
public bool inDeckPile = false;
private string valueString;
// Start is called before the first frame update
void Start()
{
if (CompareTag("Card"))
{
if (CompareTag("Card"))
{
suit = transform.name[0].ToString();
for (int i = 1; i < transform.name.Length; i++)
{
char c = transform.name[i];
valueString = valueString + c.ToString()
}
if (valueString == "A")
{
value = 1;
}
if (valueString == "2")
{
value = 2;
}
if (valueString == "3")
{
value = 3;
}
if (valueString == "4")
{
value = 4;
}
if (valueString == "5")
{
value = 5;
}
if (valueString == "6")
{
value = 6;
}
if (valueString == "7")
{
value = 7;
}
if (valueString == "8")
{
value = 8;
}
if (valueString == "9")
{
value = 9;
}
if (valueString == "10")
{
value = 10;
}
if (valueString == "J")
{
value = 11;
}
if (valueString == "Q")
{
value = 12;
}
if (valueString == "K")
{
value = 13;
}
}
}
}
public void DealFromDeck()内の
if (deckLocation < trips)内の
newTopCard.GetComponent().faceUp = true;の下に
Solitaire
newTopCard.GetComponent<Selectable>().inDeckPile = true;
を入れる
bool Stackable内の
// compare them to see if they stackの下に
UserInput
return false;
を入れるとsuitとvalueが表示されるようになる
IEnumerator SolitaireDeal()内の
newCard.name = card;の下に
Solitaire
newCard.GetComponent<Selectable>().row = i;
bool Stackable(GameObject selected)内の
return falseを
UserInput
if (s2.top) // if in the top pile must stack suited Ace to King
{
if (s1.suit == s2.suit || (s1.value == 1 && s2.suit == null))
{
if (s1.value == s2.value + 1)
{
return true;
}
}
}
else // if in the bottom pile must stack alternate colours King to Ace
{
if (s1.value == s2.value - 1)
{
bool card1Red = true;
bool card2Red = true;
if (s1.suit == "C" || s1.suit == "S")
{
card1Red = false;
}
if (s2.suit == "C" || s2.suit == "S")
{
card2Red = false;
}
if (card1Red == card2Red)
{
print("Not stackable");
return false;
}
else
{
print("Stackable");
return true;
}
}
}
return false;
に書き換える