Beispiel #1
0
    // Этот вызов используется единажды, когда последняя карта закончила раздаваться
    public void CBCallback(CardBartok cb)
    {
        // Иногда нужно делать такие отчёты
        Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.CBCallback()", cb.name);

        StartGame();
    }
Beispiel #2
0
    public void DrawFirstTarget()
    {
        CardBartok tCB = MoveToTarget(Draw());

        // Говорим CardBartok сделать обратный вызов когда он закончит
        tCB.reportFinishTo = this.gameObject;
    }
Beispiel #3
0
    public void CardClicked(CardBartok tCB)
    {
        if (CURRENT_PLAYER.type != PlayerType.human)
        {
            return;                                          //we have sentience
        }
        if (phase == TurnPhase.waiting)
        {
            return;
        }

        switch (tCB.state)
        {
        case CBState.drawpile:
            //draw the top card
            CardBartok cb = CURRENT_PLAYER.AddCard(Draw());
            cb.callbackPlayer = CURRENT_PLAYER;
            phase             = TurnPhase.waiting;
            break;

        case CBState.hand:
            if (ValidPlay(tCB))
            {
                CURRENT_PLAYER.RemoveCard(tCB);
                MoveToTarget(tCB);
                tCB.callbackPlayer = CURRENT_PLAYER;
                phase = TurnPhase.waiting;
            }
            break;
        }
    }
Beispiel #4
0
    public void CBCallback(CardBartok tCB)
    {
        Utils.tr (Utils.RoundToPlaces (Time.time),
                  "Player.CBCallback()", tCB.name, "Player " + playerNum);

        Bartok.S.PassTurn ();
    }
Beispiel #5
0
    // Add a card to the hand
    public CardBartok AddCard(CardBartok eCB)
    {
        if (hand == null)
        {
            hand = new List <CardBartok>();
        }

        // Add the card to the hand
        hand.Add(eCB);
        // Sort the cards by rank using LINQ if this is a human
        if (type == PlayerType.human)
        {
            CardBartok[] cards = hand.ToArray();             // Copy hand to a new array

            // Below is the LINQ call that works on the array of CardBartoks.
            //  It is similar to doing a foreach(CardBartok cd in cards)
            //  and sorting them by rank. It then returns a sorted array
            cards = cards.OrderBy(cd => cd.rank).ToArray();

            // Convert the array CardBartok[] back to a List<CardBartok>
            hand = new List <CardBartok>(cards);
            // Note: LINQ operations can be a bit slow (like it could take a
            //  couple of milliseconds), but since we're only doing it once
            //  every turn, it isn't a problem.
        }

        eCB.SetSortingLayerName("10");         // This sorts the moving card to the top
        eCB.eventualSortLayer = handSlotDef.layerName;

        FanHand();

        return(eCB);
    }
Beispiel #6
0
    public void CardClicked(CardBartok tCB)
    {
        if (CURRENT_PLAYER.type != PlayerType.human)
            return;
        if (phase == TurnPhase.waiting)
            return;

        switch (tCB.state) {
        case CBState.drawpile:
            CardBartok cb = CURRENT_PLAYER.AddCard(Draw());
            cb.callbackPlayer = CURRENT_PLAYER;
            Utils.tr(Utils.RoundToPlaces(Time.time),"Bartok.CardClicked()","Draw",cb.name);
            phase = TurnPhase.waiting;
            break;
        case CBState.hand:
            if(ValidPlay(tCB)){
                CURRENT_PLAYER.RemoveCard(tCB);
                MoveToTarget(tCB);
                tCB.callbackPlayer = CURRENT_PLAYER;
                Utils.tr(Utils.RoundToPlaces(Time.time),"Bartok.CardClicked()","Play",tCB.name,targetCard.name + "is target");
                phase = TurnPhase.waiting;
            }else{
                Utils.tr(Utils.RoundToPlaces(Time.time),"Bartok.CardClicked()","Attempted to Play",tCB.name +" is target");
            }
            break;
        }
    }
Beispiel #7
0
    // The Draw function will pull a single card from the drawPile and return it
    public CardBartok Draw()
    {
        CardBartok cd = drawPile[0];     // Pull the 0th CardProspector

        drawPile.RemoveAt(0);            // Then remove it from List<> drawPile
        return(cd);                      // And return it
    }
