// 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 = 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); }
}//end of CardClicked 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); }//end of MoveToDiscard
}//end of MoveToDiscard 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); }//end of MoveToTarget
private void MoveToDiscard(CardProspector card) { card.State = CardState.Discard; this.DiscardPile.Add(card); card.transform.parent = this.LayoutAnchor; card.transform.localPosition = new Vector3(this.Layout.Multiplier.x * this.Layout.DiscardPile.X, this.Layout.Multiplier.y * this.Layout.DiscardPile.Y, -this.Layout.DiscardPile.LayerId + 0.5f); card.FaceUp = true; card.SetSortingLayerName(this.Layout.DiscardPile.LayerName); card.SetSortOrder(-100 + this.DiscardPile.Count); }
void MoveToWaste(CardProspector cd) { cd.state = eCardState.waste; wastePile.Add(cd); cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3(layout.multiplier.x * layout.drawPile.x, layout.multiplier.y * layout.drawPile.y - 5, -layout.drawPile.layerID + .01f); cd.faceUp = true; cd.SetSortingLayerName(layout.drawPile.layerName); cd.SetSortOrder(-100 + (wastePile.Count * 5)); }
private void MoveToTarget(CardProspector card) { if (this.Target != null) { this.MoveToDiscard(this.Target); } this.Target = card; card.State = CardState.Target; card.transform.parent = this.LayoutAnchor; card.transform.localPosition = new Vector3(this.Layout.Multiplier.x * this.Layout.DiscardPile.X, this.Layout.Multiplier.y * this.Layout.DiscardPile.Y, -this.Layout.DiscardPile.LayerId); card.FaceUp = true; card.SetSortingLayerName(this.Layout.DiscardPile.LayerName); card.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); }
//移动当前目标纸牌到弃牌堆 void MoveToDiscard(CardProspector cd) { //设置纸牌的状态为丢弃 cd.state = CardState.discard; discardPile.Add(cd); cd.transform.parent = layoutAnchor;//更新transform父元素 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) { //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); }
// 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); }
//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); }
//从待抽取的卡堆中抽取一张新的target void MoveToTarget(CardProspector cd) { if (target != null) { MoveToDiscard(target); } target = cd; cd.state = eCardState.target; cd.transform.parent = layoutAnchor; //先移动到世界坐标系的位置 //把抽取的卡片移动到target的位置,注意是与parent: layerAnchor的相对位置 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); }
// 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); }
// Задаём новый таргет 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); }
//使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 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(); } } }
// 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); }
// 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); }
// 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); }
// Arrange all the cards of the drawPile to show how many are left void UpdateDrawPile() { // go through all the left cards in the drawPile for (int i = 0; i < drawPile.Count; i++) { // Set the position CardProspector cd = drawPile[i]; cd.transform.parent = layoutAnchor; cd.transform.localPosition = new Vector3( layout.multiplier.x * (layout.drawPile.x + i * layout.drawPile.stagger.x), layout.multiplier.y * (layout.drawPile.y + i * layout.drawPile.stagger.y), -layout.drawPile.layerId + i * 0.1f); // Set the face down cd.faceUp = false; // Set the state as drawpile cd.state = CardState.drawpile; // Sorting the order and layers cd.SetSortingLayerName(layout.drawPile.layerName); cd.SetSortingOrder(-10 * i); } }
// 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); }
// 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.discard: return; break; case eCardState.drawpile1: drawpile1.RemoveAt(drawpile1.Count - 1); UpdateClockFace(drawpile1); break; case eCardState.drawpile2: drawpile2.RemoveAt(drawpile2.Count - 1); UpdateClockFace(drawpile2); break; case eCardState.drawpile3: drawpile3.RemoveAt(drawpile3.Count - 1); UpdateClockFace(drawpile3); break; case eCardState.drawpile4: drawpile4.RemoveAt(drawpile4.Count - 1); UpdateClockFace(drawpile4); break; case eCardState.drawpile5: drawpile5.RemoveAt(drawpile5.Count - 1); UpdateClockFace(drawpile5); break; case eCardState.drawpile6: drawpile6.RemoveAt(drawpile6.Count - 1); UpdateClockFace(drawpile6); break; case eCardState.drawpile7: drawpile7.RemoveAt(drawpile7.Count - 1); UpdateClockFace(drawpile7); break; case eCardState.drawpile8: drawpile8.RemoveAt(drawpile8.Count - 1); UpdateClockFace(drawpile8); break; case eCardState.drawpile9: drawpile9.RemoveAt(drawpile9.Count - 1); UpdateClockFace(drawpile9); break; case eCardState.drawpile10: drawpile10.RemoveAt(drawpile10.Count - 1); UpdateClockFace(drawpile10); break; case eCardState.drawpile11: drawpile11.RemoveAt(drawpile11.Count - 1); UpdateClockFace(drawpile11); break; case eCardState.drawpile12: drawpile12.RemoveAt(drawpile12.Count - 1); UpdateClockFace(drawpile12); break; case eCardState.drawpile13: drawpile13.RemoveAt(drawpile13.Count - 1); UpdateClockFace(drawpile13); break; } cd.state = eCardState.discard; SlotDef tSD = layout.sDict["drawpile" + cd.rank]; cd.slotDef.x = tSD.x; cd.slotDef.y = tSD.y; cd.slotDef.faceUp = true; cd.transform.localPosition = new Vector3(layout.multiplier.x * tSD.x, layout.multiplier.y * tSD.y, 0); cd.SetSortingLayerName(layout.sortingLayerNames[0]); discardPile.Add(cd); //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 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(); }
using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class Prospector : MonoBehaviour { static public Prospector S; [Header("Set in Inspector")] public TextAsset deckXML; public TextAsset layoutXML; public float xOffset = 3; public float yOffset = -2.5f; public Vector3 layoutCenter; public Vector2 fsPosMid = new Vector2(0.5f, 0.90f); public Vector2 fsPosRun = new Vector2(0.5f, 0.75f); public Vector2 fsPosMid2 = new Vector2(0.4f, 1.0f); public Vector2 fsPosEnd = new Vector2(0.5f, 0.95f); public float reloadDelay = 2f; public Text gameOverText, roundResultText, highScoreText; [Header("Set Dynamically")] public Deck deck; public Layout layout; public List<CardProspector> drawPile; public Transform layoutAnchor; public CardProspector target; public List<CardProspector> tableau; public List<CardProspector> discardPile; public FloatingScore fsRun; void Awake() { S = this; SetUpUITexts(); } void SetUpUITexts() { // Set up the HighScore UI Text GameObject go = GameObject.Find("HighScore"); if (go != null) { highScoreText = go.GetComponent<Text>(); } int highScore = ScoreManager.HIGH_SCORE; string hScore = "High Score: " + Utils.AddCommasToNumber(highScore); go.GetComponent<Text>().text = hScore; // Set up the UI Texts that show at the end of the round go = GameObject.Find("GameOver"); if (go != null) { gameOverText = go.GetComponent<Text>(); } go = GameObject.Find("RoundResult"); if (go != null) { roundResultText = go.GetComponent<Text>(); } // Make the end of round texts invisible ShowResultsUI(false); } void ShowResultsUI(bool show) { gameOverText.gameObject.SetActive(show); roundResultText.gameObject.SetActive(show); } void Start() { Scoreboard.S.score = ScoreManager.SCORE; deck = GetComponent<Deck>(); deck.InitDeck(deckXML.text); Deck.Shuffle(ref deck.cards); layout = GetComponent<Layout>(); layout.ReadLayout(layoutXML.text); drawPile = ConvertListCardsToListCardProspectors(deck.cards); LayoutGame(); } List<CardProspector> ConvertListCardsToListCardProspectors(List<Card> lCD) { List<CardProspector> lCP = new List<CardProspector>(); CardProspector tCP; foreach (Card tCD in lCD) { tCP = tCD as CardProspector; // a lCP.Add(tCP); } return (lCP); } CardProspector Draw() { CardProspector cd = drawPile[0]; // Pull the 0th CardProspector drawPile.RemoveAt(0); // Then remove it from List<> drawPile return (cd); // And return it } // 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 // a 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) { cp = Draw(); cp.faceUp = tSD.faceUp; cp.transform.parent = layoutAnchor; 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; // CardProspectors in the tableau have the state CardState.tableau cp.state = eCardState.tableau; cp.SetSortingLayerName(tSD.layerName); tableau.Add(cp); } foreach (CardProspector tCP in tableau) { foreach (int hid in tCP.slotDef.hiddenBy) { cp = FindCardByLayoutID(hid); tCP.hiddenBy.Add(cp); } } MoveToTarget(Draw()); UpdateDrawPile(); } // Convert from the layoutID int to the CardProspector with that ID CardProspector FindCardByLayoutID(int layoutID) { foreach (CardProspector tCP in tableau) { // Search through all cards in the tableau List<> if (tCP.layoutID == layoutID) { // If the card has the same ID, return it return (tCP); } } // If it's not found, return null return (null); } // This turns cards in the Mine face-up or face-down void SetTableauFaces() { foreach (CardProspector cd in tableau) { bool faceUp = true; // Assume the card will be face-up foreach (CardProspector cover in cd.hiddenBy) { // If either of the covering cards are in the tableau if (cover.state == eCardState.tableau) { faceUp = false; // then this card is face-down } } cd.faceUp = faceUp; // Set the value on the card } } 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); } // 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); } // Arranges all the cards of the drawPile to show how many are left void UpdateDrawPile() { CardProspector cd; // Go through all the cards of the drawPile for (int i = 0; i < drawPile.Count; i++) { cd = drawPile[i]; cd.transform.parent = layoutAnchor; // Position it correctly with the layout.drawPile.stagger Vector2 dpStagger = layout.drawPile.stagger; cd.transform.localPosition = new Vector3( layout.multiplier.x * (layout.drawPile.x + i * dpStagger.x), layout.multiplier.y * (layout.drawPile.y + i * dpStagger.y), -layout.drawPile.layerID + 0.1f * i); cd.faceUp = false; // Make them all face-down cd.state = eCardState.drawpile; // Set depth sorting cd.SetSortingLayerName(layout.drawPile.layerName); cd.SetSortOrder(-10 * i); } } 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) { // 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; tableau.Remove(cd); MoveToTarget(cd); SetTableauFaces(); ScoreManager.EVENT(eScoreEvent.mine); FloatingScoreHandler(eScoreEvent.mine); break; } CheckForGameOver(); } void CheckForGameOver() { // If the tableau is empty, the game is over if (tableau.Count == 0) { // Call GameOver() with a win GameOver(true); return; } // If there are still cards in the draw pile, the game's not over if (drawPile.Count > 0) { return; } // Check for remaining valid plays foreach (CardProspector cd in tableau) { if (AdjacentRank(cd, target)) { // If there is a valid play, the game's not over return; } } // Since there are no valid plays, the game is over // Call GameOver with a loss GameOver(false); } // Called when the game is over. Simple for now, but expandable void GameOver(bool won){ int score = ScoreManager.SCORE; if (fsRun != null) score += fsRun.score; if (won) {
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); }