//创建牌 void CreateCards(Transform parentTrans, List <Card> cards, bool isSort) { List <Card> temp = cards; if (isSort) { temp.Sort((a, b) => { int a_count = cards.FindAll(p => p.GetCardWeight == a.GetCardWeight).Count; int b_count = cards.FindAll(p => p.GetCardWeight == b.GetCardWeight).Count; if (a_count > b_count) { return(-1); } else if (a_count < b_count) { return(1); } else { return(0); } }); } for (int i = 0; i < temp.Count; i++) { CardUI a = LandlordsPage.MakeSprite(temp[i], false, parentTrans); a.SetCardSize(new Vector2(145, 190)); } ani.Play(); }
private GameObject CreateCardDisplay(Card cardData) { Transform cardHolder = GetNextAvailableCardHolder(); GameObject cardObject = Instantiate(cardPrefab, cardHolder); CardUI cardUI = cardObject.GetComponent <CardUI>(); cardUI.cardData = cardData; DragSource dragSource = cardObject.GetComponent <DragSource>(); if (dragSource != null) { dragSource.enabled = cardDraggable; } HoverCardOverlay cardHover = cardObject.GetComponent <HoverCardOverlay>(); if (cardHover != null) { cardHover.hoverParent = hoverParent; } return(cardObject); }
public void FlipDiscard() { GameObject discard = GameObject.FindGameObjectWithTag("Discard"); if (!showingDiscard) { discard.transform.localPosition = displayDiscardPlacement; for (int i = 0; i < S.GameControlInst.Discard.Count; i++) { CardUI tempcardui = S.GameControlInst.Discard[i].GetComponent <CardUI>(); tempcardui.MoveAnimateWhileDiscarded(i, false); } } else { discard.transform.localPosition = originalDiscardPlacement; for (int i = 0; i < S.GameControlInst.Discard.Count; i++) { CardUI tempcardui = S.GameControlInst.Discard[i].GetComponent <CardUI>(); tempcardui.MoveAnimateWhileDiscarded(i, true); } } showingDiscard = !showingDiscard; }
private void RefreshInventorySpells() { foreach (GameObject button in inventorySpellCards) { Destroy(button); } int i = 0; foreach (Spell spell in inventory.spells) { CardUI spellCard = InitializeButton(i, inventory.spells.Count, spellCardPanel, new SpellCard(spell), null) as CardUI; spellCard.card = new SpellCard(spell); GameObject text = spellCard.gameObject.transform.GetChild(0).gameObject; text.GetComponent <Text>().text = spell.ToString(); inventorySpellCards.Add(spellCard.gameObject); i += 1; } i = 0; foreach (Spell spell in inventory.equippedSpells) { CardUI spellCard = InitializeButton(i, inventory.equippedSpells.Count, equippedSpellsPanel, new SpellCard(spell), null) as CardUI; GameObject text = spellCard.gameObject.transform.GetChild(0).gameObject; text.GetComponent <Text>().text = spell.ToString(); inventorySpellCards.Add(spellCard.gameObject); i += 1; } }
/// <summary> /// 生成手牌 /// </summary> /// <param name="card"></param> /// <param name="index"></param> /// <param name="isSelected"></param> /// <param name="type"></param> public void CreateCardUI(Card card, int index, bool isSelected, ShowPoint type) { // GameObject temp = LeanPool.Spawn(m_Prefab); temp.transform.localScale = new Vector3(1, 1, 1); CardUI cardUI = temp.GetComponent <CardUI>(); cardUI.Card = card; cardUI.IsSelected = isSelected; if (type == ShowPoint.Player) { cardUI.SetCardPosition(PlayPoint, index); } else if (type == ShowPoint.ComputerRight) { cardUI.SetCardPosition(ComputerRightPoint, index); } else if (type == ShowPoint.ComputerLeft) { cardUI.SetCardPosition(ComputerLeftPoint, index); } else if (type == ShowPoint.Desk) { cardUI.SetCardPosition(CreatePoint, index); } }
/// <summary> /// Initialize controller of current card /// </summary> /// <param name="card">Card model for initialize</param> public void Initialize(Card card) { this.card = card; cardUI = GetComponent <CardUI>(); mouseDragCard = GetComponent <MouseDragCard>(); cardUI.Initialize(card, this); }
private void SpawnRandomCardIntoHand(Texture2D content) { GameObject spawnedGO = Instantiate(prefabCard, hand.transform); CardUI spawnedCard = spawnedGO.GetComponent <CardUI>(); spawnedCard.SetContent(content); }
/// <summary> /// 展示自身的牌 /// </summary> public void ShowCards(bool isShow) { if (isShow) { if (_handCard == null) { return; } net_protocol.DdzJSPlayerInfo result = LandlordsModel.Instance.ResultModel.GetResultInfos().Find(p => p.userId.ToString() == _handCard.playerInfo.uid); if (result == null) { return; } for (int i = 0; i < result.poker.Count; i++) { Card card = new Card(result.poker[i], _handCard.playerInfo.uid); CardUI ui = LandlordsPage.MakeSprite(card, false, resultCardsShow); ui.SetCardSize(new Vector2(145, 190)); ui.Card.IsSprite = false; ui.name = (i + 1).ToString(); } } else { for (int i = 0; i < resultCardsShow.childCount; i++) { resultCardsShow.GetChild(i).GetComponent <CardUI>().Destroy(); } } }
public void AddNewCard(CardData data) { //create the prefab GameObject newCard = m_CardPrefabPool.GetPooledObject(); CardUI cardUI = newCard.GetComponent <CardUI>(); if (cardUI != null) { //init newCard.SetActive(true); cardUI.Init(); cardUI._Image.sprite = GetSpriteOfCard(data.Type); cardUI._Value = data.Value; cardUI._Index = m_Cards.Count; cardUI._Card = data; //events cardUI.OnPointerEnter += cardUI_OnPointerEnter; cardUI.OnPointerExit += cardUI_OnPointerExit; cardUI.OnPointerUp += cardUI_OnPointerUP; //add as perent newCard.transform.SetParent(this.transform); newCard.transform.localPosition = Vector3.zero; newCard.transform.localScale = new Vector3(1, 1, 1); //add to the list m_Cards.Add(cardUI); } else { Debug.LogError("No CarUI script on card ui pooled object prefab :O"); } }
IEnumerator PlayerDumpCardRoutine(PlayerModule player) { isBusy = true; CardUI cardSet = FocusedCard; cardSet.Align(DumpPile.AirPoint, player); UnsetMarkers(); yield return(new WaitForSeconds(1f)); cardSet.Align(DumpPile.TopCard.transform, player); while (cardSet.isLerping) { yield return(0); } AudioControl.Instance.PlayInPosition("fp_flip_cards_color", cardSet.transform.position); DumpPile.PushCard(cardSet.Data); DestroyCard(cardSet); isBusy = false; }
public void OnPointerEnter(PointerEventData eventData) { hoverObject = Instantiate(cardPrefab, hoverParent.transform); CardUI hoverCardUI = hoverObject.GetComponent <CardUI>(); hoverCardUI.cardData = card; if (unitUI != null) { // Detect that this is a unit by the presence of unit ui. // If so, apply override. ApplyUnitOverrides(hoverCardUI, unitUI.unit); } ZoomHover(); CanvasGroup hoverGroup = hoverObject.GetComponent <CanvasGroup>(); hoverGroup.alpha = 0; UIManager.instance.LerpTime( Mathf.Lerp, 0f, 1f, fadeDuration, alpha => hoverGroup.alpha = alpha ); hoverObject.GetComponent <HoverCardOverlay>().enabled = false; }
private void CreateCardUI(Card card, int index, bool selected, ShowPoint pos) { //对象池生成 GameObject g = LeanPool.Spawn(prefab); g.name = characterType.ToString() + index.ToString(); //设置位置和是否选中 CardUI cardUI = g.GetComponent <CardUI>(); cardUI.Card = card; cardUI.IsSelected = selected; switch (pos) { case ShowPoint.Desk: cardUI.SetPosition(CreatePoint, index); break; case ShowPoint.Player: cardUI.SetPosition(PlayerPoint, index); break; case ShowPoint.ComputerRight: cardUI.SetPosition(ComputerRightPoint, index); break; case ShowPoint.ComputerLeft: cardUI.SetPosition(ComputerLeftPoint, index); break; default: break; } }
public static void SetSelectedNodeCard(CardUI cardUi) { instance.selectedCard?.Select(false); instance.selectedCard = cardUi; instance.selectedCard.Select(true); }
public void OnPointerEnter() { if (isDrag) { CardUI.AddToList(this); } }
/// <summary> /// Method to display Card Swap on UI between Player and Discarded Deck /// </summary> /// <param name="parent">Game Object of Current Player</param> /// <param name="touchedCard">Touched card that need to be swapped</param> /// <param name="animationHolder">Start point of Player Animation display</param> /// <param name="isparentdistrubtioncompleted">True if Current Player all card distributed else False </param> /// <returns></returns> private IEnumerator SingleSwapAnimationFromDiscardedDeck(GameObject parent, Card touchedCard, GameObject animationHolder, bool isparentdistrubtioncompleted) { Debug.Log("Inside Single Swap Discarded Deck Animation Method"); foreach (Transform child in parent.transform) { CardUI cardUI = child.GetComponent <CardUI>(); if (cardUI.card == touchedCard) { string str = "Cards/" + cardUI.card.GetCardImageName(true); Sprite sprite = Resources.Load <Sprite>(str); var cover = Instantiate(cardUI, animationHolder.transform.position, Quaternion.identity, parent.transform); cover.GetComponent <RectTransform>().sizeDelta = new Vector2(100, 135); cover.GetComponent <Image>().sprite = sprite; var tween = cover.transform.DOMove(GameView.Instance.discardedDeckObject.transform.position, 0.5f); //https://stackoverflow.com/questions/32413067/unity2d-destroy-method-not-working-when-i-try-to-destroy-a-game-object tween.OnComplete(() => Destroy(cover.gameObject)); yield return(new WaitForSeconds(0.6f)); } } if (isparentdistrubtioncompleted) { var cardobject = GameView.Instance.discardedDeckObject.transform.GetChild(0); var animationobject = Instantiate(cardobject, GameView.Instance.discardedDeckObject.transform.position, Quaternion.identity, GameView.Instance.discardedDeckObject.transform); animationobject.GetComponent <Image>().sprite = cardobject.GetComponent <CardUI>().sprite; var tween1 = animationobject.transform.DOMove(animationHolder.transform.position, 0.5f); tween1.OnComplete(() => Destroy(animationobject.gameObject)); yield return(new WaitForSeconds(0.6f)); } Debug.Log("Single Swap Discarded Deck Animation Method Completed"); }
public void ResetCardUI(Card card) { CardUI retCardUI = card.GetComponent <CardUI>(); retCardUI.SetFace(false); retCardUI.SetSelected(false); }
public void DrawCards(int cards) { for (int i = 0; i < cards; i++) { bool _canDraw = CheckIfHandIsFull(); card = deck.drawCard(_canDraw); //Tell the deck we want a card and save it as _card if (card != null) { for (int j = 0; j < handSize; j++) //search for inactive cards in hand { CardUI _cardToUpdate = gameObject.transform.GetChild(j).GetComponent <CardUI>(); if (!_cardToUpdate.isActive) { _cardToUpdate.updateCard(card); card.OnDraw(); break; } } } else { Debug.Log("Card is null"); } } }
private void CalculateNewSpriteState(CardUI ui, out Vector2 position, out Texture2D texture, out float rotation, out float zIndex) { switch (ui.CardPosition) { case CardPosition.Player: CalculateSpriteState_Player(ui, out position, out texture, out rotation, out zIndex); break; case CardPosition.Enemy: CalculateSpriteState_Enemy(ui, out position, out texture, out rotation, out zIndex); break; case CardPosition.Desc: CalculateSpriteState_Desc(ui, out position, out texture, out rotation, out zIndex); break; case CardPosition.Deck: CalculateSpriteState_Deck(ui, out position, out texture, out rotation, out zIndex); break; case CardPosition.OutOfDesc: CalculateSpriteState_OutOfDesc(ui, out position, out texture, out rotation, out zIndex); break; default: CalculateSpriteState_OutOfDesc(ui, out position, out texture, out rotation, out zIndex); break; } }
public void OnClick(CardUI cardUI) { if (cardUI != showedCardUI) { Debug.LogWarning("Warning: clicked card isn't being shown."); UnshowCard(); ShowCard(cardUI); } if (!showedCardIsSelected && FightManager.instance.CurrentMana < cardUI.card.ManaCost) { FightManager.OnNotEnoughMana?.Invoke(); return; } showedCardIsSelected = !showedCardIsSelected; if (!showedCardIsSelected) { UnshowCard(); FightManager.instance.OnUnselectedHandCard(); } else { selectedCardRaycastBlocker.SetActive(true); FightManager.instance.OnSelectedHandCard(cardUI.card); } }
public void OnPointerExit(CardUI cardUI) { if (showedCardUI == cardUI && !showedCardIsSelected) { UnshowCard(); } }
public void CardClicked(CardUI cardUI) { if (currentState == PlayerSelectionState.SelectCard) { if (currentCardSelected == cardUI) { currentCardSelected = null; } else { currentCardSelected = cardUI; if (currentCardSelected.Card.TargetsNeeded > 0) { currentState = PlayerSelectionState.SelectTarget; } else if (currentCardSelected.Card.TargetsNeeded == -1) { targetsSelected.AddRange(Enemies); CastCard(); } else { CastCard(); } } } }
public void DrawPlayerAtRight() { int cardcount = PlayerUIMapping.Instance.cardholder[5].transform.childCount; if (GameController.Instance.GetCurrentPlayer() == GameController.Instance.players[5]) { PlayerUIMapping.Instance.turnIndicators[5].SetActive(true); PlayerUIMapping.Instance.timerObjects[5].SetActive(DataManager.currentGameMode == GameMode.MultiPlayer ? true : false); if (GameController.Instance.players[5].timeRemaining > 0) { GameController.Instance.players[5].timeRemaining -= Time.deltaTime; PlayerUIMapping.Instance.timerDisplay[5].text = GameController.Instance.players[5].timeRemaining.ToString("F0"); } } else { PlayerUIMapping.Instance.turnIndicators[5].SetActive(false); GameController.Instance.players[5].timeRemaining = Constants.maxTimer; } bool showCardFace = GameController.Instance.players[5].GetShowCard(); if (cardcount == 0) { int decksize = GameController.Instance.players[5].GetDeck().CardsCount(); for (int i = 0; i < decksize; i++) { Card currentCard = GameController.Instance.players[5].GetCardByIndex(i); GameObject vector2 = Object.Instantiate <GameObject>(this.cardPrefab, PlayerUIMapping.Instance.cardholder[5].transform); vector2.transform.localRotation = Quaternion.Euler(Vector3.zero); float totalWidht = PlayerUIMapping.Instance.cardholder[5].GetComponent <RectTransform>().sizeDelta.x; string str = "Cards/" + currentCard.GetCardImageName(showCardFace); Sprite sprite = Resources.Load <Sprite>(str); vector2.GetComponent <CardUI>().sprite = sprite; vector2.GetComponent <CardUI>().card = currentCard; CardUI cardUI = vector2.GetComponent <CardUI>(); vector2.GetComponent <Image>().sprite = vector2.GetComponent <CardUI>().sprite; vector2.transform.SetParent(PlayerUIMapping.Instance.cardholder[5].transform); } } else { int i = 0; foreach (Transform child in PlayerUIMapping.Instance.cardholder[5].transform) { Card currentCard = GameController.Instance.players[5].GetCardByIndex(i++); if (currentCard != null) { string str = "Cards/" + currentCard.GetCardImageName(showCardFace); Sprite sprite = Resources.Load <Sprite>(str); child.GetComponent <CardUI>().sprite = sprite; child.GetComponent <Image>().sprite = sprite; } } } }
private async void SendCardToEnemy(object sender, CardUI e) { CardToSend.Add(e.Card); if (CardToSend.Count == 2) { await controler.WysyłanieMuskuAsync(CardToSend); } }
public override CardUI GetCard(KeyValuePair <List <Karta>, List <CardSocketUI> > from, KeyValuePair <List <Karta>, List <CardSocketUI> > to, Karta target) { CardUI cd = new CardUI(target); cd.Miejsce = menu.startPosytionCard; menu.AddCard(cd); return(cd); }
private void Update() { if (UI.Count > 0) { CardUI cardUI = UI.Dequeue(); cardUI.Target(FindPlayer(cardUI.ConnID).connectionToClient, FindPlayer(cardUI.InstanceID).netId); } }
public void deselectCard() { if (selectedCard == null) return; selectedCard.setZoom (false); selectedCard = null; deselectSlot (); }
/// <summary> /// 创建卡牌预设 /// </summary> /// <param name="card"></param> /// <param name="index"></param> public void CreateCardUI(Card card, int index, bool selected) { GameObject go = PoolManager.Instance.GetObject("Card"); CardUI cardUI = go.GetComponent <CardUI>(); cardUI.Card = card; cardUI.IsSelectes = selected; cardUI.SetPosition(CreatePoint, index); }
static void AddToList(CardUI cardUI) { if (CardUI.dragSelectUI.Contains(cardUI)) { return; } CardUI.dragSelectUI.Add(cardUI); cardUI.image.color = Color.gray; }
private void AddCards() { CardUI.Cards json = JsonUtility.FromJson <CardUI.Cards>(jsonFile.text); foreach (CardUI.CardData card in json.cards) { CardUI.AddCard(card, panel, cardPrefab); } }
void cardUI_OnPointerEnter(CardUI cardUI) { //only if enabled if (_enabled) { //set to apropriate index SetFocusIndex(cardUI._Index); } }
void AddCard(CardData data) { Clear(); GameObject card = Instantiate(cardPrefab); CardUI script = card.GetComponent <CardUI>(); script.Data = data; card.transform.SetParent(parent, false); }
void HandlePlayerDeckCardClicked (CardUI cardUI, Transform contentPanel) { availableCards.Add(cardUI.Card); GameManager.Player.cards.Remove(cardUI.Card); cardUI.transform.SetParent(contentPanel, false); cardUI.cardButton.onClick.RemoveAllListeners(); cardUI.cardButton.onClick.AddListener(() => HandleMainDeckCardClicked(cardUI, playerDeckContentPanel)); if (GameManager.Player.cards.Count(c => !c.used) < GameManager.maxCardsPerPhase) { mainDeckCanvasGroup.alpha = 1f; mainDeckCanvasGroup.interactable = true; readyButton.interactable = false; } }
void cardUI_OnPointerEnter(CardUI cardUI) { //only if enabled if (_enabled) { //set to apropriate index SetFocusIndex (cardUI._Index); } }
public void DeselectCardNoPopdown(int index) { m_SelectedCardUI = null; OnCardDeselect(); }
void cardUI_OnPointerExit(CardUI cardUI) { //only if enabled if (_enabled) { //set the focus index to non (-1) SetFocusIndex (-1); } }
public void SelectCard(int index) { if (m_SelectedCardUI != null) m_SelectedCardUI.PopDown(); m_SelectedCardUI = m_Cards[index]; m_Cards[index].Popup(); //event OnCardSelect(); }
public void DeselectCard(int index) { m_Cards[index].PopDown(); m_SelectedCardUI = null; OnCardDeselect(); }
void cardUI_OnPointerUP(CardUI cardUI) { //only if enabled if (_enabled) { //pop the card in or out if (cardUI == m_SelectedCardUI) { DeselectCard (cardUI._Index); } else { SelectCard (cardUI._Index); } } }
void Awake() { TheCardUI = this; gameObject.SetActive(false); }
public virtual void Initialize(bool alreadyDiscarded) { useGUILayout = false; cardUI = gameObject.GetComponent<CardUI> (); cardSFX = gameObject.GetComponent<CardSFX> (); playerObj = GameObject.FindGameObjectWithTag("Player"); // Initialize card variables ThisLibraryCard = CardLibrary.Lib[CardName]; name = CardName; CardName = ThisLibraryCard.CardName; DisplayName = ThisLibraryCard.DisplayName; IconPath = "sprites/card icons/" + ThisLibraryCard.IconPath; Tooltip = ThisLibraryCard.Tooltip; DisplayText = ThisLibraryCard.DisplayText; MiniDisplayText = ThisLibraryCard.MiniDisplayText; rangeTargetType = ThisLibraryCard.RangeTargetType; minRange = ThisLibraryCard.rangeMin; maxRange = ThisLibraryCard.rangeMax; aoeTargetType = ThisLibraryCard.AoeTargetType; aoeMinRange = ThisLibraryCard.aoeMinRange; aoeMaxRange = ThisLibraryCard.aoeMaxRange; ThisRarity = ThisLibraryCard.ThisRarity; CardAction = ThisLibraryCard.CardAction; God = ThisLibraryCard.God; if (!alreadyDiscarded) { S.GameControlInst.Hand.Add(gameObject); } switch (ThisRarity) { case Card.Rarity.Gold: Cost = 10; break; case Card.Rarity.Silver: Cost = 6; break; case Card.Rarity.Bronze: Cost = 3; break; case Card.Rarity.Paper: Cost = 0; break; } cardUI.Initialize (alreadyDiscarded); cardSFX.PlayDrawCardSFX(); }
public void startGame() { StopAllCoroutines (); nextButton.endFlash (); resetButton.endFlash (); //Get rid of all currently existing cards if( handCards != null ) foreach (CardUI card in handCards) Destroy (card.gameObject); selectedCard = null; selectedSlot = -1; //Get rid of effects, including board cards foreach (GameObject obj in GameObject.FindGameObjectsWithTag("effect")) { Destroy (obj); } animsRunning = 0; //Set up energy meter meterScript.setCurrent (0); levelBest = PlayerPrefs.GetInt( currentLevel.hand ); //Gets 0 if the key doesn't exist int goal = ( levelBest > currentLevel.energyGoal && currentLevel.bonusGoal != -1 ) ? currentLevel.bonusGoal : currentLevel.energyGoal ; meterScript.setMax( goal ); meterScript.maxEnergyText.text = "" + goal; meterScript.setFlagHeight (currentLevel.energyGoal); meterScript.trophyImage.SetActive (currentLevel.bonusGoal != -1 && levelBest >= currentLevel.bonusGoal); meterScript.flagImage.SetActive (levelBest >= currentLevel.energyGoal); meterScript.setGhost (levelBest); Color c = getMeterFillColor (levelBest); c = new Color (c.r, c.g, c.b, 100f/255); meterScript.meterFillGhost.color = c; meterScript.meterFill.color = meterScript.normalFillColor; //Set slots to default state for (int i = 0; i < BoardManager.MAX_UNITS; ++i) setSlotColor (i, slotActiveColor); //Determine the starting hand string[] handCodes; handCodes = currentLevel.hand.Split (); //Create the hand cards handCards = new List<CardUI> (); foreach (string code in handCodes) { newHandCard (code, handSpawnPos.position); } StartCoroutine (setHandPositions ()); //Display level messages if (currentLevel.messages != null) msgManager.messageBox (currentLevel.messageTitle, currentLevel.messages); else msgManager.close (); //Create the Board Manager GameCard[] cards = new GameCard[handCodes.Length]; for (int i=0; i<handCodes.Length; ++i) { cards[i] = GameCard.findByCode(handCodes[i]); } theGame = BoardManager.newGame(cards, this); }
public void onDragRelease() { //Attempt to play the card if ( selectedSlot != -1 && slotsPlayable [selectedSlot] && theGame.playCard( handCards.IndexOf(selectedCard), selectedSlot ) ) { //Update meter meterScript.setCurrent( theGame.getEnergyTotal() ); if( !theGame.actionsInQueue() ) saveLevelScore(); //Set slots to inactive state (can't play additional cards yet) //(unless the action queue is already empty) if( theGame.actionsInQueue() ) for( int i = 0; i < buildSlots.Length; ++i ) setSlotColor( i, slotInactiveColor ); //Remove the card from our hand handCards.Remove(selectedCard); adjustColumn(selectedCard.handColumn, true); //Deselect and destroy the card //TODO: Add a card play animation (turns white or something?) Destroy( selectedCard.gameObject ); deselectSlot(); selectedCard = null; } else { selectedCard.flyTo( selectedCard.snapPos, CARD_FLY_SPEED, CARD_FLY_DAMP_DIST ); deselectSlot(); selectedCard = null; } }