Beispiel #8
0
    public List <CardBartok> hand; // The cards in this player's hand

    // Add a card to the hand
    public CardBartok AddCard(CardBartok eCB)
    {
        if (hand == null)
        {
            hand = new List <CardBartok>();
        }

        // Add the card to the hand
        hand.Add(eCB);

        // Sort the cards by rank using LINQ if this is a human
        if (type == PlayerType.human)
        {
            CardBartok[] cards = hand.ToArray(); // a

            // This is the LINQ call
            cards = cards.OrderBy(cd => cd.rank).ToArray(); // b

            hand = new List <CardBartok>(cards);            // c
            // Note: LINQ operations can be a bit slow (like it could take a couple of milliseconds), but since we're only doing it once every round, it isn't a problem.
        }

        eCB.SetSortingLayerName("10"); // Sorts the moving card to the top // a
        eCB.eventualSortLayer = handSlotDef.layerName;

        FanHand();
        return(eCB);
    }
Beispiel #9
0
    // This callback is used by the last card to be dealt at the beginning
    // It is only used once per game.
    public void CBCallback(CardBartok cb)
    {
        // You sometimes want to have reporting of method calls like this
        Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.CBCallback()", cb.name);

        StartGame(); // Start the Game
    }
Beispiel #10
0
    public void DrawFirstTarget()
    {
        //Flip up the first target card of the drawPile
        CardBartok tCB = MoveToTarget(Draw());

        tCB.reportFinishTo = this.gameObject;
    }
Beispiel #11
0
    //This pulls a single card from the draw pile and returns it
    public CardBartok Draw()
    {
        CardBartok cd = drawPile [0];

        drawPile.RemoveAt(0);
        return(cd);
    }
Beispiel #12
0
    // Add a card to the hand
    public CardBartok AddCard(CardBartok eCB)
    {
        if (hand == null)
        {
            hand = new List <CardBartok> ();
        }

        // Add the card to the hand
        hand.Add(eCB);

        // If the player is human, sort the cards by rank using LINQ
        if (type == PlayerType.human)
        {
            // Copy hand to new array
            CardBartok [] cards = hand.ToArray();

            // Below is the LINQ call that works on the array of CardBartoks
            // It's similar to doing a foreach (CardBartok cd in cards)
            // and sorting them by rank. It then returns a sorted array
            cards = cards.OrderBy(cd => cd.rank).ToArray();

            // Convert the array CardBartok [] back to a List<CardBartok>
            hand = new List <CardBartok> (cards);
        }

        // Sort the moving card to the top
        eCB.SetSortingLayerName("10");
        eCB.eventualSortLayer = handSlotDef.layerName;

        FanHand();
        return(eCB);
    }
Beispiel #13
0
    public CardBartok Draw()
    {
        CardBartok cd = drawPile[0];

        if (drawPile.Count == 0)
        {
            int ndx;
            while (discardPile.Count > 0)
            {
                ndx = Random.Range(0, discardPile.Count);
                drawPile.Add(discardPile[ndx]);
                discardPile.RemoveAt(ndx);
            }
            ArrangeDrawPile();
            float t = Time.time;
            foreach (CardBartok tCB in drawPile)
            {
                tCB.transform.localPosition = layout.discardPile.pos;
                tCB.callbackPlayer          = null;
                tCB.MoveTo(layout.drawPile.pos);
                tCB.timeStart         = t;
                t                    += 0.02f;
                tCB.state             = CBState.toDrawpile;
                tCB.eventualSortLayer = "0";
            }
        }

        drawPile.RemoveAt(0);
        return(cd);
    }
