Exemple #1
0
    public PT_XMLReader xmlr; // Just like Deck, this has an PT_XMLReader

    #endregion Fields

    #region Methods

    // This function is called to read in the LayoutXML.xml file
    public void ReadLayout(string xmlText)
    {
        xmlr = new PT_XMLReader();
        xmlr.Parse(xmlText); // The XML is parsed
        xml = xmlr.xml["xml"][0]; // And xml is set as a shortcut to the XML
        // Read in the multiplier, which sets card spacing
        multiplier.x = float.Parse(xml["multiplier"][0].att("x"));
        multiplier.y = float.Parse(xml["multiplier"][0].att("y"));
        // Read in the slots
        SlotDef tSD;
        // slotsX is used as a shortcut to all the <slot>s
        PT_XMLHashList slotsX = xml["slot"];
        for (int i=0; i<slotsX.Count; i++) {
            tSD = new SlotDef(); // Create a new SlotDef instance
            if (slotsX[i].HasAtt("type")) {
                // If this <slot> has a type attribute parse it
                tSD.type = slotsX[i].att("type");
            } else {
                // If not, set its type to "slot"
                tSD.type = "slot";
            }
            // Various attributes are parsed into numerical values
            tSD.x = float.Parse( slotsX[i].att("x") );
            tSD.y = float.Parse( slotsX[i].att("y") );
            tSD.pos = new Vector3( tSD.x*multiplier.x, tSD.y*multiplier.y, 0 );
            // Sorting Layers
            tSD.layerID = int.Parse( slotsX[i].att("layer") );
            // In this game, the Sorting Layers are named 1, 2, 3, ...through 10
            // This converts the number of the layerID into a text layerName
            tSD.layerName = tSD.layerID.ToString();
            // The layers are used to make sure that the correct cards are
            // on top of the others. In Unity 2D, all of our assets are
            // effectively at the same Z depth, so sorting layers are used
            // to differentiate between them.
            // pull additional attributes based on the type of each <slot>
            switch (tSD.type) {
            case "slot":
                // ignore slots that are just of the "slot" type
                break;
            case "drawpile":
                // The drawPile xstagger is read but not actually used in Bartok
                tSD.stagger.x = float.Parse( slotsX[i].att("xstagger") );
                drawPile = tSD;
                break;
            case "discardpile":
                discardPile = tSD;
                break;
            case "target":
                // The target card has a different layer from discardPile
                target = tSD;
                break;
            case "hand":
                // Information for each player's hand
                tSD.player = int.Parse( slotsX[i].att("player") );
                tSD.rot = float.Parse( slotsX[i].att("rot") );
                slotDefs.Add (tSD);
                break;
            }
        }
    }
Exemple #2
0
    public PT_XMLReader xmlr; // Just like Deck, this has a PT_XMLReader

    #endregion Fields

    #region Methods

    // This function is called to read in the LayoutXML.xml file
    public void ReadLayout(string xmlText)
    {
        xmlr = new PT_XMLReader();
        xmlr.Parse(xmlText);      // The XML is parsed
        xml = xmlr.xml["xml"][0]; // And xml is set as a shortcut to the XML

        // Read in the multiplier, which sets card spacing
        multiplier.x = float.Parse(xml["multiplier"][0].att("x"));
        multiplier.y = float.Parse(xml["multiplier"][0].att("y"));

        // Read in the slots
        SlotDef tSD;
        // slotsX is used as a shortcut to all the <slot>s
        PT_XMLHashList slotsX = xml["slot"];

        for (int i=0; i<slotsX.Count; i++) {
            tSD = new SlotDef();  // Create a new SlotDef instance
            if (slotsX[i].HasAtt("type")) {
                // If this <slot> has a type attribute parse it
                tSD.type = slotsX[i].att("type");
            } else {
                // If not, set its type to "slot"; it's a tableau card
                tSD.type = "slot";
            }
            // Various attributes are parsed into numerical values
            tSD.x = float.Parse( slotsX[i].att("x") );
            tSD.y = float.Parse( slotsX[i].att("y") );
            tSD.layerID = int.Parse( slotsX[i].att("layer") );
            // This converts the number of the layerID into a text layerName
            tSD.layerName = sortingLayerNames[ tSD.layerID ];
            // The layers are used to make sure that the correct cards are
            //   on top of the others. In Unity 2D, all of our assets are
            //   effectively at the same Z depth, so the layer is used
            //   to differentiate between them.

            switch (tSD.type) {
                // pull additional attributes based on the type of this <slot>
            case "slot":
                tSD.faceUp = (slotsX[i].att("faceup") == "1");
                tSD.id = int.Parse( slotsX[i].att("id") );
                if (slotsX[i].HasAtt("hiddenby")) {
                    string[] hiding = slotsX[i].att("hiddenby").Split(',');
                    foreach( string s in hiding ) {
                        tSD.hiddenBy.Add ( int.Parse(s) );
                    }
                }
                slotDefs.Add(tSD);
                break;

            case "drawpile":
                tSD.stagger.x = float.Parse( slotsX[i].att("xstagger") );
                drawPile = tSD;
                break;
            case "discardpile":
                discardPile = tSD;
                break;
            }
        }
    }
