public void PlayerMoveByItem(Transform tailPiece, Card.CardType itemType) { gameplayManager.EndTurnButton.interactable = false; if (PlayerWalkinItemPosition <= 0) { transform.position = Vector2.MoveTowards(transform.position, tailPiece.transform.position, MoveSpeed * Time.deltaTime); GameplayManager.StillMoveBecauseItem = true; if (transform.position == tailPiece.transform.position) { if (itemType == Card.CardType.Snake || itemType == Card.CardType.Snake2Head) { //SoundManager.PlaySoundEffect("GotSnakeEffect"); } else { //SoundManager.PlaySoundEffect("GotLadderEffect"); } PlayerWalkinItemPosition += 1; } } else { PlayerMovingWaypointIndex = Waypoint.WaypointIndexContainPlayer; SetCurrentPositionPlayer(Waypoint.WaypointIndexContainPlayer); GameplayManager.StillMoveBecauseItem = false; } gameplayManager.EndTurnButton.interactable = true; }
public void DisplayActionButtons(Card.CardType cardType, bool newCard = false) { foreach (GameObject button in actionButtons) { if (button.name.Equals(cardType.ToString())) { button.SetActive(true); if (newCard) { foreach (Transform child in button.GetComponentInChildren <Transform>()) { if (cardType.Equals(Card.CardType.NPC) && child.name.Equals("Button Run")) { child.gameObject.SetActive(false); } else { child.gameObject.SetActive(true); } } } } else { button.SetActive(false); } } }
public Card_AttackTypeCount(XmlNode _node) { node = _node; range = 0; if (node ["range"] != null) { range = float.Parse(node ["range"].InnerText); } else { Debug.Log("ATTACK CARD HAS NO RANGE: " + idName); } typeToCareAbout = Card.CardType.Other; if (node ["type_to_care_about"] != null) { typeToCareAbout = cardTypeFromString(node ["type_to_care_about"].InnerText); } damagePerCard = 1; if (node ["damage_per_card"] != null) { damagePerCard = int.Parse(node ["damage_per_card"].InnerText); } }
public void TestCardToHand() { System.Collections.Generic.List <Card> deck = new System.Collections.Generic.List <Card>(); Card.Suits suit = Card.Suits.Diamonds; Card.CardType typ = Card.CardType.Five; Card card = new Card(typ, suit); deck.Add(card); deck.Add(card); deck.Add(card); // Test the number of cards in the deck Assert.AreEqual(3, deck.Count); CardPlayer cardPlayer = new CardPlayer(); //Test the number of cards on hand Assert.AreEqual(0, cardPlayer.HandValue); cardPlayer.addCardToHand(); // Test the number of cards after play Assert.AreEqual(2, deck.Count); Assert.AreEqual(5, cardPlayer.HandValue); }
public void ExecuteCard(Card.CardType type) { Vector2Int direction; switch (type) { case Card.CardType.Up: direction = Vector2Int.up; break; case Card.CardType.Down: direction = Vector2Int.down; break; case Card.CardType.Left: direction = Vector2Int.left; break; case Card.CardType.Right: direction = Vector2Int.right; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } MoveEverything(direction); }
public Card_CardsPlayedBonus(XmlNode _node) { node = _node; anyUnit = false; if (node ["any_unit"] != null) { anyUnit = bool.Parse(node ["any_unit"].InnerXml); } numCardsToDraw = 0; if (node ["cards_to_draw"] != null) { numCardsToDraw = int.Parse(node ["cards_to_draw"].InnerXml); } numActionsToGain = 0; if (node ["actions_to_gain"] != null) { numActionsToGain = int.Parse(node ["actions_to_gain"].InnerXml); } typeToCareAbout = Card.CardType.Other; if (node ["type_to_care_about"] != null) { typeToCareAbout = cardTypeFromString(node ["type_to_care_about"].InnerText); } }
private void MakeCard() { splashArt = transform.Find("splash").GetComponent <SpriteRenderer>(); nameText = gameObject.transform.Find("CardNameText").GetComponent <TextMeshPro>(); //AttackCostText = transform.Find("AttackCost").GetComponent<TextMeshPro>(); //DrawCostText = transform.Find("DrawCost").GetComponent<TextMeshPro>(); effectDiscriptionText = transform.Find("CardDescription").GetComponent <TextMeshPro>(); backgroundRenderer = transform.Find("cardBackground").GetComponent <SpriteRenderer>(); mainCardMat = backgroundRenderer.material; highlightborder = transform.Find("highlight").GetComponent <SpriteRenderer>(); clickhighlightborder = transform.Find("click highlight").GetComponent <SpriteRenderer>(); keywordTextBox = transform.Find("keywordText").gameObject; if (card.cardSplashArt != null) { splashArt.sprite = card.cardSplashArt; } else { splashArt.sprite = null; } containedKeywords = new List <Card.Keywords>(); nameText.text = card.cardName; cardType = card.type; gameObject.name = card.cardName; attackCost = card.attackBarCost; drawCost = card.drawBarCost; company = card.Company; effectDiscriptionText.text = card.cardEffectDiscription; containedKeywords = card.containedKeywords; }
public override void setupCustom() { Card_AttackTypeCount blueprintCustom = (Card_AttackTypeCount)blueprint; range = blueprintCustom.range; typeToCareAbout = blueprintCustom.typeToCareAbout; damagePerCard = blueprintCustom.damagePerCard; }
public bool TypeIs(Card.CardType cardType) { if (!cardIsOpen) { return(false); } return(selfCard.cardType == cardType); }
public override void setupCustom() { Card_CardsPlayedBonus blueprintCustom = (Card_CardsPlayedBonus)blueprint; anyUnit = blueprintCustom.anyUnit; numCardsToDraw = blueprintCustom.numCardsToDraw; numActionsToGain = blueprintCustom.numActionsToGain; typeToCareAbout = blueprintCustom.typeToCareAbout; }
// Workaround to "instanciate" Playable, since "new" cannot be called on monobehaviour. public static Playable GetPlayable(string id, Card.CardType buildType) { GameObject go = new GameObject(); Playable p = go.AddComponent <Playable>(); p.id = id; p.buildType = buildType; return(p); }
public string PasangItem(RaycastHit2D hit, GameObject item, Card.CardType itemType, Card cardOnHand) { int[] boardPosItemPlaced; Vector3 itemPosition = new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z); if (hit.collider.gameObject.name == "Waypoint") { boardPosItemPlaced = new int[] { 1 }; } else { string resultString = Regex.Match(hit.collider.gameObject.name, @"\d+").Value; int clickPosisi = int.Parse(resultString) + 1; if (itemType == Card.CardType.Ladder2Tail || itemType == Card.CardType.Snake2Head) { boardPosItemPlaced = new int[] { clickPosisi - 1, clickPosisi + 1 }; } else { boardPosItemPlaced = new int[] { clickPosisi }; } } // DICOMMENT KARENA TESTING if (GameObject.Find(item.name + "(Clone)") != null) { PhotonNetwork.Destroy(GameObject.Find(item.name + "(Clone)")); } string itemPrefabPath = "Items/" + cardOnHand.Level.ToString() + "/" + itemType.ToString() + "/" + item.name; this.ItemOnHand = new Item { Owner = PlayerScript.PlayerNickname, Age = 0, BoardPosition = boardPosItemPlaced[0], Type = itemType, ItemObject = PhotonNetwork.Instantiate(itemPrefabPath, itemPosition, item.transform.rotation), }; if (!this.ItemOnHand.ItemObject.activeSelf) { this.ItemOnHand.ItemObject.SetActive(true); } // DICOMMENT KARENA TESTING if (CheckTailTrigger.TriggerByTail) { CheckTailTrigger.TriggerByTail = false; } this.ItemOnHand.ItemObject.transform.Find("gambar").gameObject.SetActive(false); this.ItemOnHand.Spawn(hit.collider.gameObject.transform.position); ClickMousePlaceItem = true; return("snake/ladder putted"); }
private void Discard(Card.CardType role) { foreach (Card c in this.cards) { if (c.GetRole() == role) { this.cards.Remove(c); return; } } }
public Card drawCard(Card.CardType type) { if (type == Card.CardType.CHANCE) { return(drawChance()); } else if (type == Card.CardType.COMMUNITY) { return(drawCommunity()); } return(null); }
public static bool HasCard(Card.CardType cardType, List <uint> hands, uint num = 1) { uint count = 0; foreach (var v in hands) { if ((Card.GetCard(v).Type) == cardType) { count++; } } return(count >= num); }
public int getCardsInHandOfType(Card.CardType type) { int total = 0; foreach (Card card in hand) { if (card.type == type) { total++; } } return(total); }
public static object DeserializeCard(StreamBuffer inStream, short length) { int cardValue, cardTypeID, cardLevelID; Card.CardLevel cardLevel = Card.CardLevel.None; Card.CardType cardType = Card.CardType.None; lock (memCard) { inStream.Read(memCard, 0, 3 * 4); int off = 0; Protocol.Deserialize(out cardValue, memCard, ref off); Protocol.Deserialize(out cardTypeID, memCard, ref off); Protocol.Deserialize(out cardLevelID, memCard, ref off); } if (cardTypeID == 1) { cardType = Card.CardType.Snake; } else if (cardTypeID == 2) { cardType = Card.CardType.Snake2Head; } else if (cardTypeID == 3) { cardType = Card.CardType.Ladder; } else if (cardTypeID == 4) { cardType = Card.CardType.Ladder2Tail; } if (cardLevelID == 1) { cardLevel = Card.CardLevel.One; } else if (cardLevelID == 2) { cardLevel = Card.CardLevel.Two; } else if (cardLevelID == 3) { cardLevel = Card.CardLevel.Three; } Card boughtCard = new Card(cardValue, cardLevel, cardType); return(boughtCard); }
//getting some info public int getCardsOfTypePlayedThisTurn(Card.CardType type) { if (cardsPlayedThisTurn == null) { return(0); } int total = 0; foreach (Card card in cardsPlayedThisTurn) { if (card.type == type) { total++; } } return(total); }
public static object DeserializeItem(StreamBuffer inStream, short length) { int itemOwnerID, itemAge, itemBoardPos, itemTypeID; Card.CardType itemType = Card.CardType.None; lock (memItem) { inStream.Read(memItem, 0, 4 * 4); int off = 0; Protocol.Deserialize(out itemOwnerID, memItem, ref off); Protocol.Deserialize(out itemAge, memItem, ref off); Protocol.Deserialize(out itemBoardPos, memItem, ref off); Protocol.Deserialize(out itemTypeID, memItem, ref off); } if (itemTypeID == 1) { itemType = Card.CardType.Snake; } else if (itemTypeID == 2) { itemType = Card.CardType.Snake2Head; } else if (itemTypeID == 3) { itemType = Card.CardType.Ladder; } else if (itemTypeID == 4) { itemType = Card.CardType.Ladder2Tail; } Item attachedItem = new Item { Owner = PhotonNetwork.CurrentRoom.GetPlayer(itemOwnerID).NickName, Age = itemAge, BoardPosition = itemBoardPos, Type = itemType }; return(attachedItem); }
public void TestCreatDeck() { //creat a cardtype list with the different types List <Card.CardType> cardTypes = new List <Card.CardType>(); cardTypes.Add(Card.CardType.hearts); cardTypes.Add(Card.CardType.diamonds); cardTypes.Add(Card.CardType.clover); cardTypes.Add(Card.CardType.spades); //create the correct hashset with correct tostrings. // hashset is used for contains check and to remove order dependency. HashSet <string> correctToStringHashSet = new HashSet <string>(); for (int i = 0; i < cardTypes.Count; i++) { //loop through card types and add them to the hashset with the correct toString value Card.CardType cardTypeVarible = cardTypes[i]; for (int j = 1; j < Card.numberOfDifferentValues + 1; j++) { correctToStringHashSet.Add("Cardtype: " + cardTypeVarible + " Number: " + (Card.CardNumber)j); } } //create the default deck and add to string in to a hashset. Deck defaultDeck = new Deck(); defaultDeck.createCardPile(); Assert.IsTrue(defaultDeck.Cards.Count == Card.numberOfDifferentValues * Card.numberofTypes); HashSet <string> deckCardsHashSet = new HashSet <string>(); for (int i = 0; i < defaultDeck.Cards.Count; i++) { deckCardsHashSet.Add(defaultDeck.Cards[i].ToString()); } // loop through the correct tostring hashset and check so that the decks hashset contains the correct to string. foreach (string toStringCompare in correctToStringHashSet) { Assert.IsTrue(deckCardsHashSet.Contains(toStringCompare)); } }
public void TestHandValue() { CardPlayer cardPlayer = new CardPlayer(); System.Collections.Generic.List <Card> cards = new System.Collections.Generic.List <Card>(); Card.Suits suit = Card.Suits.Diamonds; Card.CardType typ = Card.CardType.Five; Card card = new Card(typ, suit); cards.Add(card); cards.Add(card); cards.Add(card); cardPlayer.Hand = cards; cardPlayer.getHandValue(); // Test correctness of card counting Assert.AreEqual(15, cardPlayer.HandValue); }
public static Color TypeToColor(Card.CardType t) { switch (t) { case Card.CardType.Hit: return(Color.red); case Card.CardType.Miss: return(Color.blue); case Card.CardType.Block: return(Color.blue); case Card.CardType.Armor: return(Color.green); default: break; } Debug.LogError("Missing color data for " + t); return(Color.white); }
public string SelectBoardToPutItem(GameObject item, Card.CardType itemType, Card cardOnHand) { //deklarasi variabel condition string condition = "empty"; //kondisi ketika meng-klik kiri pada mouse if (Input.GetMouseButtonDown(0)) { Debug.Log("press"); //Mengambil nilai Vector3 dari posisi kursor mouse saat melakukan klik kiri Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); //Mengambil nilai Vector2 dari posisi kursor mouse saat melakukan klik kiri Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); //Mengambil nilai RaycastHit2D dari kursor mouse saat melakukan klik kiri RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); //Mengisi nilai dari condition dengan mengeksekusi method Checkboard dengan parameter RaycastHit2d, GameObject, ItemType dan CardOnHand condition = this.CheckBoard(hit, item, itemType, cardOnHand); //Memasukkan nilai dari variabel condition ke dalam properti isPlayerPlacedItem this.IsPlayerPlacedItem = condition; } //kondisi ketika properti isPlayerPlaced memiliki nilai "snake/ladder putted" else if (this.IsPlayerPlacedItem == "snake/ladder putted") { //Mengisi nilai dari condition dengan memberikan nilai dari properti isPlayerPlacedItem condition = this.IsPlayerPlacedItem; } //Kondisi ketika melepas klik kiri dari mouse if (Input.GetMouseButtonUp(0)) { //mengisi parameter clickMousePlaceItem dengan nilai false ClickMousePlaceItem = false; } //memberikan nilai kembalian berupa variabel condition return(condition); }
public void UpdateVisual() { card = GetComponent <CardFunction>().card; splashArt = transform.Find("splash").GetComponent <SpriteRenderer>(); Background = transform.Find("cardBackground").GetComponent <SpriteRenderer>(); descriptionBG = transform.Find("carddesc").GetComponent <SpriteRenderer>(); CompanyNameBG = transform.Find("bottom background").GetComponent <SpriteRenderer>(); TopNameBG = transform.Find("title background").GetComponent <SpriteRenderer>(); CostIndicator = transform.Find("CostIcon").GetComponent <SpriteRenderer>(); nameText = gameObject.transform.Find("CardNameText").GetComponent <TextMeshPro>(); CostText = transform.Find("Cost").GetComponent <TextMeshPro>(); //DrawCostText = transform.Find("DrawCost").GetComponent<TextMeshPro>(); effectDiscriptionText = transform.Find("CardDescription").GetComponent <TextMeshPro>(); CompanyNameText = transform.Find("CardCompanyDisplay").GetComponent <TextMeshPro>(); keywordExplainText = transform.Find("keywordText").GetComponent <TextMeshPro>(); splashArt.sprite = card.cardSplashArt; nameText.text = card.cardName; cardType = card.type; gameObject.name = card.cardName; attackCost = card.attackBarCost; drawCost = card.drawBarCost; if (attackCost > 0) { CostText.text = attackCost.ToString(); CostIndicator.sprite = Services.cardList.CPUCostIcon; } else if (drawCost > 0) { CostText.text = drawCost.ToString(); CostIndicator.sprite = Services.cardList.GPUCostIcon; } else { CostText.text = drawCost.ToString(); } //DrawCostText.text = drawCost.ToString(); int index = 0; if (card.Company == Card.CardCompany.BasicSoftware) { index = 0; } else if (card.Company == Card.CardCompany.FileKillerCorp) { index = 1; } else if (card.Company == Card.CardCompany.Snorton) { index = 2; } Background.sprite = Services.cardList.CardBackGround[index]; TopNameBG.sprite = Services.cardList.CardTitleBackGround[index]; CompanyNameBG.sprite = Services.cardList.CardTitleBackGround[index]; descriptionBG.sprite = Services.cardList.CardDescriptionBackGround[index]; effectDiscriptionText.text = card.cardEffectDiscription; CompanyNameText.text = companyFullName[(int)card.Company]; string temp = ""; foreach (Card.Keywords a in card.containedKeywords) { temp += keywordDescription[(int)a] + "\n"; } keywordExplainText.text = temp; GetComponent <CardFunction>().keywordTextBox = keywordExplainText.gameObject; keywordExplainText.gameObject.SetActive(false); }
public void InitCard(bool isenemy, string name, string animname, int cost, int hp = 0, int atk = 0, Card.CardType cardtype = Card.CardType.Character, Card.HurtEffect hurteffect = Card.HurtEffect.Normal) { GameObject toInstantiate = (GameObject)Resources.Load("Prefabs/HandCard"); Card card = Instantiate(toInstantiate, battlemanager.transform.Find("Recycle")).GetComponent <Card>(); card.battleManager = battlemanager; card.m_IsEnemy = isenemy; card.ChangeHPAndATKLine(); card.m_CardName = name; card.m_HurtEffect = hurteffect; card.ChangeHP(hp); card.ChangeATK(atk); card.m_Cost = cost; card.m_CardType = cardtype; card.InitAnimation(animname); card.PrepareForBattle(); this.m_AreaList.Add(card); }
static public bool Card_Is_Of_Type(Card c, Card.CardType cardType) { //return c.Type == cardType; return(true); }
public string CheckBoard(RaycastHit2D hit, GameObject item, Card.CardType itemType, Card cardOnHand) { //kondisi ketika collider pada raycasthit2d tidak kosong atau tidak bernilai null if (hit.collider != null) { string objectTagCollidedByItem = hit.collider.gameObject.tag; GameObject gambarObject, parentObject; switch (objectTagCollidedByItem) { case "Petak-100": //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo("Dilarang memasang item di petak 100!", 2f, false)); return("error"); case "kepala": gambarObject = hit.collider.gameObject.transform.GetChild(0).gameObject; if (gambarObject.activeSelf.Equals(false)) { //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo(CheckTailTrigger.AlertMessage, 2f, false)); } else { //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo("Dilarang memasang disini, ada item lain!", 2f, false)); } return("error"); case "ekor": parentObject = hit.collider.gameObject.transform.parent.gameObject; gambarObject = parentObject.transform.GetChild(0).gameObject; if (gambarObject.activeSelf.Equals(false)) { //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo(CheckTailTrigger.AlertMessage, 2f, false)); } else { //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo("Dilarang memasang disini, ada item lain!", 2f, false)); } return("error"); case "Player": //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo("Dilarang memasang disini, ada pion pemain!", 2f, false)); return("error"); case "Barrier": //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo("Tidak boleh memasang diluar area papan!", 2f, false)); return("error"); default: return(this.PasangItem(hit, item, itemType, cardOnHand)); } } else { //SoundManager.PlaySoundEffect("WrongPlace"); StartCoroutine(gameplayManager.DisplayNotificationInfo("Tidak boleh memasang diluar area papan!", 2f, false)); return("error"); } }