Beispiel #14
0
    public void CardClicked(CardBartok tCB)
    {
        // If it's not the human's turn, don't respond
        if (CURRENT_PLAYER.type != PlayerType.human) return;
        // If the game is waiting on a card to move, don't respond
        if (phase == TurnPhase.waiting) return;

        // Act differently based on whether it was a card in hand
        //  or on the drawPile that was clicked
        switch (tCB.state) {
        case CBState.drawpile:
            // Draw the top card, not necessarily the one clicked.
            CardBartok cb = CURRENT_PLAYER.AddCard( Draw() );
            cb.callbackPlayer = CURRENT_PLAYER;
            Utils.tr (Utils.RoundToPlaces(Time.time), "Bartok.CardClicked()","Draw",cb.name);
            phase = TurnPhase.waiting;
            break;
        case CBState.hand:
            // Check to see whether the card is valid
            if (ValidPlay(tCB)) {
                CURRENT_PLAYER.RemoveCard(tCB);
                MoveToTarget(tCB);
                tCB.callbackPlayer = CURRENT_PLAYER;
                Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.CardClicked()", "Play",tCB.name,targetCard.name+" is target");
                phase = TurnPhase.waiting;
            } else {
                // Just ignore it
                Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.CardClicked()", "Attempted to Play",tCB.name,targetCard.name+" is target");
            }
            break;

        }
    }
    //add a card to the hand
    public CardBartok AddCard(CardBartok eCB)
    {
        if (hand == null) hand = new List<CardBartok>();

        // add the card to the hand
        hand.Add (eCB);

        //sort the cards by rank using LINQ if this is a human
        if (type == PlayerType.human) {
            CardBartok[] cards = hand.ToArray (); //copy hand to a new array

            //below is the LINQ call that works on the array of CardBartoks.
            //it is similar to doing a foreach (CardBartok cd in cards)
            //and sorting them by rank. It then returns a sorted array
            cards = cards.OrderBy (cd => cd.rank).ToArray ();

            //covert the array CardBartok[] back to a List<CardBartok>
            hand = new List<CardBartok> (cards);
            //note: LINQ operations can be a bit slow (like it could take a
            //couple of milliseconds), but since we're only doing it once
            //every turn, it isn't a problem
        }

        eCB.SetSortingLayerName ("10"); //this sorts the moving card to the top
        eCB.eventualSortLayer = handSlotDef.layerName;

        FanHand ();
        return(eCB);
    }
Beispiel #16
0
    public void CBCallback(CardBartok tCB)
    {
        Utils.tr("Player.CBCallback()", tCB.name, "Player " + playerNum);

        // The card is done moving, so pass the turn
        Bartok.S.PassTurn();
    }
Beispiel #17
0
 public void CBCallback(CardBartok tCB)
 {
     Utils.tr (Utils.RoundToPlaces(Time.time),
               "Player.CBCallback()",tCB.name,"Player "+playerNum);
     // The card is done moving, so pass the turn
     Bartok.S.PassTurn();
 }
Beispiel #18
0
    public void CardClicked(CardBartok tCB)
    {
        if (CURRENT_PLAYER.type != PlayerType.human)
        {
            return;
        }
        if (phase == TurnPhase.waiting)
        {
            return;
        }
        switch (tCB.state)
        {
        case CBState.drawpile:
            CardBartok cb = CURRENT_PLAYER.AddCard(Draw());
            cb.callbackPlayer = CURRENT_PLAYER;
            Utils.tr("Bartok:CardClicked()", "Draw", cb.name);
            phase = TurnPhase.waiting;
            break;

        case CBState.hand:
            if (ValidPlay(tCB))
            {
                CURRENT_PLAYER.RemoveCard(tCB);
                MoveToTarget(tCB);
                tCB.callbackPlayer = CURRENT_PLAYER;
                Utils.tr("Bartok:CardClicked()", "Play", tCB.name, targetCard.name + " is target");
                phase = TurnPhase.waiting;
            }
            else
            {
                Utils.tr("Bartok:CardClicked()", "Attempted to Play", tCB.name, targetCard.name + " is target");
            }
            break;
        }
    }
Beispiel #19
0
	// Remove a card from the hand
	public CardBartok RemoveCard(CardBartok cb)
	{
		hand.Remove(cb);
		FanHand();

		return (cb);
	}
