public void CardClicked(CardProspector cd) { switch (cd.state) { case CardState.target: break; case CardState.drawpile: MoveToDiscard(target); MoveToTarget(Draw ()); UpdateDrawPile(); ScoreManager(ScoreEvent.draw); break; case CardState.tableau: bool validMatch = true; if (!cd.faceUp) { validMatch = false; } if (!AdjacentRank(cd,target)) { validMatch = false; } if (!validMatch) return; tableau.Remove (cd); MoveToTarget(cd); SetTableauFaces(); ScoreManager(ScoreEvent.mine); break; } CheckForGameOver (); }
// Return true if the two cards are adjacent in rank (A & K wrap around) public bool AdjacentRank(CardProspector c0, CardProspector c1) { // If either card is face-down, it's not adjacent. if (!c0.faceUp || !c1.faceUp) return(false); // If they are 1 apart, they are adjacent if (Mathf.Abs(c0.rank - c1.rank) == 1) { return(true); } // If one is A and the other King, they're adjacent if (c0.rank == 1 && c1.rank == 13) return(true); if (c0.rank == 13 && c1.rank == 1) return(true); // Otherwise, return false return(false); }
public bool AdjacentRank(CardProspector c0, CardProspector c1) { if (!c0.faceUp || !c1.faceUp) return false; if (Mathf.Abs (c0.rank - c1.rank) == 1) return true; if (c0.rank == 1 && c1.rank == 13) return true; if(c1.rank == 1 && c0.rank == 13) return true; return false; }
public bool AdjacentRank(CardProspector c0, CardProspector c1) { if (!c0.faceUp || !c1.faceUp) return (false); if (Mathf.Abs (c0.rank - c1.rank) == 1) { return(true); } if (c0.rank == 1 && c1.rank == 13) return (true); if (c0.rank == 13 && c1.rank == 1) return(true); return(false); }
// Moves the current target to the discardPile void MoveToDiscard(CardProspector cd) { // Set the state of the card to discard cd.state = eCardState.discard; discardPile.Add(cd); // Add it to the discardPile List<> cd.transform.parent = layoutAnchor; // Update its transform parent // Position this card on the discardPile cd.transform.localPosition = new Vector3(layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID + 0.5f); cd.faceUp = true; // Place it on top of the pile for depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(-100 + discardPile.Count); }
// Return true if the two cards are adjacent in rank (A & K wrap around) public bool AdjacentRank(CardProspector c0, CardProspector c1) { // If either card is face-down, it's not adjacent. if (!c0.faceUp || !c1.faceUp) return (false); // If they are 1 apart, they are adjacent if (Mathf.Abs(c0.rank - c1.rank) == 1) { return (true); } // If one is A and the other King, they're adjacent if (c0.rank == 1 && c1.rank == 13) return (true); if (c0.rank == 13 && c1.rank == 1) return (true); // Otherwise, return false return (false); }
void MoveToDiscard(CardProspector cd) { //change state cd.state = eCardState.discard; //add to discard pile discardPile.Add(cd); //update transform parent even though im fairly sure its parent is already layoutAnchor cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID + 0.5f); cd.faceUp = true; cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(-100 + discardPile.Count); }
void MoveToDiscard(CardProspector cd) { cd.state = eCardState.discard; discardPile.Add(cd); cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID + 0.5f); cd.faceUp = true; cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(-100 + discardPile.Count); }
// Make cd the new target card void MoveToTarget(CardProspector cd) { // If there is currently a target card, move it to discardPile if (target != null) { MoveToDiscard(target); } target = cd; // cd is the new target cd.state = CardState.target; cd.transform.parent = layoutAnchor; // Move to the target position cd.transform.localPosition = new Vector3(layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID); cd.faceUp = true; // Make it face-up // Set the depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(0); }
// CardClicked is called any time a card in the game is clicked public void CardClicked(CardProspector cd) { // The reaction is determined by the state of the clicked card switch (cd.state) { case eCardState.target: // Clicking the target card does nothing break; case eCardState.drawpile: // Clicking any card in the drawPile will draw the next card MoveToDiscard(target); // Moves the target to the discardPile MoveToTarget(Draw()); // Moves the next drawn card to the target UpdateDrawPile(); // Restacks the drawPile ScoreManager.EVENT(eScoreEvent.draw); FloatingScoreHandler(eScoreEvent.draw); break; case eCardState.tableau: // Clicking a card in the tableau will check if it's a valid play bool validMatch = true; if (!cd.faceUp) { // If the card is face-down, it's not valid validMatch = false; } if (!AdjacentRank(cd, target)) { // If it's not an adjacent rank, it's not valid validMatch = false; } if (!validMatch) { return; // return if not valid } // If we got here, then: Yay! It's a valid card. tableau.Remove(cd); // Remove it from the tableau List MoveToTarget(cd); // Make it the target card SetTableauFaces(); // Update tableau card face-ups ScoreManager.EVENT(eScoreEvent.mine); FloatingScoreHandler(eScoreEvent.mine); break; } // Check to see whether the game is over or not CheckForGameOver(); }
void MoveToTarget(CardProspector cd) { if (target != null) { MoveToDiscard(target); } target = cd; cd.state = CardState.target; cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID); cd.faceUp = true; cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(0); }
// Moves the current target to the discardPile void MoveToDiscard(CardProspector cd) { // Set the state of the card to discard cd.state = eCardState.discard; discardPile.Add(cd); // Add it to the discardPile List<> cd.transform.parent = layoutAnchor; // Update its transform parent // Position this card on the discardPile cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID + 0.5f); cd.faceUp = true; // Place it on top of the pile for depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(-100 + discardPile.Count); }
public void CardClicked(CardProspector cd) { switch (cd.state) { case eCardState.target: break; case eCardState.drawpile: MoveToDiscard(target); MoveToTarget(Draw()); UpdateDrawPile(); ScoreManager.EVENT(eScoreEvent.draw); FloatingScoreHandler(eScoreEvent.draw); break; case eCardState.tableau: bool validMatch = true; if (!cd.faceUp) { validMatch = false; } if (!AdjacentRank(cd, target)) { validMatch = false; } if (!validMatch) { return; } tableau.Remove(cd); MoveToTarget(cd); SetTableauFaces(); SetTableauFaces(); ScoreManager.EVENT(eScoreEvent.mine); FloatingScoreHandler(eScoreEvent.mine); break; } CheckForGameOver(); }
// the CardClicked function public void CardClicked(CardProspector card) { switch (card.state) { case CardState.target: // Click the target card does nothing break; case CardState.drawpile: // Click the drawpile will replace the target card with a new one and move it to discardPile MoveToDiscard(target); MoveToTarget(Draw()); UpdateDrawPile(); ScoreManager(ScoreEvent.draw); break; case CardState.tableau: // Click a card in the tableau will check if it's a valid play bool validPlay = card.faceUp; // Check if it is hidden ( faceUp or not) // Check if it is adjacent to the target if (!AdjacentRank(card, target)) { validPlay = false; } if (validPlay == false) { return; // Return if it is not a valid move } // It is a valid move MoveToDiscard(target); // remove the origin target tableau.Remove(card); // Remove it from the tableau list MoveToTarget(card); // Make it the new target SetTableauFaces(); // Update tableau card face- ScoreManager(ScoreEvent.mine); break; } // Check whether the game is over CheckForGameOver(); }
public void CardClicked(CardProspector cd) //From pg 704 { switch (cd.state) //The reaction is determined by the state of the clicked card { case CardState.target: //clcking the target card does nothing break; case CardState.drawpile: //Clicking any card in the drawPile will draw the next card MoveToDiscard(target); //Moves target to discardPile MoveToTarget(Draw()); //Moves next drawn card to th target UpdateDrawPile(); //Restacks the drawPile ScoreManager(ScoreEvent.draw); //from pg 713 for score break; case CardState.tableau: //Clicking a card in the tableau will chec if it's a valid play bool validMatch = true; //This and below pg 708. if (!cd.faceUp) //If it's not an adjacent rank, it's not valid { validMatch = false; } if (!AdjacentRank(cd, target)) //If it's not an adjacent rank, it's not valid. { validMatch = false; } if (!validMatch) { return; //Return if not valid } //Next two lines means it has to be valid. tableau.Remove(cd); //If it's a valid card, Remove it from the tableau List. MoveToTarget(cd); //Make it the target card. //End pg 708 stuff. SetTableauFaces(); //Update tableau card face-ups. //From pg 709 if (cd.tag.Equals("goldCard")) //MY STUFF to make gold card count as double chain value. { ScoreManager(ScoreEvent.mineGold); } else { ScoreManager(ScoreEvent.mine); //From pg 713 for score } break; } CheckForGameOver(); //Check to see whether game is over or not. Pg 710 }
//moves the curren target to the discardPile void MoveToDiscard(CardProspector cd) { //set the state of the card to discard cd.state = CardState.discard; discardPile.Add(cd); cd.transform.parent = layoutAnchor; cd.transform.localPosition = Vector3.Lerp(cd.transform.localPosition, new Vector3 ( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID + 0.5f ), 0.25f); //position it on the discard pile cd.faceUp = true; //place it on top of the pile for depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(-100 + discardPile.Count); }
public bool DifferentColor(CardProspector c0, CardProspector c1) { // If either card is face-down, they don't have same color if (!c0.faceUp || !c1.faceUp) { return(false); } // If they have different color, they have different color if (c0.color != c1.color) { return(true); } // Otherwise, return false return(false); }
// Make cd the new target card void MoveToTarget(CardProspector cd) { // If there is currently a target card, move it to discardPile if (target != null) { MoveToDiscard(target); } target = cd; // cd is the new target cd.state = eCardState.target; cd.transform.parent = layoutAnchor; // Move to the target position cd.transform.localPosition = new Vector3(layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID); cd.faceUp = true; // Make it face-up // Set the depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(0); }
//CardClicked is called any time a card in the game is clicked public void CardClicked(CardProspector cd) { //the reaction is determined by the state of the clicked card switch (cd.state) { case eCardState.target: //clicking the target card does nothing break; case eCardState.drawpile: //clicking any card in the drawPile will draw the next card MoveToDiscard(target); //moves the target to the discard pile MoveToTarget(Draw()); //moves the next drawn card to the target UpdateDrawPile(); //restacks the drawPile break; case eCardState.tableau: //clicking a card in the tableau will check if its a valid play bool validMatch = true; if (!cd.faceUp) { //if the card is face-down, its not valid validMatch = false; } if (!AdjacentRank(cd, target)) { //if it's not an adjacent rank it's not valid validMatch = false; } if (!validMatch) { return; //return if not valid } //if we got here, then: YAY! its a valid card. tableau.Remove(cd); //remove it from the tableau List MoveToTarget(cd); //make it the target card SetTableauFaces(); break; } //check to see whether the game is over or not CheckForGameOver(); }
//使cd成为新的目标牌 void MoveToTarget(CardProspector cd) { //如果当前已有目标牌,则将它移动到弃牌堆 if (target != null) { MoveToDiscard(target); } target = cd;//cd成为新的目标牌 cd.state = CardState.target; cd.transform.parent = layoutAnchor; //移动到目标位置 cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID); cd.faceUp = true;//纸牌正面朝上 //设置深度排序 cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(0); }
public bool AdjacentRank(CardProspector c0, CardProspector c1) { if (!c0.faceUp || !c1.faceUp) { return(false); } if (Mathf.Abs(c0.rank - c1.rank) == 1) { return(true); } if (c0.rank == 1 && c1.rank == 13) { return(true); } if (c0.rank == 13 && c1.rank == 1) { return(true); } return(false); }
// Задаём новый таргет void MoveToTarget(CardProspector cd) { // Если уже есть таргет, убираем последний в биту if (target != null) { MoveToDiscard(target); } target = cd; // Новый таргет cd.state = CardState.target; cd.transform.parent = layoutAnchor; // Перемещаем в позицию таргета cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID); cd.faceUp = true; // Видим таргет // Задаём глубину прорисовки cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(0); }
//checks to see if cards are alternating color public bool AlternatingColor(CardProspector c0, CardProspector c1) { //checked if either card is Face down if (!c0.faceUp || !c1.faceUp) { return(false); } if ((c0.suit == "C" || c0.suit == "S") && (c1.suit == "H" || c1.suit == "D")) { return(true); } if ((c0.suit == "H" || c0.suit == "D") && (c1.suit == "C" || c1.suit == "S")) { return(true); } return(false); }
//CardClicked is called any time a card in the game is clicked public void CardClicked(CardProspector cd) { //The reaction is determined by the state of the clicked card switch (cd.state) { case CardState.target: //Clicking the target card does nothing break; case CardState.drawpile: //Clicking any card in the drawPile will draw the next card MoveToDiscard(target); //Moves the target to the discardPile MoveToTarget(Draw ()); //Moves the next drawn card to the target UpdateDrawPile(); //Restacks the drawPile ScoreManager(ScoreEvent.draw); break; case CardState.tableau: //Clicking a card in the tableau will check if it's a valid play bool validMatch = true; if(!cd.faceUp){ //If the card is face-down, it's not valid validMatch = false; } if(!AdjacentRank(cd, target)){ //If it's not an adjacent rank, it's not valid validMatch = false; } if(!validMatch) return; //return if not valid //Yay! It's a valid card tableau.Remove(cd); //Remove it from the tableau List MoveToTarget(cd); //Make it the target card SetTableauFaces(); //Update tableau card face-ups ScoreManager(ScoreEvent.mine); break; } CheckForGameOver (); }
public void CardClicked(CardProspector cd) { // the reaction is determined by the state of the clicked card switch (cd.state) { case eCardState.target: break; case eCardState.drawpile: // clicking any card in the dP will draw the next card MoveToDiscard(target); //Moves the target to the dP MoveToTarget(Draw()); // Moves the next drawn card to the target UpdateDrawPile(); // restacks the dP ScoreManager.EVENT(eScoreEvent.draw); FloatingScoreHandler(eScoreEvent.draw); break; case eCardState.tableau: // clicking a card in the tab will check if it's a valid play bool validMatch = true; if (!cd.faceUp) { validMatch = false; } if (!AdjacentRank(cd, target)) { validMatch = false; } if (!validMatch) { return; } tableau.Remove(cd); MoveToTarget(cd); SetTableauFaces(); ScoreManager.EVENT(eScoreEvent.mine); FloatingScoreHandler(eScoreEvent.mine); break; } CheckForGameOver(); }
//Returns true if the two cards are of different colour public bool AlternatingColour(CardProspector c0, CardProspector c1) { // If either card is face-down, it's not alternating. if (!c0.faceUp || !c1.faceUp) { return(false); } //If one is red and the other is black, return true if (c0.colS == "Red" && c1.colS == "Black") { return(true); } if (c0.colS == "Black" && c1.colS == "Red") { return(true); } //Otherwise, return false return(false); }
public void newTarget(CardProspector card) { target.state = CardState.discard; target.SetSortingLayerName ("discard"); if (card.state == CardState.tableau) tableau.Remove (card); else if (card.state == CardState.drawpile) drawPile.Remove (card); card.faceUp = true; card.layoutID = layout.discardPile.id; card.transform.parent = layoutAnchor; card.transform.localPosition = new Vector3 (layout.discardPile.x,layout.discardPile.y,-layout.discardPile.layerID); card.slotDef = layout.discardPile; card.state = CardState.target; card.SetSortingLayerName (layout.discardPile.layerName); discardPile.Add (card); target = card; if (tableau.Count == 0) { Puntos.S.Totaliza(); Win(); } else if (drawPile.Count == 0) { bool lose = true; foreach (CardProspector c in tableau) { if (c.faceUp && possibleTarget(c)) { lose = false; break; } } if (lose) { Puntos.S.Totaliza(); Lose(); } } }
// Moves the current target to the discardPile void MoveToDiscard(CardProspector cd) { // Set the card state to discard cd.state = CardState.discard; // Set the parent and localposition to the discardpile cd.transform.parent = layoutAnchor; float x = layout.multiplier.x * layout.discardPile.x; float y = layout.multiplier.y * layout.discardPile.y; cd.transform.localPosition = new Vector3(x, y, -layout.discardPile.layerId + 0.5f); // Set the faceUp cd.faceUp = true; // Add it to the list of discardPile discardPile.Add(cd); // Place it on top of the pile for depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortingOrder(-100 + discardPile.Count); }
// Move the top card of the DrawPile to the target void MoveToTarget(CardProspector cd) { // Set the card state to target cd.state = CardState.target; // Set the parent and localpotion to the target position cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerId); // Set the faceUp cd.faceUp = true; // Set it to target target = cd; // Place it on the target layer and set the order cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortingOrder(0); }
// make cd the new target card void MoveToTarget(CardProspector cd) { if (target != null) { MoveToDiscard(target); // if there is a target card, move it to dP } target = cd; cd.state = eCardState.target; cd.transform.parent = layoutAnchor; // move to the target position // position this card on the dP cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID); cd.faceUp = true; // set the depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(0); }
// Return true if the two cards are EqualToThirteen in rank public bool EqualToThirteenRank(CardProspector c0, CardProspector c1) { // If either card is face-down, it's not EqualToThirteen. if (!c0.faceUp || !c1.faceUp) { return(false); } // If they are 1 apart, they are EqualToThirteen if (Mathf.Abs(c0.rank + c1.rank) == 13) { return(true); } if (c0.rank == 13) { MoveToDiscard(c0); } //if (c0.rank == 13 && c1.rank == 1) return (true); //Otherwise, return false return(false); }
public bool AdjacentRank(CardProspector c0, CardProspector c1) { if (!c0.faceUp || !c1.faceUp) { return(false); } if (Mathf.Abs(c0.rank - c1.rank) == 1) { return(true); } // If one is Ace and the other King, they are adjacent if (c0.rank == 1 && c1.rank == 13) { return(true); } if (c0.rank == 13 && c1.rank == 1) { return(true); } return(false); }
public bool AdjacentRank(CardProspector card0, CardProspector card1) { if (!card0.FaceUp || !card1.FaceUp) { return(false); } if (Mathf.Abs(card0.Rank - card1.Rank) == 1) { return(true); } if (card0.Rank == 1 && card1.Rank == 13) { return(true); } if (card0.Rank == 13 && card1.Rank == 1) { return(true); } return(false); }
public bool AdjacentRank(CardProspector c0, CardProspector c1) //Return true if the two cards are adjcent in rank (A & K wrap around). //Pg 707! { if (!c0.faceUp || !c1.faceUp) { return(false); //If either card is face down, it's not adjacent. } if (Mathf.Abs(c0.rank - c1.rank) == 1) { return(true); } //If they are 1 apart, they are adjacent //If one is A and the other King, they're adjacent. if (c0.rank == 1 && c1.rank == 13) { return(true); } if (c0.rank == 13 && c1.rank == 1) { return(true); } //Otherwise, return false return(false); }
}//end of LayoutGame public void CardClicked(CardProspector cd) { switch (cd.state) { case CardState.target: break; case CardState.drawpile: MoveToDiscard (target); MoveToTarget (Draw ()); UpdateDrawPile (); ScoreManager(ScoreEvent.draw); break; case CardState.tableau: bool validMatch = true; if (!cd.faceUP) validMatch = false; if (!AdjacentRank(cd,target)) validMatch = false; if (!validMatch) return; tableau.Remove(cd); MoveToTarget(cd); SetTableauFaces(); ScoreManager(ScoreEvent.mine); break; }//end of switch CheckForGameOver (); }//end of CardClicked
void MoveToTarget(CardProspector cd) { if (target != null) MoveToDiscard (target); target = cd; cd.state = CardState.target; cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3 ( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID ); cd.faceUp = true; cd.SetSortingLayerName (layout.discardPile.layerName); cd.SetSortOrder (0); }
void MoveToDiscard(CardProspector cd) { cd.state = CardState.discard; discardPile.Add (cd); cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3 ( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID+0.5f); cd.faceUp = true; cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(-100+discardPile.Count); }
// Make cd the new target card void MoveToTarget(CardProspector cd) { // If there is currently a target card, move it to discardPile if (target != null) MoveToDiscard(target); target = cd; // cd is the new target cd.state = CardState.target; cd.transform.parent = layoutAnchor; // Move to the target position cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID ); cd.faceUp = true; // Make it face-up // Set the depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(0); }
// Moves the current target to the discardPile void MoveToDiscard(CardProspector cd) { // Set the state of the card to discard cd.state = CardState.discard; discardPile.Add(cd); // Add it to the discardPile List<> cd.transform.parent = layoutAnchor; // Update its transform parent cd.transform.localPosition = new Vector3( layout.multiplier.x * layout.discardPile.x, layout.multiplier.y * layout.discardPile.y, -layout.discardPile.layerID+0.5f ); // ^ Position it on the discardPile cd.faceUp = true; // Place it on top of the pile for depth sorting cd.SetSortingLayerName(layout.discardPile.layerName); cd.SetSortOrder(-100+discardPile.Count); }
public bool possibleTarget(CardProspector card) { int dis = target.rank - card.rank; if (dis == 1 || dis == -1 || dis == 12 || dis == -12) return true; return false; }
public void oneLessTableau(CardProspector card) { foreach (CardProspector c in tableau) { c.hiddenBy.Remove(card); if (c.hiddenBy.Count == 0) c.faceUp = true; } }
// LayoutGame() positions the initial tableau of cards, a.k.a. the "mine" void LayoutGame() { // Create an empty GameObject to serve as an anchor for the tableau if (layoutAnchor == null) { GameObject tGO = new GameObject("_LayoutAnchor"); // ^ Create an empty GameObject named _LayoutAnchor in the Hierarchy layoutAnchor = tGO.transform; // Grab its Transform layoutAnchor.transform.position = layoutCenter; // Position it } CardProspector cp; // Follow the layout foreach (SlotDef tSD in layout.slotDefs) { // ^ Iterate through all the SlotDefs in the layout.slotDefs as tSD cp = Draw(); // Pull a card from the top (beginning) of the drawPile cp.faceUp = tSD.faceUp; // Set its faceUp to the value in SlotDef cp.transform.parent = layoutAnchor; // Make its parent layoutAnchor // This replaces the previous parent: deck.deckAnchor, which appears // as _Deck in the Hierarchy when the scene is playing. cp.transform.localPosition = new Vector3( layout.multiplier.x * tSD.x, layout.multiplier.y * tSD.y, -tSD.layerID); // ^ Set the localPosition of the card based on slotDef cp.layoutID = tSD.id; cp.slotDef = tSD; cp.state = CardState.tableau; //cp.hiddenBy = List<CardProspector>(); //foreach(int tapa in tSD.hiddenBy){ // cp.hiddenBy.Add( //} cp.SetSortingLayerName(tSD.layerName); // Set the sorting layers tableau.Add(cp); // Add this CardProspector to the List<> tableau } for( int i = 0; i < layout.slotDefs.Count; i++) { foreach( int tapa in layout.slotDefs[i].hiddenBy){ tableau[i].hiddenBy.Add(tableau[tapa]); } } SlotDef dP = layout.discardPile; cp = Draw (); cp.faceUp = true; cp.layoutID = dP.id; cp.transform.parent = layoutAnchor; cp.transform.localPosition = new Vector3 (dP.x,dP.y,-dP.layerID); cp.slotDef = dP; cp.state = CardState.target; cp.SetSortingLayerName (dP.layerName); discardPile.Add (cp); target = cp; dP = layout.drawPile; int N = 0; foreach (CardProspector c in drawPile) { c.faceUp = dP.faceUp; c.transform.parent = layoutAnchor; c.transform.localPosition = new Vector3( dP.x + dP.stagger.x * N, dP.y + dP.stagger.y * N, -dP.layerID); c.layoutID = dP.id; c.slotDef = dP; c.state = CardState.drawpile; c.SetSortingLayerName(dP.layerName); N++; } }