Пример #1
0
    void MoveToTarget(CardProspector cd)
    {
        if (target != null)
        {
            MoveToDiscard(target);
        }
        target              = cd;
        cd.state            = eCardState.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 + 0.5f);
        cd.faceUp = true;

        cd.SetSortingLayerName(layout.discardPile.layerName);
        cd.SetSortOrder(0);
    }
Пример #2
0
 //移动当前目标纸牌到弃牌堆
 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);
 }
    //AAAAAAAAAAAAAAAA pg 552 "return true if the two  cards.." comes here after the elipsis

    //AAAAAAAAAAAAAAAAG pg 553 "// This turns cards in the Mine face-up or face-down" comes after same elipsis


    // 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);
    }
    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);
    }
Пример #5
0
    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);
    }
Пример #6
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);
    }
Пример #7
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            = 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);
 }
Пример #8
0
 //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);
 }
Пример #9
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);
    }
Пример #10
0
 //从待抽取的卡堆中抽取一张新的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);
 }
Пример #11
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);
 }
Пример #12
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);
 }
Пример #13
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);
    }
Пример #14
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 = 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);
 }
Пример #15
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);
 }
Пример #16
0
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)
        {
Пример #17
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);
 }
Пример #18
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);
    }