public override void OnInspectorGUI() { CardUnityBase target = serializedObject.targetObject as CardUnityBase; DrawDefaultInspector(); Rect textureRect = EditorGUILayout.GetControlRect(false, target.sprite.texture.height); textureRect.y += 16f; textureRect.x = 16f; EditorGUI.DrawPreviewTexture(textureRect, target.sprite.texture, null, ScaleMode.ScaleToFit); }
// public void AddCard(string cardName, int add = 1){ // CardCollectionEntry entry = FindByName(cardName); // if(entry != null){ // entry.amount += add; // } else { // cardCollectionEntries.Add(new CardCollectionEntry(Resources.Load<CardUnity>($"CardData/{cardName}"), add)); // } // } /// <summary>Removes an amount of the supplied card.</summary> /// <returns>True if a card was removed, false if not.</returns> public bool RemoveCard(CardUnityBase cardToRemove, int remove = 1) { CardCollectionEntry entry = FindByName(cardToRemove.cardName); if (entry != null) { entry.AmountMax = Mathf.Clamp(entry.AmountMax - remove, 0, entry.AmountMax); return(true); } else { return(false); } }
public void AddCard(CardUnityBase cardToAdd, int add = 1) { // Debug.Log($"Trying to add card {cardToAdd.ID} to collection"); CardCollectionEntry entry = FindByName(cardToAdd.cardName); if (entry != null) { entry.AmountMax += add; } else { cardCollectionEntries.Add(new CardCollectionEntry(cardToAdd, add)); } }
public void SetupCardUI(CardUnityBase baseCard) { // Debug.Log($"Setting up ui card for {baseCard.cardName}", baseCard); if (card != null) { card.UnlinkUICard(this); } card = baseCard; if (cardImage == null || cardButton == null || rectTransform == null) { Awake(); } cardImage.sprite = card.sprite; gameObject.name = baseCard.cardName; PositionAmountGroup(); baseCard.LinkUICard(this); }
public void ModifyCollection(CardUnityBase card = null, /* string cardName = "", */ bool add = true, int change = 1) { if ((card == null /* && cardName.Length < 1 */) || change < 1) { return; } // if(cardName.Length > 0){ // if(add) // AddCard(cardName, change); // else // RemoveCard(cardName, change); // } else { if (add) { AddCard(card, change); } else { RemoveCard(card, change); } // } }
public CardCollectionEntry(CardUnityBase slotCard, int newAmount) { card = slotCard; amountMax = newAmount; identifier = card.ID; }