Beispiel #20
0
    // The Draw function will pull a single card from the drawPile and return it
    public CardBartok Draw()
    {
        CardBartok cd = drawPile[0]; // Pull the 0th CardBartok

        if (drawPile.Count == 0)
        {
            // If the drawPile is now empty
            // We need to shuffle the discards into the drawPile
            int ndx;
            while (discardPile.Count > 0)
            {
                // Pull a random card from the discard pile
                ndx = Random.Range(0, discardPile.Count);
                drawPile.Add(discardPile[ndx]);
                discardPile.RemoveAt(ndx);
            }
            ArrangeDrawPile();
            // Show the cards moving to the drawPile
            float t = Time.time;
            foreach (CardBartok tCB in drawPile)
            {
                tCB.transform.localPosition = layout.discardPile.pos;
                tCB.callbackPlayer          = null;
                tCB.MoveTo(layout.drawPile.pos);
                tCB.timeStart         = t;
                t                    += 0.02f;
                tCB.state             = CBState.toDrawpile;
                tCB.eventualSortLayer = "0";
            }
        }

        drawPile.RemoveAt(0); // Then remove it from List<> drawPile
        return(cd);           // And return it
    }
Beispiel #21
0
    // Remove a card from the hand
    public CardBartok RemoveCard(CardBartok cb)
    {
        hand.Remove(cb);
        FanHand();

        return(cb);
    }
    public void DrawFirstTarget()
    {
        // Flip up the first target card from the drawPile
        CardBartok tCB = MoveToTarget(Draw());

        // Set the CardBartok to call CBCallback on this Bartok when it is done
        tCB.reportFinishTo = this.gameObject; // b
    }
    public void CBCallback(CardBartok tCB)
    {
        CardBartok cb;

        Utils.tr(Utils.RoundToPlaces(Time.time), "Player.CBCallback()", tCB.name, "Player " + playerNum);
        cb = this.AddCard(Bartok.S.Draw());
        cb.callbackPlayer = this;
    }
Beispiel #24
0
    public void DrawFirstTarget()
    {
        // Перевернуть первую целевую карту лицевой стороной вверх
        CardBartok tCB = MoveToTarget(Draw());

        // Вызвать метод CBCallback сценария Bartok, когда карта закончит перемещение
        tCB.reportFinishTo = this.gameObject;
    }
Beispiel #25
0
    public void DrawFirstTarget()
    {
        //flip up the first target card from the draw pile
        CardBartok tCB = MoveToTarget(Draw());

        //set the cardbartok to call cbcallback on this bartok when it is done
        tCB.reportFinishTo = this.gameObject;
    }
Beispiel #26
0
    public bool ValidPlay(CardBartok cb)
    {
        if(cb.rank == targetCard.rank) return (true);

        if(cb.suit == targetCard.suit){
            return (true);
        }
        return (false);
    }
 public CardBartok MoveToDiscard(CardBartok tCB)
 {
     tCB.state = CBState.discard;
     discardPile.Add(tCB);
     tCB.SetSortingLayerName(layout.discardPile.layerName);
     tCB.SetSortOrder(discardPile.Count * 4);
     tCB.transform.localPosition = layout.discardPile.pos + Vector3.back / 2;
     return(tCB);
 }
Beispiel #28
0
 public CardBartok RemoveCard(CardBartok cb)
 {
     if (hand == null || !hand.Contains(cb))
     {
         return(null);
     }
     hand.Remove(cb);
     return(cb);
 }
Beispiel #29
0
    public void CBCallback(CardBartok cb)
    {
                                                                                       // c
                                                                                       // You sometimes want to have reporting of method calls like this
                Utils.tr("Bartok:CBCallback()", cb.name);                              // d

                StartGame();                                                           // Start the Game

            
    }
Beispiel #30
0
    public CardBartok AddCard(CardBartok eCB)
    {
        if (hand == null)
        {
            hand = new List <CardBartok>();
        }

        hand.Add(eCB);
        return(eCB);
    }
Beispiel #31
0
                          // Remove a card from the hand
                          public CardBartok RemoveCard(CardBartok cb)
                      {
                                  // If hand is null or doesn't contain cb, return null
                                  if(hand == null || !hand.Contains(cb)) return(null);

                                  hand.Remove(cb);
                          FanHand();
                                  return(cb);
                              
                      }
Beispiel #32
0
    // The Draw function will pull a single card from the drawPile return it
    public CardBartok Draw()
    {
        // Pull the top card from the drawPile
        CardBartok cd = drawPile [0];

        // Remove it from the List<> drawPile
        drawPile.RemoveAt(0);
        // Return the card
        return(cd);
    }
