void AddCard(PlayableCard card) { cards.Add(card); card.transform.parent = this.transform; card.gameObject.GetComponent <CardDragger>().inHand = true; OrganizeCards(); }
void HandleSpellMouseUp() { if (effect.targeted) { PlayableCard card = CheckValidSpellTarget(); if (card != null) { //Handle Spell casting on that target Debug.Log("CASTING TARGETED SPELL"); CastSpellFromHand(card); } else { transform.position = originalPos; targetPosition = transform.position; } } else { if (transform.localPosition.z < 5.0f) { transform.position = originalPos; targetPosition = transform.position; } else { //Handle spell casting no target Debug.Log("CASTING UNTARGETED SPELL"); CastSpellFromHand(null); } } }
public void OpponentDrewCard() { GameObject cardBack = Instantiate(CardBackPrefab); PlayableCard card = cardBack.GetComponent <PlayableCard>(); opponentHandOrganizer.AttemptToAddCard(card); }
void ProcessClickForCardAction(Player player, Game game) { // if the game is not in the right phase log error and return if (game.GamePhase != GamePhase.LOGISTICS_PLANNING) { ServerLogError("Received a click for card message in the wrong game phase Player=" + player.Name); return; } // does the player have a click remaining if (player.Clicks < 1) { ServerLogError("Received a click for card message from a player with no clicks remaining Player=" + player.Name); return; } // spend the click ChangeClicks(player, -1); // draw card for player PlayableCard card = player.Deck.Draw(); player.Hand.Add(card); // send it to the client var cardMsg = new MessageTypes.DrawnCardMessage(); cardMsg.CardCodename = card.CardCodename.ToString(); cardMsg.cardId = card.CardId; NetworkServer.SendToClient(player.ConnectionId, (short)MessageTypes.MessageType.DRAWN_CARD, cardMsg); ServerLog(string.Format("{0} clicks for a card", player.Name), game); // send the action to the opponent for their game log //SendGameLogToPlayer(game.GetOpponent(player), string.Format("{0} clicks to draw", player.Name)); }
public bool DrawCard() { if (deckManager.playableDeck.Count > 0) { Card cardTemplate = deckManager.playableDeck[0]; GameObject cardObj; if (cardTemplate.cardType == CardInfo.CardType.Minion) { cardObj = Instantiate(PlayableMinionPrefab); } else { cardObj = Instantiate(PlayableSpellPrefab); } PlayableCard playableCard = cardObj.GetComponent <PlayableCard>(); //int id = (NakamaSessionManager.Instance.GetNextNetworkID()).Result; //Debug.Log("assigning card the id: " + id); //playableCard.networkID = id; playableCard.baseCard = cardTemplate; playableCard.SetToBaseCard(); cardObj.GetComponent <CardDragger>().playHandler = this; cardObj.GetComponent <CardDragger>().owned = true; cardObj.GetComponent <CardDragger>().inHand = true; myHandOrganizer.AttemptToAddCard(playableCard); deckManager.playableDeck.RemoveAt(0); MatchMessageEndTurn none = new MatchMessageEndTurn("", 0); MatchCommunicationManager.Instance.SendMatchStateMessage(MatchMessageType.CardDrawn, none); } return(false); }
public void HandleIncomingCombat(int theirID, int myID) { PlayableCard myCard = null; PlayableMinion theirCard = null; foreach (PlayableCard c in myPlayingFieldOrganizer.cards) { if (c.networkID == myID) { myCard = (PlayableMinion)c; continue; } } foreach (PlayableCard c in opponentFieldOrganizer.cards) { if (c.networkID == theirID) { theirCard = (PlayableMinion)c; continue; } } foreach (PlayableCard c in heroCards) { if (c.networkID == myID) { myCard = c; continue; } } if (myCard != null && theirCard != null) { myCard.RecieveAttack(theirCard); theirCard.RecieveAttack(myCard); } }
public void AddCard(PlayableCard card, int absPos) { Debug.Log("Attempting to add card to opponents board."); GameManager.instance.currentNextID++; card.gameObject.transform.parent = transform; cards.Insert(absPos, card); OrganizeCards(); }
public void ChangeCardDetails(PlayableCard newDetails) { if (newDetails != null) { rankSR.sprite = ChooseRankSprite(newDetails.rank); rankSR.color = ChooseRankColor(newDetails.suit); suitSR.sprite = iconSR.sprite = ChooseSuitSprite(newDetails.suit); } }
public override void RecieveAttack(PlayableCard other) { //DUMB CODE REPLACE ASAP if (other.networkID < 0) { return; } ChangeHealth(((PlayableMinion)other).attack); }
public override void Trigger(Card caster, PlayableCard target, bool broadcast = true, int modifier = 0) { target.ChangeHealth(amount + modifier); if (broadcast) { MatchMessageSpellCast cast = new MatchMessageSpellCast(caster.cardID, true, target.networkID, modifier); MatchCommunicationManager.Instance.SendMatchStateMessage(MatchMessageType.SpellActivated, cast); } }
internal void SetCard(PlayableCard card, int index) { if (index >= cardDeck.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } cardDeck[index] = card ?? throw new ArgumentNullException(nameof(card)); card.Player = this; CardDeckChanged?.Invoke(); }
public bool AttemptToAddCard(PlayableCard card) { if (cards.Count >= 10) { return(false); } else { AddCard(card); return(true); } }
public bool AttemptToAddCard(PlayableCard card, Vector3 pos) { if (cards.Count >= 7) { return(false); } else { AddCard(card, pos); return(true); } }
void BeginAttack(PlayableCard card) { //LOTS OF PLACEHOLDER CODE HERE SetToReady(false); PlayableMinion me = GetComponent <PlayableMinion>(); card.RecieveAttack(me); me.RecieveAttack(card); MatchMessageHandleCombat combat = new MatchMessageHandleCombat(me.networkID, card.networkID); MatchCommunicationManager.Instance.SendMatchStateMessage(MatchMessageType.UnitAttacked, combat); }
// Handle SMSG_SELECT_CARDS packet private static void HandleSelectCards(Packet packet, ClientGame game) { game.MainWindow.SlideShow.SetVisible(false); game.ShowCardDeck(true); var count1 = packet.ReadByte(); var count2 = packet.ReadByte(); var guids1 = new PacketGuid[count1]; var guids2 = new PacketGuid[count2]; for (var i = 0; i < count2; i++) { guids2[i] = new PacketGuid(); packet.ReadGuidBitStreamInOrder(guids2[i], 1, 2, 7, 0, 5, 3, 4, 6); } for (var i = 0; i < count1; i++) { guids1[i] = new PacketGuid(); packet.ReadGuidBitStreamInOrder(guids1[i], 7, 1, 2, 4, 6, 0, 3, 5); } var senderId = packet.ReadUInt32(); var player1 = (game.Player.Id == senderId) ? game.Player : game.Opponent; var player2 = (game.Player.Id == senderId) ? game.Opponent : game.Player; var cards1 = new PlayableCard[count1]; var cards2 = new PlayableCard[count2]; for (var i = 0; i < count1; i++) { packet.ReadGuidByteStreamInOrder(guids1[i], 7, 2, 0, 1, 6, 4, 5); var id = packet.ReadUInt32(); packet.ReadGuidByteStreamInOrder(guids1[i], 3); cards1[i] = PlayableCard.Create(guids1[i], DataHolder.GetCard(id)); } for (var i = 0; i < count2; i++) { packet.ReadGuidByteStreamInOrder(guids2[i], 4, 2, 6, 1, 7, 0); var id = packet.ReadUInt32(); packet.ReadGuidByteStreamInOrder(guids2[i], 3, 5); cards2[i] = PlayableCard.Create(guids2[i], DataHolder.GetCard(id)); } player1.AddCards(cards1); player2.AddCards(cards2); game.UnloadData(); game.Chat.Write("Game has started", ChatTypes.Info); }
public PlayableCard Draw() { if (_cards.Count < 1) { Debug.Log("Tried to draw card from an empty deck"); return(null); } PlayableCard c = _cards[0]; _cards.RemoveAt(0); return(c); }
private void CreateCardForDeck(PlayableCard playableCard) { var newCard = Instantiate(cardPrefab); newCard.GetComponent <Card>().SetCardDetails(playableCard); newCard.gameObject.name = playableCard.ToString(); newCard.transform.SetParent(gameDeck.GetComponent <RectTransform>(), false); // non mi serve sia figlia delle rect transform degli slot newCard.transform.SetAsFirstSibling(); newCard.GetComponent <RectTransform>().position = spawnPoint.position; gameDeck.AddCardToStock(newCard); }
public void AddCardToHand(PlayableCard card, bool replacesUnknown) { // instantiate the card prefab Transform cardPrefab = InstantiateCardPrefab(card, true); // add it to the players hand area cardPrefab.SetParent(PlayerHandGUI); if (replacesUnknown) { // remove the placeholder face down card Destroy(_cardPlaceholders.Dequeue().gameObject); } }
void PlayCardFromHand() { inHand = false; PlayableCard card = GetComponent <PlayableCard>(); playHandler.myHandOrganizer.RemoveCard(card); transform.SetParent(playHandler.myPlayingFieldOrganizer.gameObject.transform); playHandler.myPlayingFieldOrganizer.AttemptToAddCard(card, transform.position); card.cardName.GetComponent <SkewTextExample>().RestartSkew(); GameManager.instance.playHandler.SpendMana(card.manacost); SetToReady(false); card.OnCardPlayed(); //TODO: Network in removing cards from my hand on other side }
public void AddCardToHand(PlayableCard card, bool replacesUnknown) { // instantiate the card prefab Transform cardPrefab = InstantiateCardPrefab(card, true); // add it to the players hand area cardPrefab.SetParent(PlayerHandGUI); if (replacesUnknown) { // remove the placeholder face down card Destroy(_cardPlaceholders.Dequeue().gameObject); } }
public Deck(string dataStr) { string[] data = dataStr.Split('#'); Faction = new Faction(data[0]); _cards = new List <PlayableCard>(); string[] cardData = data[1].Split('|'); int numCards = int.Parse(cardData[0]); for (int i = 0; i < numCards; i++) { PlayableCard card = (PlayableCard)CardFactory.CreateCard((CardCodename)Enum.Parse(typeof(CardCodename), cardData[1 + (i * 2)]), cardData[2 + (i * 2)]); _cards.Add(card); } }
PlayableCard CheckValidSpellTarget() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { PlayableCard card = hit.transform.gameObject.GetComponent <PlayableCard>(); if (card != null) { return(card); } } return(null); }
// Handle SMSG_SELECT_CARDS packet private static void HandleSelectCards(Packet packet, Game game) { game.IsGameWaiting = false; var count1 = packet.ReadByte(); var count2 = packet.ReadByte(); var guids1 = new PacketGuid[count1]; var guids2 = new PacketGuid[count2]; for (var i = 0; i < count2; i++) { guids2[i] = new PacketGuid(); packet.ReadGuidBitStreamInOrder(guids2[i], 1, 2, 7, 0, 5, 3, 4, 6); } for (var i = 0; i < count1; i++) { guids1[i] = new PacketGuid(); packet.ReadGuidBitStreamInOrder(guids1[i], 7, 1, 2, 4, 6, 0, 3, 5); } var senderId = packet.ReadUInt32(); var player1 = (game.Player.Id == senderId) ? game.Player : game.Opponent; var player2 = (game.Player.Id == senderId) ? game.Opponent : game.Player; var cards1 = new PlayableCard[count1]; var cards2 = new PlayableCard[count2]; for (var i = 0; i < count1; i++) { packet.ReadGuidByteStreamInOrder(guids1[i], 7, 2, 0, 1, 6, 4, 5); var id = packet.ReadUInt32(); packet.ReadGuidByteStreamInOrder(guids1[i], 3); cards1[i] = PlayableCard.Create(guids1[i], game.DataHolder.GetCard(id), player1); } for (var i = 0; i < count2; i++) { packet.ReadGuidByteStreamInOrder(guids2[i], 4, 2, 6, 1, 7, 0); var id = packet.ReadUInt32(); packet.ReadGuidByteStreamInOrder(guids2[i], 3, 5); cards2[i] = PlayableCard.Create(guids2[i], game.DataHolder.GetCard(id), player2); } player1.SetCards(cards1); player2.SetCards(cards2); }
void CheckValidTarget() { if (!inHand && dragable && owned) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { PlayableCard card = hit.transform.gameObject.GetComponent <PlayableCard>(); if (card != null) { BeginAttack(card); } } } }
public void OpponentCastSpell(int cardID, bool targeted, int targetID = -10, int modifier = 0) { //PlayableCard caster = GameManager.instance.card if (targeted) { PlayableCard target = FindTargetByID(targetID); if (target != null) { GameManager.instance.cardDatabase[cardID].battlecries[0].Trigger(GameManager.instance.cardDatabase[cardID], target, false, modifier); } } else { GameManager.instance.cardDatabase[cardID].battlecries[0].Trigger(GameManager.instance.cardDatabase[cardID], false, modifier); } }
void ProcessHostShipAction(Player player, Player opponent, Game game, string shipId, string shipyardId, CardCodename cardCodename) { // find card and shipyard by their id PlayableCard card = FindCardIn(shipId, player.Hand);//player.Hand.Find(x => x.CardId == cardId); Ship ship = (Ship)card; // TODO - error if card not in hand - at the moment we just trust that it is // TODO - error if cardCodename is not the same - need to verify this as we pass to opponent on trust otherwise Shipyard shipyard = FindCardIn(shipyardId, player.Shipyards);//player.Shipyards.Find(x => x.ShipyardId == shipyardId); // TODO - error if shipyard not found ServerLog(string.Format("Trying to host {0}({1}) on {2}({3}) for {4}", ship.CardName, ship.CardId, shipyard.CardName, shipyard.CardId, player.Name), game); if (TryHost(game, player, ship, shipyard) == false) { ServerLogError(string.Format("Failed trying to host {0}({1}) on {2}({3}) for {4}", ship.CardName, ship.CardId, shipyard.CardName, shipyard.CardId, player.Name), game); } }
void CastSpellFromHand(PlayableCard target) { Card me = GetComponent <PlayableCard>().baseCard; if (target != null) { effect.Trigger(me, target); } else { effect.Trigger(me); } PlayableCard card = GetComponent <PlayableCard>(); playHandler.myHandOrganizer.RemoveCard(card); //TODO: Network in removing cards from my hand on other side Destroy(this.gameObject); }
void AddCard(PlayableCard card, Vector3 pos) { //int cardNetID = card.networkID; int cardNetID = GameManager.instance.currentNextID; card.networkID = cardNetID; GameManager.instance.currentNextID++; int absPos = 0; MatchMessageCardPlayed cardPlayed; if (cards.Count == 0) { cards.Add(card); OrganizeCards(); cardPlayed = new MatchMessageCardPlayed(card.baseCard.cardID, (int)card.baseCard.cardType, absPos, cardNetID); MatchCommunicationManager.Instance.SendMatchStateMessage(MatchMessageType.CardPlayed, cardPlayed); return; } if (pos.x < cards[0].transform.position.x) { cards.Insert(0, card); OrganizeCards(); cardPlayed = new MatchMessageCardPlayed(card.baseCard.cardID, (int)card.baseCard.cardType, absPos, cardNetID); MatchCommunicationManager.Instance.SendMatchStateMessage(MatchMessageType.CardPlayed, cardPlayed); return; } for (int a = 0; a < cards.Count - 1; a++) { if (pos.x > cards[a].transform.position.x && pos.x < cards[a + 1].transform.position.x) { cards.Insert(a + 1, card); OrganizeCards(); absPos = a + 1; cardPlayed = new MatchMessageCardPlayed(card.baseCard.cardID, (int)card.baseCard.cardType, absPos, cardNetID); MatchCommunicationManager.Instance.SendMatchStateMessage(MatchMessageType.CardPlayed, cardPlayed); return; } } cards.Add(card); absPos = cards.Count - 1; cardPlayed = new MatchMessageCardPlayed(card.baseCard.cardID, (int)card.baseCard.cardType, absPos, cardNetID); MatchCommunicationManager.Instance.SendMatchStateMessage(MatchMessageType.CardPlayed, cardPlayed); OrganizeCards(); }
private void OnDrawnCardMessage(NetworkMessage netMsg) { var msg = netMsg.ReadMessage <MessageTypes.DrawnCardMessage>(); var cardCodenameData = msg.CardCodename; string cardId = msg.cardId; Debug.Log(String.Format("Card drawn: {0}({1})", cardCodenameData, cardId)); // add to local version of game state CardCodename cardCodename = (CardCodename)Enum.Parse(typeof(CardCodename), cardCodenameData); PlayableCard card = (PlayableCard)CardFactory.CreateCard(cardCodename, cardId); _game.Player.Hand.Add(card); GameViewController.AddCardToHand(card, true); // update player state gui UpdatePlayerStateGUI(); }
public IEnumerator CreateCardForPile(Pile pile, PlayableCard cardToAdd, bool lastCardOfPile) { var newCard = Instantiate(cardPrefab); yield return(new WaitForSeconds(.1f)); newCard.GetComponent <Card>().SetCardDetails(cardToAdd); newCard.gameObject.name = cardToAdd.ToString(); newCard.transform.SetParent(pile.AppendSlot.GetComponent <RectTransform>(), false); newCard.GetComponent <RectTransform>().position = spawnPoint.position; Coroutine travelCoroutine = StartCoroutine(newCard.GetComponent <Card>().TravelTo(pile.SpotPosition)); if (lastCardOfPile) { //yield return travelCoroutine; StartCoroutine(newCard.GetComponent <Card>().Flip()); } pile.AddCardToPile(newCard, lastCardOfPile); }
public override IEnumerator OnDie(bool wasSacrifice, PlayableCard killer) { var playerGraveyard = CustomGameManager.encounterGraveyard.Where(card => card.OpponentCard).Select(card => card.Info.defaultEvolutionName).ToList(); var smallBirdDied = playerGraveyard.Contains(Constants.SMALL_BIRD_ID) || playerGraveyard.Contains(Constants.SMALL_BIRD_2_ID) || playerGraveyard.Contains(Constants.SMALL_BIRD_3_ID); if (smallBirdDied && playerGraveyard.Contains(Constants.BIG_BIRD_ID) && playerGraveyard.Contains(Constants.JUDGEMENT_BIRD_ID)) { Plugin.logger.LogDebug($"Summoning Apocalypse Bird"); yield return(PreSuccessfulTriggerSequence()); yield return(new WaitForSeconds(1f)); yield return(Singleton <BoardManager> .Instance.CreateCardInSlot(CardLoader.GetCardByName(Constants.APOCALYPSE_BIRD_NAME), Card.Slot, 0.15f, true)); yield return(LearnAbility(0.5f)); } yield break; }