Esempio n. 1
0
File: Loot.cs Progetto: etomsky/Loot
    public void PassTurn(int num = -1)
    {
        // If no number was passed in, pick the next player
        if (num == -1)
        {
            int ndx = players.IndexOf(CURRENT_PLAYER);
            num = (ndx + 1) % 4;
        }
        int lastPlayerNum = -1;

        if (CURRENT_PLAYER != null)
        {
            lastPlayerNum = CURRENT_PLAYER.playerNum;
            // Check for Game Over and need to reshuffle discards
            if (CheckGameOver())
            {
                return;
            }
        }
        CURRENT_PLAYER = players[num];
        phase          = TurnPhase.pre;

        CURRENT_PLAYER.TakeTurn();

        // Report the turn passing
        Utils.tr("Loot:PassTurn()", "Old: " + lastPlayerNum, "New: " + CURRENT_PLAYER.playerNum);
    }
Esempio n. 2
0
File: Loot.cs Progetto: etomsky/Loot
    //Perform the initial game layout
    void LayoutGame()
    {
        // Create an empty GameObject to serve as the tableau's anchor
        if (layoutAnchor == null)
        {
            GameObject tGO = new GameObject("_LayoutAnchor");
            layoutAnchor = tGO.transform;
            layoutAnchor.transform.position = layoutCenter;
        }

        // Position the drawPile cards
        ArrangeDrawPile();



        // Set up the players
        LootPlayer pl;

        players = new List <LootPlayer>();
        foreach (SlotDef tSD in layout.slotDefs)
        {
            pl             = new LootPlayer();
            pl.handSlotDef = tSD;
            players.Add(pl);
            pl.playerNum = tSD.player;
        }
        players[0].type = PlayerType.human; // Make only the 0th player human

        CardLoot tCL;

        // Deal six cards to each player
        for (int i = 0; i < numStartingCards; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                tCL = Draw(); // Draw a card
                // Stagger the draw time a bit.
                tCL.timeStart = Time.time + drawTimeStagger * (i * 4 + j);

                players[(j + 1) % 4].AddCard(tCL);
            }
        }

        Invoke("DrawFirstTarget", drawTimeStagger * (numStartingCards * 4 + 4));
    }
Esempio n. 3
0
    private void Update()
    {
        if (Loot.S.phase != TurnPhase.gameOver)
        {
            txt.text = "";
            return;
        }
        // We only get here if the game is over
        LootPlayer cP = Loot.CURRENT_PLAYER;

        if (cP == null || cP.type == PlayerType.human)
        {
            txt.text = "";
        }
        else
        {
            txt.text = "Player " + (cP.playerNum) + " won";
        }
    }
Esempio n. 4
0
    private void Update()
    {
        switch (state)
        {
        case CLState.toHand:
        case CLState.toTarget:
        case CLState.toDrawpile:
        case CLState.toPirate:
        case CLState.toMerchant:
        case CLState.to:
            float u  = (Time.time - timeStart) / timeDuration;
            float uC = Easing.Ease(u, MOVE_EASING);

            if (u < 0)
            {
                transform.localPosition = bezierPts[0];
                transform.rotation      = bezierRots[0];
                return;
            }
            else if (u >= 1)
            {
                uC = 1;
                // Move from the to... state to the proper next state
                if (state == CLState.toHand)
                {
                    state = CLState.hand;
                }
                if (state == CLState.toTarget)
                {
                    state = CLState.target;
                }
                if (state == CLState.toDrawpile)
                {
                    state = CLState.drawpile;
                }
                if (state == CLState.toPirate)
                {
                    state = CLState.pirate;
                }
                if (state == CLState.toMerchant)
                {
                    state = CLState.merchant;
                }
                if (state == CLState.to)
                {
                    state = CLState.idle;
                }

                // Move to the final position
                transform.localPosition = bezierPts[bezierPts.Count - 1];
                transform.rotation      = bezierRots[bezierPts.Count - 1];

                // Reset timeStart to 0 so it gets overwritten next time
                timeStart = 0;

                if (reportFinishTo != null)
                {
                    reportFinishTo.SendMessage("CLCallback", this);
                    reportFinishTo = null;
                }
                else if (callbackPlayer != null)
                {
                    // If there's a callback Player
                    // Call CLCallback directly on the Player
                    callbackPlayer.CLCallback(this);
                    callbackPlayer = null;
                }
                else
                {
                    // If there is nothing to callback
                    // Just let it stay still.
                }
            }
            else
            {
                // Normal interpolation behavior (0 <= u < 1)
                Vector3 pos = Utils.Bezier(uC, bezierPts);
                transform.localPosition = pos;
                Quaternion rotQ = Utils.Bezier(uC, bezierRots);
                transform.rotation = rotQ;

                if (u > 0.5f)
                {
                    SpriteRenderer sRend = spriteRenderers[0];
                    if (sRend.sortingOrder != eventualSortOrder)
                    {
                        // Jump to the proper sort order
                        SetSortOrder(eventualSortOrder);
                    }
                    if (sRend.sortingLayerName != eventualSortLayer)
                    {
                        // Jump to the proper sort layer
                        SetSortingLayerName(eventualSortLayer);
                    }
                }
            }
            break;
        }
    }
Esempio n. 5
0
File: Loot.cs Progetto: etomsky/Loot
 public void RestartGame()
 {
     CURRENT_PLAYER = null;
     SceneManager.LoadScene("__Loot_Scene_0");
 }