Exemple #3
0
    public void ReadLayout(string xmlText)
    {
        xmlr = new PT_XMLReader ();
        xmlr.Parse (xmlText);
        xml = xmlr.xml ["xml"][0];

        multiplier.x = float.Parse (xml ["multiplier"] [0].att ("x"));
        multiplier.y = float.Parse (xml ["multiplier"] [0].att ("y"));

        SlotDef tSD;
        PT_XMLHashList slotsX = xml ["slot"];

        for (int i = 0; i < slotsX.Count; i++) {

            tSD = new SlotDef ();

            if(slotsX[i].HasAtt("type")){

                tSD.type = slotsX[i].att("type");

            }else{

                tSD.type = "slot";

            }
            tSD.x = float.Parse(slotsX[i].att("x"));
            tSD.y = float.Parse(slotsX[i].att("y"));
            tSD.layerID = int.Parse(slotsX[i].att("layer"));
            tSD.layerName = sortLayerNames[tSD.layerID];

            switch(tSD.type){

            case "slot":
                tSD.faceUp = (slotsX[i].att ("faceup") == "1");
                tSD.id = int.Parse (slotsX[i].att ("id"));
                if(slotsX[i].HasAtt ("hiddenby")){

                    string[] hiding = slotsX[i].att ("hiddenby").Split (',');
                    foreach(string s in hiding){ tSD.hiddenBy.Add(int.Parse(s)); }

                }
                slotDefs.Add (tSD);
                break;

            case "drawpile":
                tSD.stagger.x = float.Parse( slotsX[i].att ("xstagger") );
                drawPile = tSD;
                break;

            case "discardpile":
                discardPile = tSD;
                break;

            }

        }
    }
    public void ReadLayout(string xmlText)
    {
        xmlr = new PT_XMLReader ();
        xmlr.Parse (xmlText);
        xml = xmlr.xml ["xml"] [0];

        multiplier.x = float.Parse(xml["multiplier"][0].att ("x"));
        multiplier.y = float.Parse(xml["multiplier"][0].att ("y"));

        SlotDef tSD;
        PT_XMLHashList slotsX = xml ["slot"];

        for (int i = 0; i < slotsX.Count; i++) {

            tSD = new SlotDef();
            if(slotsX[i].HasAtt("type"))
                tSD.type = slotsX[i].att("type");
            else
                tSD.type = "slot";

            tSD.x = float.Parse (slotsX[i].att("x"));
            tSD.y = float.Parse (slotsX[i].att("y"));

            tSD.pos = new Vector3 (tSD.x * multiplier.x, tSD.y * multiplier.y, 0);

            tSD.layerID = int.Parse ( slotsX[i].att ("layer"));
            tSD.layerName = tSD.layerID.ToString();

            switch(tSD.type){

            case "slot":
                break;

            case "drawpile":
                tSD.stagger.x = float.Parse(slotsX[i].att("xstagger"));
                drawPile = tSD;
                break;

            case "discardpile":
                discardPile = tSD;
                break;

            case "target":
                target = tSD;
                break;

            case "hand":
                tSD.player = int.Parse(slotsX[i].att ("player"));
                tSD.rot = float.Parse(slotsX[i].att ("rot"));
                slotDefs.Add(tSD);
                break;

            }

        }
    }
