/* * I'm removing this static instance to make the Layout Manager local. * This way it can do the same functions for each side of the field. * //Awake is always called before any Start functions * void Awake() * { * //Check if instance already exists * if (instance == null) * * //if not, set instance to this * instance = this; * * //If instance already exists and it's not this: * else if (instance != this) * * //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. * Destroy(gameObject); * } */ //puts a card in the deck zone on the field public void PlaceInDeck(BasicCard card) { //cast the transform as a RectTransform to access more sophisticated methods. //Only necessary when there isn't an active Layout Group. //NOTE that the Layout groups also change the pivots of their children, but setting deckLocation to have a width and height of 0 seems to have solved that problem. //If in doubt, I can change the pivot in this calculation too. Or just make these locations their own layout group... RectTransform cardTransform = card.gameObject.transform as RectTransform; cardTransform.SetParent(null, false); //places the card on the field in the correct location. cardTransform.SetParent(deckLocation, false); cardTransform.anchoredPosition = Vector2.zero; //Debug.Log(card.ToString() + " placed in the Deck Area at " + cardTransform.position.ToString()); //ensures that the card remains face down. if (card.FaceUp) { card.FlipFaceDown(); } //ensures that the card remains untapped. if (card.Tapped) { card.Untap(); } }
//puts a card in the retreat area on the field public void PlaceInRetreat(BasicCard card) { //cast the transform as a RectTransform to access more sophisticated methods. //Only necessary when there isn't an active Layout Group RectTransform cardTransform = card.gameObject.transform as RectTransform; cardTransform.SetParent(null, false); //places the card on the field in the correct location. cardTransform.SetParent(retreatLocation, false); //sets the card's transform as the last in a local list so as to be rendered on top... actually has no effect. //cardTransform.SetAsLastSibling(); cardTransform.anchoredPosition = Vector2.zero; //Debug.Log(card.ToString() + " placed in the Retreat Area at " + cardTransform.position.ToString()); //ensures that the card remains face up. if (!card.FaceUp) { card.FlipFaceUp(); } //ensures that the card remains untapped. if (card.Tapped) { card.Untap(); } }
//puts a new card on the Front Line Area and returns the CardStack it created. public CardStack PlaceInFrontLine(BasicCard card) { GameObject pooledObject = cardStackObjectPool.GetObject(); CardStack stack = pooledObject.GetComponent <CardStack>(); stack.Setup(card); pooledObject.transform.SetParent(null, false); //places the card on the field in the correct location. pooledObject.transform.SetParent(frontLineLocation, false); //Debug.Log(card.ToString() + " placed on the Front Line at " + card.gameObject.transform.position.ToString()); //ensures that the card remains face up. if (!card.FaceUp) { card.FlipFaceUp(); } //ensures that the card remains untapped. if (card.Tapped) { card.Untap(); } return(stack); }
//puts a card in the Bond area either Face up or Face down as desired public void PlaceInBonds(BasicCard card, bool placeFaceUp) { card.gameObject.transform.SetParent(null, false); //places the card on the field in the correct location. card.gameObject.transform.SetParent(bondLocation, false); card.gameObject.transform.SetAsFirstSibling(); //Debug.Log(card.ToString() + " placed in the Bond Area at " + card.gameObject.transform.position.ToString()); //ensures that the card lands facing correctly and tapped. if (placeFaceUp) { if (!card.FaceUp) { card.FlipFaceUp(); } } else //the card should be placed face down { if (card.FaceUp) { card.FlipFaceDown(); } } if (!card.Tapped) { card.Tap(); } }
//Setup methods public void Setup(BasicCard topCard) { //a newly deployed card cannot be class Changed. classChanged = false; //ensures that the card lands face up. if (!topCard.FaceUp) { topCard.FlipFaceUp(); } cardsInPile.Push(topCard); //sets all the currently deployed card's skills as active and registers them to the appropriate events. topCard.ActivateFieldSkills(); //deals with positioning //cast the transform as a RectTransform to access more sophisticated methods. //Only necessary when there isn't an active Layout Group RectTransform cardTransform = topCard.gameObject.transform as RectTransform; cardTransform.SetParent(null, false); //places the card on the field in the correct location. cardTransform.SetParent(transform, false); cardTransform.anchorMax = new Vector2(0.5f, 0.5f); cardTransform.anchorMin = new Vector2(0.5f, 0.5f); cardTransform.anchoredPosition = Vector2.zero; //cardTransform.anchoredPosition = new Vector2(0.5f,0.5f); //Debug.Log(card.ToString() + " placed on the Front Line at " + card.gameObject.transform.position.ToString()); }
public void CanDiscardFromTheHandWhenNotEmpty() { BasicCard myCardToRemove = ScriptableObject.CreateInstance <BasicCard>(); GameEngine.Instance.hand.ClearCards(); GameEngine.Instance.hand.AddCard(myCardToRemove); GameEngine.Instance.disposalPile.ClearCards(); // Main action! GameEngine.Instance.DiscardCard(myCardToRemove); // Results are: // - The card should no more be in hand! (Hand must be empty) // - the card should be found in the disposal Assert.AreEqual(0, GameEngine.Instance.hand.Count()); Assert.AreSame(myCardToRemove, GameEngine.Instance.disposalPile.DrawCard()); // Rebelote GameEngine.Instance.hand.AddCard(myCardToRemove); GameEngine.Instance.DiscardCard(); // Blindly remove a card (but only one, then... ;) ) Assert.AreEqual(0, GameEngine.Instance.hand.Count()); Assert.AreSame(myCardToRemove, GameEngine.Instance.disposalPile.DrawCard()); }
public void BasicCardInits() { var title = "title"; var subtitle = "subtitle"; var text = "text"; var cardAction = new CardAction("type", "title", "image", "text", "displayText", new { }, new { }); var images = new List <CardImage>() { new CardImage("http://example.com", "example image", cardAction) }; var buttons = new List <CardAction>() { cardAction }; var tap = cardAction; var basicCard = new BasicCard(title, subtitle, text, images, buttons, tap); Assert.NotNull(basicCard); Assert.IsType <BasicCard>(basicCard); Assert.Equal(title, basicCard.Title); Assert.Equal(subtitle, basicCard.Subtitle); Assert.Equal(text, basicCard.Text); Assert.Equal(images, basicCard.Images); Assert.Equal(buttons, basicCard.Buttons); Assert.Equal(tap, basicCard.Tap); }
//Activates Ogma's Captain of the Royal Talysian Army buffing skill. (No choice) public override void ActivateTriggerSkill(BasicCard triggeringCard) { //displays the ability on the Game Log CardReader.instance.UpdateGameLog("\nOgma's Captain of the Royal Talysian Army skill raises the attack of himself and " + triggeringCard.CharName + " by +10 until the end of the turn!"); //remember the skill's target for future use. buffedAllies.Add(triggeringCard); //Adds 10 to the triggering card's attack and Ogma's till the end of the turn. triggeringCard.attackModifier += 10; attackModifier += 10; //display the boost on the target. triggeringCard.AddToSkillChangeTracker("Ogma's Captain of the Royal Talysian Army skill providing +10 attack."); //update Ogma's skill display. RemoveFromSkillChangeTracker("Ogma's Captain of the Royal Talysian Army skill providing +" + timesBuffed + "0 attack."); timesBuffed++; AddToSkillChangeTracker("Ogma's Captain of the Royal Talysian Army skill providing +" + timesBuffed + "0 attack."); //Sets up the removal methods at the end of the player's turn or if a buffed card leaves the field. Owner.endTurnEvent.AddListener(RemoveAllOgmaBuffs); triggeringCard.RemoveFromFieldEvent.AddListener(RemoveOgmaBuffFromAnother); //returns control to the deployTriggerTracker to recheck conditions and activate any remaining abilities. Owner.deployTriggerTracker.RecheckTrigger(); }
//fonction lancée au drag d'une carte public void OnBeginDrag(PointerEventData eventData) { //on active la dropZone pour les cartes GameManager.Instance.ActiveDropZone(true); startPosition = this.transform.position; if (eventData.pointerDrag.GetComponent <CardDisplay>().card.cardType != BasicCard.CARDTYPE.CURSE) { this.transform.SetParent(movingCardParent); eventData.pointerDrag.GetComponent <CardDisplay>().OnCardDrag(true); } _card = eventData.pointerDrag.GetComponent <CardDisplay>().card; context = new GameContext { card = _card }; if (_card.cardType == BasicCard.CARDTYPE.MOVE) { PlayerMgr.Instance.UpdateMoveDatas(context.card.effectsData); //On envoie les datas de la carte au playerMgr pour gérer les cas d'accessibilités des nodes voisins } //on désactive le drag de la caméra pour rester stabe pendant le drag d'une carte mainCamera.ActiveCameraDrag(false); }
//fonction lancée au drag d'une carte public void OnBeginDrag(PointerEventData eventData) { //onCardDragBeginDelegate?.Invoke(this.gameObject, eventData); startPosition = this.transform.position; if (eventData.pointerDrag.GetComponent <CardDisplay>().card.cardType != BasicCard.CARDTYPE.CURSE) { this.transform.SetParent(movingCardParent); eventData.pointerDrag.GetComponent <CardDisplay>().OnCardDrag(true); } _card = eventData.pointerDrag.GetComponent <CardDisplay>().card; context = new GameContext { card = _card }; if (_card.cardType == BasicCard.CARDTYPE.MOVE) { PlayerManager.Instance.UpdateMoveDatas(context.card.effectsData); //On envoie les datas de la carte au playerMgr pour gérer les cas d'accessibilités des tiles voisines } //On montre les positions disponibles pour le drop de la carte dropPosManager.ShowPositionsToDrop(_card); }
public override void playCard() { bool playerInputValid = false; do { object cardColor; string playerInput; Console.WriteLine("What color would you like the " + this.Type + " card to be?"); playerInput = Console.ReadLine().Trim().ToLower(); playerInput = Function.titleCase(playerInput); playerInputValid = Enum.TryParse(typeof(CardColor), playerInput, true, out cardColor); if (playerInputValid) { setColor((CardColor)cardColor); BasicCard.playCard(); } else { Console.WriteLine(playerInput + " is not a color option. Color options are: "); foreach (CardColor color in Enum.GetValues(typeof(CardColor))) { Console.WriteLine(color); } } } while (!playerInputValid); }
public bool playDrawnCard(BasicCard cardDrawn) { bool playedCard = false; Console.WriteLine("You drew a " + cardDrawn.lookAtCard() + "."); if (discardDeck.isCardPlayable(cardDrawn)) { Console.WriteLine("The card you drew is playable."); Console.WriteLine("Would you like to play this card?"); if (playerEnterYesOrNo()) { playCard(cardDrawn); playedCard = true; } else { putCardInHand(cardDrawn); } } else { putCardInHand(cardDrawn); } return(playedCard); }
/** * Play the effect of the card */ public void PlayCard(BasicCard card, GameContext context) { //create and apply all the effect of the card foreach (CardEffectData effectData in card.effectsData) { CardEffect effect = CreateEffect(effectData.GetEffectType()); effect.ApplyEffect(effectData, context); } //Une fois que les effets ont été appliqués, on lance les actions GameSequencer.Instance.ExecuteActions(context); //on met à jour les infos des cartes affichées GameManager.Instance.UpdateCardDataDisplay(); //on indique le nombre de tour que va jouer le RingMaster //on check les possibles modificateurs if (BuffManager.Instance.isStickyFingersActivate) { TimelineManager.Instance.SetRingmasterActionRemain(context.card.actionCost + 1); } else { TimelineManager.Instance.SetRingmasterActionRemain(context.card.actionCost); } if (context.card.actionCost == 0) { //on lock toutes les cartes en main et tout le downPanel GameManager.Instance.UnlockDragCardHandler(true); GameManager.Instance.DownPanelBlock(false); } }
/** * Discard a card (not from hand) * Call by the NodeEffectMgr */ public void AddCardToDiscardPile(BasicCard cardDiscarded) { GameEngine.Instance.AddCardToDiscardPile(cardDiscarded); //active visual effect //GameManager.Instance.SetVisualCardOnDeck("DiscardPile"); }
//Add a card directly to the disposal pile (Discard) public void AddCardToDiscardPile(BasicCard discardedCard) { if (discardedCard != null) { disposalPile.AddCard(discardedCard); } }
public void ShowPositionsToDrop(BasicCard draggedCard) { switch (draggedCard.cardType) { case BasicCard.CARDTYPE.MOVE: // Say to MapManager if the card we want to play is swift or not, to change accessible nodes if (draggedCard.effectsData[0].swift) { MapManager.Instance.ignoreEnemies = true; } else { MapManager.Instance.ignoreEnemies = false; } // Display accessibles nodes effects MapManager.Instance.UpdateAccessibleNodesList(); MapManager.Instance.AllowAccessibleNodesEffects(); break; case BasicCard.CARDTYPE.ATTACK: EnemyMgr.Instance.AllowAttackableEffect(draggedCard.effectsData[0].attackRange); break; } }
public void DiscardSupport() { retreat.Add(SupportCard); layoutManager.PlaceInRetreat(SupportCard); Debug.Log(SupportCard.ToString() + " is placed in the Retreat Zone."); supportCard = null; }
public void BasicCardInitsWithNoArgs() { var basicCard = new BasicCard(); Assert.NotNull(basicCard); Assert.IsType <BasicCard>(basicCard); }
//deploys a card on the field //should only be called by the ContextMenu buttons and so doesn't do any checks on location, etc. public void DeployToFieldFromHand(BasicCard card) { //Update the used bonds before anything changes on the board. GameManager.instance.bondDeployCount += card.DeploymentCost; //remove the card from the hand. Hand.Remove(card); //We need to know where to deploy this card. Call a dialogue box. DialogueWindowDetails details = new DialogueWindowDetails { windowTitleText = "Deployment", questionText = "Where would you like to deploy " + card.CharName + "?", button1Details = new DialogueButtonDetails { buttonText = "Front Line", buttonAction = () => { DeployToFrontLine(card); } }, button2Details = new DialogueButtonDetails { buttonText = "Back Line", buttonAction = () => { DeployToBackLine(card); } } }; DialogueWindow dialogueWindow = DialogueWindow.Instance(); dialogueWindow.MakeChoice(details); }
public void PlaceCardInBonds(BasicCard card, List <BasicCard> presentLocation, bool placeFaceUp) { if (!presentLocation.Contains(card)) { Debug.LogError("ERROR! Tried to place card in bonds, but " + card.ToString() + " not found in " + presentLocation.ToString()); } else { presentLocation.Remove(card); Bonds.Add(card); //text for the Game Log string bondText = playerName + " places " + card.CharName + ": " + card.CharTitle + " in the Bond Area "; if (placeFaceUp) { AddColorToBonds(card); bondText += "faceup."; } else { bondText += "faceudown."; } layoutManager.PlaceInBonds(card, placeFaceUp); CardReader.instance.UpdateGameLog(bondText); Debug.Log(card.ToString() + " placed in Bonds. Bonds now has " + Bonds.Count + " cards, and " + presentLocation.ToString() + " has " + presentLocation.Count + " cards."); } }
//This method actually reassigns/moves the support card. private void FlipSupport() { supportCard = Deck[0]; layoutManager.PlaceInSupport(Deck[0]); Debug.Log(Deck[0].ToString() + " was placed in the Support Zone."); CardReader.instance.UpdateGameLog(playerName + " draws " + Deck[0].CharName + " as a support!"); deck.RemoveAt(0); }
//This method sets up the MC card on a player's field at the start of the game. public void SetMCAtStart(BasicCard card) { deck.Remove(card); playerMC = layoutManager.SetAsMC(card); frontLine.Add(playerMC); Debug.Log(playerName + "'s MC was set as " + MCCard.CharName + ": " + MCCard.ToString()); }
private void moveCardFromDrawDeckToDiscardDeck() { int drawDeckTopCardIndex = drawDeck.topCardIndex(); BasicCard drawDeckTopCard = drawDeck.CardDeck[drawDeckTopCardIndex]; drawDeck.removeCard(drawDeckTopCardIndex, discardDeck); discardDeck.addCard(drawDeckTopCard); }
//Takes a random card from the hand and junk it to the disposal pile public void DiscardRandomCard() { BasicCard discarded = hand.DrawCard(); if (discarded != null) { disposalPile.AddCard(discarded); } }
//Captain of the Royal Talysian Army [TRIGGER] Each time an ally with a Deployment Cost of 2 or lower is deployed, until the end of the turn, this unit and that ally gain +10 attack. //Checks to see if a cost 2 or lower ally has been deployed public override bool CheckTriggerSkillCondition(BasicCard triggeringCard) { if (triggeringCard.DeploymentCost <= 2) { return(true); } return(false); }
public SetCardColor(BasicCard card) { this.BasicCard = card; setColor(BasicCard.Color); Type = BasicCard.Type; PerformCardAction = BasicCard.PerformCardAction; CardWithNoActions = false; card.CardWithNoActions = false; }
public void addCardToHand(BasicCard card) { hand.addCard(card); if (hand.CardDeck.Count > 1) { resetSaidUnoField(); } }
/** * Create a card gameObject in the hand and add it to the list * Use when a card is draw */ public void AddCard(BasicCard cardDraw) { CardDisplay cardDisplay = Instantiate(cardDisplayPrefab, this.transform).GetComponent <CardDisplay>(); //Set the display of the card cardDisplay.gameObject.GetComponent <RectTransform>().sizeDelta = new Vector2(cardWidth, cardHeight); cardDisplay.UpdateCard(cardDraw); CardDisplayList.Add(cardDisplay); }
/** * At the beginning of turn, * the player discard all his currents cards and draw new one. */ public void PlayerDraw() { handManager.DiscardAllCard(); for (int i = 0; i < GameEngine.Instance.GetSettings().MaxHandCapability; i++) { BasicCard cardDrawn = GameEngine.Instance.DrawCard(); handManager.AddCard(cardDrawn); } }
//add card to hand from shop public void AddCardInHand(BasicCard card) { GameEngine.Instance.hand.AddCard(card); handManager.AddCard(card); UpdateCardDataDisplay(); //compteur des cartes piocher à ce tour pour le player PlayerMgr.Instance.AddCardAtThisTurn(); }