// Этот вызов используется единажды, когда последняя карта закончила раздаваться public void CBCallback(CardBartok cb) { // Иногда нужно делать такие отчёты Utils.tr(Utils.RoundToPlaces(Time.time), "Bartok.CBCallback()", cb.name); StartGame(); }
public void DrawFirstTarget() { CardBartok tCB = MoveToTarget(Draw()); // Говорим CardBartok сделать обратный вызов когда он закончит tCB.reportFinishTo = this.gameObject; }
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; } }
public void CBCallback(CardBartok tCB) { Utils.tr (Utils.RoundToPlaces (Time.time), "Player.CBCallback()", tCB.name, "Player " + playerNum); Bartok.S.PassTurn (); }
// 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); }
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; } }
// 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 }
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); }
// 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 }
public void DrawFirstTarget() { //Flip up the first target card of the drawPile CardBartok tCB = MoveToTarget(Draw()); tCB.reportFinishTo = this.gameObject; }
//This pulls a single card from the draw pile and returns it public CardBartok Draw() { CardBartok cd = drawPile [0]; drawPile.RemoveAt(0); return(cd); }
// 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); }
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); }
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); }
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(); }
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(); }
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; } }
// Remove a card from the hand public CardBartok RemoveCard(CardBartok cb) { hand.Remove(cb); FanHand(); return (cb); }
// 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 }
// 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; }
public void DrawFirstTarget() { // Перевернуть первую целевую карту лицевой стороной вверх CardBartok tCB = MoveToTarget(Draw()); // Вызвать метод CBCallback сценария Bartok, когда карта закончит перемещение tCB.reportFinishTo = this.gameObject; }
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; }
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); }
public CardBartok RemoveCard(CardBartok cb) { if (hand == null || !hand.Contains(cb)) { return(null); } hand.Remove(cb); return(cb); }
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 }
public CardBartok AddCard(CardBartok eCB) { if (hand == null) { hand = new List <CardBartok>(); } hand.Add(eCB); return(eCB); }
// 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); }
// 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); }
// 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); }
// Удаляет карту из рук public CardBartok RemoveCard(CardBartok cb) { // Если список hand пуст или не содержит карты cb, вернуть null if (hand == null || !hand.Contains(cb)) { return(null); } hand.Remove(cb); FanHand(); return(cb); }
// 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 }
// 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); }
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; }
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; }
// 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 }
// 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); }
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; }
public void CBCallback(CardBartok cb) { Utils.tr (Utils.RoundToPlaces (Time.time), "Bartok.CBCallback()", cb.name); StartGame (); }
public bool ValidPlay(CardBartok cb) { if (cb.rank == targetCard.rank) return true; if (cb.suit == targetCard.suit) { return true; } return false; }