Exemple #5
0
    // This function is called to read in the LayoutXML.xml file
    public void ReadLayout(string xmlText)
    {
        xmlr = new PT_XMLReader();
        xmlr.Parse(xmlText);      // The XML is parsed
        xml = xmlr.xml["xml"][0]; // And xml is set as a shortcut to the XML

        // Read in the multiplier, which sets card spacing
        multiplier.x = float.Parse(xml["multiplier"][0].att("x"));
        multiplier.y = float.Parse(xml["multiplier"][0].att("y"));

        // Read in the slots
        SlotDef tSD;
        // slotsX is used as a shortcut to all the <slot>s
        PT_XMLHashList slotsX = xml["slot"];

        for (int i = 0; i < slotsX.Count; i++)
        {
            tSD = new SlotDef(); // Create a new SlotDef instance
            if (slotsX[i].HasAtt("type"))
            {
                // If this <slot> has a type attribute parse it
                tSD.type = slotsX[i].att("type");
            }
            else
            {
                // If not, set its type to "slot"; it's a card in the rows
                tSD.type = "slot";
            }
            // Various attributes are parsed into numerical values
            tSD.x       = float.Parse(slotsX[i].att("x"));
            tSD.y       = float.Parse(slotsX[i].att("y"));
            tSD.layerID = int.Parse(slotsX[i].att("layer"));
            // This converts the number of the layerID into a text layerName
            tSD.layerName = sortingLayerNames[tSD.layerID];              // a

            switch (tSD.type)
            {
            // pull additional attributes based on the type of this <slot>
            case "slot":
                tSD.faceUp = (slotsX[i].att("faceup") == "1");
                tSD.id     = int.Parse(slotsX[i].att("id"));
                if (slotsX[i].HasAtt("hiddenby"))
                {
                    string[] hiding = slotsX[i].att("hiddenby").Split(',');
                    foreach (string s in hiding)
                    {
                        tSD.hiddenBy.Add(int.Parse(s));
                    }
                }
                slotDefs.Add(tSD);
                break;

            case "drawpile":
                tSD.stagger.x = float.Parse(slotsX[i].att("xstagger"));
                drawPile      = tSD;
                break;

            case "discardpile":
                discardPile = tSD;
                break;
            }
        }
    }
    // Bartok calls this method to read in the BartokLayoutXML.xml file
    public void ReadLayout(string xmlText)
    {
        xmlr = new PT_XMLReader();
        xmlr.Parse(xmlText);      // The XML is parsed
        xml = xmlr.xml["xml"][0]; // And xml is set as a shortcut to the XML

        // Read in the multiplier, which sets card spacing
        multiplier.x = float.Parse(xml["multiplier"][0].att("x"));
        multiplier.y = float.Parse(xml["multiplier"][0].att("y"));

        // Read in the slots
        SlotDef tSD;
        // slotsX is used as a shortcut to all the <slot>s
        PT_XMLHashList slotsX = xml["slot"];

        for (int i = 0; i < slotsX.Count; i++)
        {
            tSD = new SlotDef(); // Create a new SlotDef instance
            if (slotsX[i].HasAtt("type"))
            {
                // If this <slot> has a type attribute parse it
                tSD.type = slotsX[i].att("type");
            }
            else
            {
                // If not, set its type to "slot"; it's a card in the rows
                tSD.type = "slot";
            }

            // Various attributes are parsed into numerical values
            tSD.x   = float.Parse(slotsX[i].att("x"));
            tSD.y   = float.Parse(slotsX[i].att("y"));
            tSD.pos = new Vector3(tSD.x * multiplier.x, tSD.y * multiplier.y, 0);

            // Sorting Layers
            tSD.layerID   = int.Parse(slotsX[i].att("layer"));
            tSD.layerName = tSD.layerID.ToString();

            // pull additional attributes based on the type of each <slot>
            switch (tSD.type)
            {
            case "slot":
                // ignore slots that are just of the "slot" type
                break;

            case "drawpile":
                tSD.stagger.x = float.Parse(slotsX[i].att("xstagger"));
                drawPile      = tSD;
                break;

            case "redDiscardpile":
                redDiscardPile = tSD;
                break;

            case "greenDiscardpile":
                greenDiscardPile = tSD;
                break;

            case "whiteDiscardpile":
                whiteDiscardPile = tSD;
                break;

            case "blueDiscardpile":
                blueDiscardPile = tSD;
                break;

            case "yellowDiscardpile":
                yellowDiscardPile = tSD;
                break;

            case "redPlayer1":
                redPlayer1    = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                break;

            case "redPlayer2":
                redPlayer2    = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                tSD.rot       = float.Parse(slotsX[i].att("rot"));
                break;

            case "greenPlayer1":
                greenPlayer1  = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                break;

            case "greenPlayer2":
                greenPlayer2  = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                tSD.rot       = float.Parse(slotsX[i].att("rot"));
                break;

            case "whitePlayer1":
                whitePlayer1  = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                break;

            case "whitePlayer2":
                whitePlayer2  = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                tSD.rot       = float.Parse(slotsX[i].att("rot"));
                break;

            case "bluePlayer1":
                bluePlayer1   = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                break;

            case "bluePlayer2":
                bluePlayer2   = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                tSD.rot       = float.Parse(slotsX[i].att("rot"));
                break;

            case "yellowPlayer1":
                yellowPlayer1 = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                break;

            case "yellowPlayer2":
                yellowPlayer2 = tSD;
                tSD.stagger.y = float.Parse(slotsX[i].att("ystagger"));
                tSD.rot       = float.Parse(slotsX[i].att("rot"));
                break;

            case "target":
                target = tSD;
                break;

            case "hand":
                tSD.player = int.Parse(slotsX[i].att("player"));
                tSD.rot    = float.Parse(slotsX[i].att("rot"));
                slotDefs.Add(tSD);
                break;
            }
        }
    }