Beispiel #33
0
 // Remove a card from the hand
 public CardBartok RemoveCard(CardBartok cb)
 {
     // If hand is null or doesn't contain cb, return null
     if (hand == null || !hand.Contains(cb))
     {
         return(null);
     }
     hand.Remove(cb);
     FanHand();
     return(cb);
 }
Beispiel #34
0
 // Удаляет карту из рук
 public CardBartok RemoveCard(CardBartok cb)
 {
     // Если список hand пуст или не содержит карты cb, вернуть null
     if (hand == null || !hand.Contains(cb))
     {
         return(null);
     }
     hand.Remove(cb);
     FanHand();
     return(cb);
 }
Beispiel #35
0
    // The Draw function will pull a single card from the drawPile and return it
    public CardBartok Draw()
    {
        if (drawPile.Count == 0)
        {
            GameFail();
        }

        CardBartok cd = drawPile[0];             // Pull the 0th CardProspector

        drawPile.RemoveAt(0);                    // Then remove it from List<> drawPile
        return(cd);                              // And return it
    }
Beispiel #36
0
    // Add a card to the hand
    public CardBartok AddCard(CardBartok eCB)
    {
        if (hand == null)
        {
            hand = new List <CardBartok>();
        }

        // Add the card to the hand
        hand.Add(eCB);

        return(eCB);
    }
Beispiel #37
0
    public CardBartok AddCard(CardBartok eCB)
    {
        if (hand == null)
            hand = new List<CardBartok> ();
        hand.Add (eCB);

        if (type == PlayerType.human) {
            CardBartok[] cards = hand.ToArray();
            cards = cards.OrderBy(cd => cd.rank).ToArray();
            hand = new List<CardBartok>(cards);
        }

        eCB.SetSortingLayerName ("10");
        eCB.eventualSortLayer = handSlotDef.layerName;

        FanHand ();
        return eCB;
    }
Beispiel #38
0
    public CardBartok MoveToTarget(CardBartok tCB)
    {
        tCB.timeStart = 0;
        tCB.MoveTo (layout.discardPile.pos + Vector3.back);
        tCB.state = CBState.toTarget;
        tCB.faceUp = true;

        tCB.SetSortingLayerName ("10");
        tCB.eventualSortLayer = layout.target.layerName;
        if (targetCard != null) {
            MoveToDiscard(targetCard);
        }

        targetCard = tCB;
        return tCB;
    }
Beispiel #39
0
    // This callback is used by the last card to be dealt at the beginning
    // It is only used once per game.
    public void CBCallback(CardBartok cb)
    {
        // You sometimes want to have reporting of method calls like this   // 1
        Utils.tr(Utils.RoundToPlaces(Time.time),"Bartok.CBCallback()",cb.name);

        StartGame(); // Start the Game
    }
Beispiel #40
0
    // ValidPlay verifies that the card chosen can be played on the discard pile
    public bool ValidPlay(CardBartok cb)
    {
        // It's a valid play if the rank is the same
        if (cb.rank == targetCard.rank) return(true);

        // It's a valid play if the suit is the same
        if (cb.suit == targetCard.suit) {
            return(true);
        }

        // Otherwise, return false
        return(false);
    }
Beispiel #41
0
    public CardBartok MoveToDiscard(CardBartok tCB)
    {
        tCB.state = CBState.discard;
        discardPile.Add (tCB);
        tCB.SetSortingLayerName (layout.discardPile.layerName);
        tCB.SetSortOrder (discardPile.Count * 4);
        tCB.transform.localPosition = layout.discardPile.pos + Vector3.back / 2;

        return tCB;
    }
Beispiel #42
0
    public void CBCallback(CardBartok cb)
    {
        Utils.tr (Utils.RoundToPlaces (Time.time), "Bartok.CBCallback()", cb.name);

        StartGame ();
    }
Beispiel #43
0
 public bool ValidPlay(CardBartok cb)
 {
     if (cb.rank == targetCard.rank)
         return true;
     if (cb.suit == targetCard.suit) {
         return true;
     }
     return false;
 }