void Awake() { S = this; //check for a high score in PlayerPrefs if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } //add the score from last round, whihc will be >0 if it was a win score += SCORE_FROM_PREV_ROUND; //reset the SCORE_FROM_PREV_ROUND SCORE_FROM_PREV_ROUND = 0; //set up the GUITexts that show at the end of the round //get the GUIText Components GameObject go = GameObject.Find("GameOver"); if (go != null) { GTGameOver = go.GetComponent <GUIText>(); } go = GameObject.Find("RoundResult"); if (go != null) { GTRoundResult = go.GetComponent <GUIText>(); } //make them invisible ShowResultGTs(false); go = GameObject.Find("HighScore"); string hScore = "High Score: " + Utils.AddCommasToNumber(HIGH_SCORE); go.GetComponent <GUIText>().text = hScore; }
void Awake() { S = this; if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } score += SCORE_FROM_PREV_ROUND; SCORE_FROM_PREV_ROUND = 0; GameObject go = GameObject.Find("GameOver"); if (go != null) { GTGameOver = go.GetComponent <GUIText> (); } go = GameObject.Find("RoundResult"); if (go != null) { GTRoundResult = go.GetComponent <GUIText> (); } ShowResultGTs(false); go = GameObject.Find("HighScore"); string hScore = "High Score: " + Utils.AddCommasToNumber(HIGH_SCORE); go.GetComponent <GUIText> ().text = hScore; }
void Awake() { S = this; //Set up a Singleton for Prospector //For scoring from page 712 if (PlayerPrefs.HasKey("ProspectorHighScore")) //Check for a high score in PlayerPrefs { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } score += SCORE_FROM_PREV_ROUND; //Add the score from the last round, which will be >0 if it was a win SCORE_FROM_PREV_ROUND = 0; //And reset the thing. //Below from page 726 //Set up the GUITexts that show at the end of the round //Get the GUIText Components GameObject go = GameObject.Find("GameOver"); if (go != null) { GTGameOver = go.GetComponent <Text>(); } go = GameObject.Find("RoundResult"); if (go != null) { GTRoundResult = go.GetComponent <Text>(); } //Make them invisible ShowResultGTs(false); go = GameObject.Find("HighScore"); string hScore = "High Score: " + Utils.AddCommasToNumber(HIGH_SCORE); go.GetComponent <Text>().text = hScore; }
void Awake() { S = this; //确认PlayerPrefs中的高分值 if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } //将分数添加到上一轮,如果赢的话分数>0 score += SCORE_FROM_PREV_ROUND; //并且重置SCORE_FROM_PREV_ROUND SCORE_FROM_PREV_ROUND = 0; //设置最后一轮显示的GUITexts //获取GUIText组件 GameObject go = GameObject.Find("GameOver"); if (go != null) { GTGameOver = go.GetComponent <GUIText>(); } go = GameObject.Find("RoundResult"); if (go != null) { GTRoundResult = go.GetComponent <GUIText>(); } //使之不可见 ShowResultGTs(false); go = GameObject.Find("HighScore"); string hScore = "High Score:" + Utils.AddCommasToNumber(HIGH_SCORE); go.GetComponent <GUIText>().text = hScore; }
// void Awake is left out of many parts of the tutorial. Not sure if it needs to be part of the final code void Awake() { S = this; // Set up a Singleton for Prospector // Check for a high score in PlayerPrefs if (PlayerPrefs.HasKey ("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } // Add the score from last round, which will be >0 if it was a win score += SCORE_FROM_PREV_ROUND; // And reset the SCORE_FROM_PREV_ROUND SCORE_FROM_PREV_ROUND = 0; // Set up the GUITexts that show at the end of the round // Get the GUIText Components GameObject go = GameObject.Find ("GameOver"); if (go != null) { GTGameOver = go.GetComponent<GUIText>(); } go = GameObject.Find ("RoundResult"); if (go != null) { GTRoundResult = go.GetComponent<GUIText>(); } // Make them invisible ShowResultGTs(false); go = GameObject.Find("HighScore"); string hScore = "High Score: "+Utils.AddCommasToNumber(HIGH_SCORE); go.GetComponent<GUIText>().text = hScore; }
void Awake() { S = this; // Set up a Singleton for Prospector // Check for a high score in PlayerPrefs if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } // Add the score from last round, which will be >0 if it was a win score += SCORE_FROM_PREV_ROUND; // And reset the SCORE_FROM_PREV_ROUND SCORE_FROM_PREV_ROUND = 0; GameObject go = GameObject.Find("GameOver"); if (go != null) { GTGameOver = go.GetComponent <GUIText>(); } go = GameObject.Find("RoundResult"); if (go != null) { GTRoundResult = go.GetComponent <GUIText>(); } ShowResultsGTs(false); go = GameObject.Find("HighScore"); string hScore = "High Score:" + Utils.AddCommasToNumber(HIGH_SCORE); go.GetComponent <GUIText>().text = hScore; }
void Awake() { S = this; xOffset = 3; yOffset = -2.5f; SetUpUITexts(); }
public static void ProspectorTest() { Job prospector = new Prospector(); Assert.AreEqual(prospector.Salary, 400); Assert.IsTrue(prospector.payoutNumber.Contains(2)); Assert.IsTrue(prospector.payoutNumber.Contains(12)); }
void Awake() { S = this; // Set up a Singleton for Prospector SetUpUITexts(); if (SM == null) { SM = GetComponent <ScoreManager>(); } }
void Awake() { S = this; if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } score += SCORE_FROM_PREV_ROUND; SCORE_FROM_PREV_ROUND = 0; }
private void Awake() { S = this; if (PlayerPrefs.HasKey("ProspectorHighScore")) { HighScore = PlayerPrefs.GetInt("ProspectorHighScore"); } this.Score += ScoreFromPrevRound; ScoreFromPrevRound = 0; }
void Awake() { S = this; // Проверяем наивысший счёт в PlayerPrefs if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } // Добавляем счёт с предыдущего раунда, который будет > 0, если это победа score += SCORE_FROM_PREV_ROUND; // И обнуляем счёт с пред. раунда SCORE_FROM_PREV_ROUND = 0; }
void Awake() { S = this; // Set up a Singleton for Prospector // Check for a high score in PlayerPrefs if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } // Add the score from last round, which will be >0 if it was a win score += SCORE_FROM_PREV_ROUND; // And reset the SCORE_FROM_PREV_ROUND SCORE_FROM_PREV_ROUND = 0; }
void Awake() { S = this; // Set up a Singleton for Prospector if (PlayerPrefs.HasKey("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } score += SCORE_FROM_PREV_ROUND; SCORE_FROM_PREV_ROUND = 0; SetUpUITexts(); }
void Awake() { S = this; // Set up a Singleton for Prospector _SM = GameObject.Find("_MainCamera").GetComponent <ScoreManager>(); SetUpUITexts(); }
void Awake() { S = this; // Set up a Singleton for Prospector SetUpUITexts(); }
void Awake() { S = this; //Prospector singleton SetUpUITexts(); }
void Awake() { S = this; // Check for a high score in PlayerPrefs if (PlayerPrefs.HasKey ("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } // Add the score from last round, which will be >0 if it was a win score += SCORE_FROM_PREV_ROUND; // And reset the SCORE_FROM_PREV_ROUND SCORE_FROM_PREV_ROUND = 0; }
void Awake() { Scoreboard.S.score = ScoreManager.SCORE; S = this; SetUpUITexts(); }
void Awake() { S = this; // Set up a Singleton for Prospector }
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) {
private void Awake() { S = this; }
void Awake() { S = this; SetUpUITexts(); }
void Awake() { S = this; }
void Awake() { S = this; if (PlayerPrefs.HasKey ("ProspectorHighScore")) { HIGH_SCORE = PlayerPrefs.GetInt("ProspectorHighScore"); } score += SCORE_FROM_PREV_ROUND; SCORE_FROM_PREV_ROUND = 0; GameObject go = GameObject.Find ("GameOver"); if (go != null) { GTGameOver = go.GetComponent<GUIText>(); } go = GameObject.Find ("RoundResult"); if (go != null) { GTRoundResult = go.GetComponent<GUIText>(); } ShowResultGTs (false); go = GameObject.Find ("HighScore"); string hScore = "High Score: " + Utils.AddCommasToNumber (HIGH_SCORE); go.GetComponent<GUIText> ().text = hScore; }
private void Awake() { S = this; // Set up a Singelton for Prospector }