Search Unity

KINGS - Card Swiping Decision Game Asset

Discussion in 'Assets and Asset Store' started by Maulwurfmann, Nov 26, 2017.

  1. interpretasyo

    interpretasyo

    Joined:
    Jun 18, 2019
    Posts:
    33
    Hi,

    Sorry, if I didn't try to explain that much. Actually, we already have the share function. Now we wanted to share the text on the card if I press the share button. But how are we going to refer to that text in the card?
    So, similar thing, for the character menu, there is a description there. We also wanted to refer to that character description and use it for the share function.
     
  2. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi,
    I wrote a script which could access the question text from anywhere (gif):
    GetCardTexts.gif
    The script can be extended to get the other texts (left, right etc.) from the actual spawned card. I attached the script "GetCardTexts.cs" to this post. Regarding the character menu: I also don't know how to access it at the moment. I will reply later.
    Until then, I hope this helps.
     

    Attached Files:

  3. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    @interpretasyo

    Regarding the character description

    Not the nicest solution, but should work for your case:
    I extended the existing script "valueDependentTexts" which generates the character description. It now is able to return the actual text as string by calling the public method "GetValueDependentText()"
    I attached the script, please overwrite the existing one. Don't forget to backup your project first.

    I added an example for accessing, see attachements.
    To access this method you have to reference to the existing script in your Hierarchy:
    Example_GetTextFromValueDep.PNG

    I hope this helps.
     

    Attached Files:

  4. interpretasyo

    interpretasyo

    Joined:
    Jun 18, 2019
    Posts:
    33
    Hi,

    Thanks, this is working. You're really great.
     
  5. interpretasyo

    interpretasyo

    Joined:
    Jun 18, 2019
    Posts:
    33
    Hi,

    For this one, I don't understand the variable 'value'
    Code (CSharp):
    1.     float value = 0f;
    2.  
    3.     public string GetValueDependentText()
    4.     {
    5.         //get through the list to get the new text
    6.         string text = "";
    7.         for (int i = 0; i < valueDependingTexts.Length; i++)
    8.         {
    9.             if (value >= valueDependingTexts[i].minValue)
    10.             {
    11.                 text = TextReplacement.TranslateAndReplace(valueDependingTexts[i].text);
    12.             }
    13.         }
    14.  
    15.         return text;
    16.     }
    Just want to clarify, that the character description is already set. It's just that we want to retrieve that value.
    I don't get how willl the 'value' change its value. When I debug, it has always a fixed value. Because of this, I'm not able to retrieve the current character description.
     
  6. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi interpretasyo,

    Yes and no :) . You are right, there's a bug in there. Unfortunately it is not correct to take the text from the character description text field, because it is not guaranteed to be actualized. I also thought about making an example how to retrieve the text from the existing text field, but it is programmed to actualize only if the GameObject was activated once. When the panel was not activated once the default string would be returned.
    I added this method to actualize the string and return it without the need to activate the gameObject first.

    Regarding the bugfix, I attached the corrected script. I was missing, like you mentioned, the actualization of the variable "value".

    Because I have a spare minute, some side information:
    The character (or rather the "Name" as defined in "valueDefinitions.cs") is stored as a "value", this can be seen as a key. E.g. the seconde character has the number 1 (if you are counting from 0). For the character selection screen there are also some different values set, like surename, gender etc.:
    characterSelection.PNG
    The existing script "valueDependentTexts.cs" does following: depending on this number it shows a text, in this particular case the character description. Because the information is stored as value you can do other tricks. Because it's a value, this can be used in the conditions for sub card stacks to unlock different cards.
    Another possibility without using numbers to identify the characters would be using the dictionary, but this was introduced in a later version of Kings and if it had been changed it would have disturbed existing builds.

    "valueDependentTexts.cs" can also be used to do some other neat things. It supports ranges to generate texts, the left numbers are used as minimal values when the text will be shown. Heres an example for "People" to show their state from Poor (0-24.9), OK(25-74.9), Good(75-90) to Excellent (90 and bigger):
    ValueDependentTexts.gif

    I hope this helps.
     

    Attached Files:

  7. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Hey again!

    I've run into some confusion. I am trying to make it so that players can get an "item" when they defeat a monster, and also monster cards will check if they have that item and award more value if they are defeated while the player has that item. I also this item's effect to stack so if the player gets 3 of the item, they get 3x the bonus.

    Problem 1: I can't get multiple MakeChanges scripts to run at the same time. I thought I could have 3 MakeChanges scripts, one that would detect for > 0 of the item, the next for > 1, and one for > 2 of the item. This way a player could stack the effects of all three. This was a workaround though, my ideal would be that the player is rewarded for each item without having to place an artificial cap of 3. I made a cap because I didn't want to have to make potentially dozens of MakeChanges scripts for every incriment of 1 :(

    Problem 2: My items don't reset to 0 after my game finishes. I would like this to be the case... or even better I would like to have some be reset and some remain.

    Problem 3: When the player receives an item, the icon is too small and the I don't know where to edit the settings for the pop-up, the item icon, or the item details (all three linked in the attachments with red circles).

    Sorry for doing three in one post, but I figured I'd rather give you all the info.
     

    Attached Files:

  8. interpretasyo

    interpretasyo

    Joined:
    Jun 18, 2019
    Posts:
    33
    Thank you. You are really the best.
     
    KMDeclius likes this.
  9. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Sorry I forgot about this special behaviour of Unity.
    The simplest way to workaround this is to put each script of the same type to an empty gameObject on the card and linking them in:
    multibleMakeChangesOnOneCard.PNG
    I personally would reset the items when the game ends:
    ResetItemsOnGameOver.PNG
    Let me explain the scrip calls for this:
    1. The GameStateManager can fire an event if the game is over.
    2. There you can call a make changes script. I made an extra gameObject because of the same reason as on your card.
    3. This script can set the number of Items to an specific amount. If you want to delete them, set it to 0.

    I'm not really sure what the reason for this behaviour is. Some questions here, I hope they lead in the right direction:
    Could you post this particular image so I can test it?
    Did you try to use an image with higher resolution?
    Did you try different import settings for this image?
    Does your image have an invisible border so the actual content get scaled down?

    Regarding the place to edit the image setting:
    ItemPrefabs.PNG
    There are several prefabs for the items. One for the popup, one for the minimal view etc.
    The prefab itself has only dummy images attached, the actual image for the item are replaced from the data of the item definition when the prefab is instantiated.

    I hope this helps.
     
  10. interpretasyo

    interpretasyo

    Joined:
    Jun 18, 2019
    Posts:
    33
    Hi,

    The SelectKing card is where we select the King. We tried to change the icon in that card and it now shows correctly. But in the character description screen (in where we see that stats), it's showing different icon. How to connect them so that what we select is what we will see in the character description?
     
  11. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi,

    The images shown in the character description scene is generated similar to the value dependent texts. It is depending on the values which were set when selecting the character:
    charSelectionValues.PNG

    Theres a script which can replace images depending on a condition (here: is the character a male of female) and then depending on another range (here: the surename) select the according image. It's called "ValueDependentConditionalImages" - phu, a really long name :)
    The 4 already defined images are linked there, it is located under
    Hierarchy->MenuCanvas->MenuPanel->PlayerInfoPanel->PlayerImageDescription->PlayeImage :
    CharacterImage.PNG

    I will describe what it does:
    Depending on a condition (here: Gender == 1 for female) it selects two sprite sets.
    From a Modifier Value (here: surname) it selects ranges for images.
    E.g. the Gender is female and the surename is with id 3 it selects the sprite queen2. The Numbers on the left are ranges from where the sprite will be selected, very similar like the value depending text described earlier on this page.

    The script would also allow for your own values, which you can define and set when clicking the selection buttons. The modifier value could be adjusted accordingly. The actual logic was adjusted this way, to be able to handle the randomized character selection below the character selection buttons and output valid images.

    if the logic is not clear and you want to use the existing logic you could also just replace the existing linked images.

    I hope this helps.
     
  12. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Hi there!

    Quick question. The swipe background is currently white and the text is white as well. I can clearly see how to change the color of the text on the "AnswerLeft" object for example, but I don't see anywhere to change the background color. Any ideas?
     
  13. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Also, one more quick question... it's driving me insane! I can't figure out why one of my cards is slight offset on the Y axis!!! To my understanding all of it's Y-axis positions are set to 0 but the card refuses to change positions. So I looked into the animation thinking that maybe the animation is changing it's position, but still I couldn't find anything wrong with it! I highlighted the problem in a red circle, obviously it should be a bit higher but won't move no matter what I do :(:(:(.
     

    Attached Files:

  14. interpretasyo

    interpretasyo

    Joined:
    Jun 18, 2019
    Posts:
    33
    This is actually what I'm looking for. I know that you have this but I just can't find it. Thank you so much for explaining it.
     
    KMDeclius likes this.
  15. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    @Chekmate
    There are two possiblities for changing the card color.
    Default for Kings is with the style definitions attached to this card,
    but in the previous page of this forum you mentioned you removed it from the cards.
    If this is the case, the background color is no longer controlled and can be changed directly for the background image:
    ChangeCardColorWithoutStyles.PNG
     
  16. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    No sorry, not the card color. The background color of the gradient that drops down when you swipe, screenshot attached for clarity.
     

    Attached Files:

  17. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    @Chekmate
    Regarding your second issue, you are correct, the position is driven by the animator. For your image you used the 4-way swipe card, this has its own 2-dimensional blend tree because you can swipe horizontally and vertically.
    The Animation itself consists of 9 animation clips which are blended.
    To select the clip in question, you can click on it in the blend tree itself and also edit it. I think this is one of the few elements you can edit in play mode, which makes it easier.
    I made a short gif for this, to follow itplease open the windows "Animation" and "Animator" before:
    FourWaySwipeAnimatorSmaller.gif

    I hope this helps.
     
  18. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Regarding the background color of the answer.
    Try editing the image color of the gameobject "AnswerBack" in the prefab:
    ColorAnswerBack.PNG
    The transparency of the color seems like it is controlled from an animator.

    Again, I hope this helps.
     
  19. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Yes that was very helpful! Thank you!
     
    KMDeclius likes this.
  20. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Hey there!

    I've got two more issues that I can't seem to figure out:

    1) I created a couple UI icons that I want to display on the top panel, but when I place them on the default layer (sorting layer 1) they appear on the UI, but also appear during the playerSelect screen (see attached). How do I have them not show up on that screen while still having them show up in the UI? Also, is there a safe way to remove the player select screen? I don't think I actually want it, but am afraid of what might happen to the rest of the game if I delete it...

    2) I'm also having an issue figuring out how to change the StatImgs on the the UpdatedStatsPanel. As you can see in the screenshot, I have them set to display a coin, but every time I launch the game it still shows up as the green crown icon.

    There's no rush to get back immediately, I know we're all dealing with some pretty strange global circumstances at the moment. Stay safe.

    Cheers.
     

    Attached Files:

  21. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi Chekmate,

    I have to do a litte bit of guessing work.
    The Icons are depending on the hierarchy. Be shure to put them as child of the TopPanel. If the TopPanel moves or is hidden, the childs will also move or be hidden. This is called "Parenting". The order of the sibling game objects is also the order they are drawn:
    objectHierachy.PNG
    In this example I created the game object "MyNewIcons" which are children of the "TopPanel" game object. They are last in the order and therefore should be drawn last. The last drawn object is visually on top. I usually don't use layers for this.

    Regarding the player select screen: I also have to test what happens. If you want to test it, make a back up from your project first. But I will test it when I have free time (perhaps tomorrow).

    The slider consist of more than one image, if you look at the examples theres an background image and a fill image which is drawn after. The fill effect is achieved by cropping the image correctly. You have to replace both images, in your example the background image is not replaced:
    SliderBgAndFill.PNG

    Well said. Stay safe.
     
  22. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Ha! I was just typing this when you made your reply! I made the UI icons into empty game objects with an image component and that seemed to work, previously I was just dragging the sprite into the scene. Thanks for the reply, I'll look into fixing number 2 now.
     
  23. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Your answer for number 2 seems to talk about the sliders, but what about the images in the UpdatedStatsPanel. Is it the same? They don't have Fills like the sliders do.
     

    Attached Files:

  24. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    I'm sorry I misread your post. Here it's 1 o'clock in the night and I should go to sleep :p
    The images on the object you changed are only place holders. There are several dummy imgages to be able to show multible changes at once. They will be replaced by the image which is assigned to an value. The image is linked at the script "valueScript":

    ActualizationImage.PNG

    I hope this helps. Gn8.
     
  25. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi Chekmate,
    regardining the player select screen: The player select screen itself is a card. Simply remove its prefab from the "MainMenuCard" game object as follow up card (twice):
    RemoveSelectKingCard.PNG

    Then the game should start directly without this screen.

    There should be no negative draw back, exept the values "name","gender","country" etc. will stay at 0.
    The screens which show player information stay, you could simply hide them in the hirarchy (not 100% shure, but it should work).

    I hope this helps. Keep well.
     
  26. BOOMCAT1981

    BOOMCAT1981

    Joined:
    Jul 28, 2018
    Posts:
    37
    Hi
    I don't know how to set the UpdatedPanel in the same problem,when I change the UpdatedStatPanel>Stat1mg this image then run the game it will none to change

    So, how to change this icon in UpdatedStatPanel?

    Cheers.
     

    Attached Files:

  27. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi,
    I answered that, sorry I made it not clear. Heres the important part:

    [Edit] Too fast submit.
    Don't alter the images in the hierarchy. Change it per value so each value can have its own update image.

    I hope this help. Tell me if theres an issue or I misunderstood something. Keep well.
     
  28. BOOMCAT1981

    BOOMCAT1981

    Joined:
    Jul 28, 2018
    Posts:
    37


    。。。。well I mean this panel (UpdateStatPanel)it still can't change when I modified any Icon or text in this panel (Post 1)
     
  29. BOOMCAT1981

    BOOMCAT1981

    Joined:
    Jul 28, 2018
    Posts:
    37
    。。。。well I mean this panel (UpdateStatPanel)it still can't change when I modified any Icon or text in this panel (Post 1) and when I run the game (all has been modified icons are disappear and the panel will reset all icons (post2)

    I don't know if this description is right or not. Simply speaking, these contents can't be adjusted according to your screenshot method, at least in this panel.

    cheers
     

    Attached Files:

  30. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    @BOOMCAT1981
    For me it works actualizing the images for the UpdateStatPanel for each value, like the last screenshot I linked.
    I made an short gif to enshure we are talking about the same thing:

    ChangeImagesOfUpdateStats.gif

    The icons are automatically replace by scripts if a value changes (= a stat was updated).
    The images in the UpdateStatPanel are only itself are only place holders.

    [Edit] Sorry, the gif is a little bit fast. The gif also shows how to link an image per value (stat).

    I hope this helps.
     
  31. BOOMCAT1981

    BOOMCAT1981

    Joined:
    Jul 28, 2018
    Posts:
    37
    Thank you for your detailed reply.

    Form my stupid way out these issues :p

    1) I saw your GIF and know that different issues from the game mode (mode vertical & mode landscape)

    2)from vertical mode the UpdateStatPanl locks the Icons position, So I have been a change uncheck the box 【Horizontal Layout Group】 (post 1)then I can easy to modify (including the Img and position)
     

    Attached Files:

  32. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Quick question! If I have cardstyles turned off, which text boxes do I actually need to change when I make new cards; the text boxes in the parent, the text boxes in the children, or both? The text boxes don't seem to always accurately reflect my changes when I change just one of them so it's hard to nail down the problem.
     
  33. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    One more thing... right now I have a card set up to be a follow up, then on that follow up card I have a condition set to only be drawn if that condition is met, however it appears that follow-up overrides condition, or that the condition only matters when being drawable from the deck? (Maybe those are the same things haha). Is there any way that I could get this to work the way I want? I want a follow-up card to be drawn under a certain condition, else it is ignored.
     
  34. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    It's not clear to me what you mean with text boxes in the parent or the children.
    Regardless of card styles, the content of the text fields is controlled from the eventScript.
    If you have additonal text fields and want them to be translated or use the feature of text replacement, you should propably link them into the "additonal texts" field. A base text and a link to the text field itself is required here.
    CardTextFields.PNG


    For follow up cards, the conditions on the following card itself are ignored.
    If you only want a follow up card to appear on a certain condition then define the condition on the card before (result condition). This case is covered in the documentation on page seven with the marriage example. For the conditional branches (true or false) only defined follow up cards will be drawn. If it's not defined, the game will continue as usual.

    I hope this helps.
     
  35. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    I think I understand you on both points. My terminology might be wrong so please forgive me if it was unclear, I'm still learning Unity terminology. I'll attach an image to help clarify this point and then I will try to help you understand what I'm trying to do with my 2nd point in another post, because I don't think your solution works in my case (but I could be wrong).
     

    Attached Files:

  36. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    The way I have set my battle system up is this:

    1. You encounter an enemy and can "attack" them with the 4-way choice.
    2. If your stats are higher than the random condition of the enemy's stat type you chose to attack, you win! Swiping left or right both reward you with a value bonus and some gold.
    3. If you don't already own the enemy that you defeated, you capture them as an item in your inventory.

    My worry is that if I set up a condition for "If you don't already own the enemy that you defeated" on a previous card, I will lose out on the value bonus and gold from step 2 as part of the condition as well. Am I wrong? Perhaps I'm misunderstanding something?

    Cheers!
     

    Attached Files:

  37. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Thank you for the information, your target behaviour was not clear to me.
    There are several ways to achive this.

    With the existing asset:

    The simplest would be to use conditions on your victory card to select your follow up card and give your bonus to the player if the victory card despawns:
    ConditionalFollowUp.PNG
    This only works if the bunus you give to the player is independent of the swipe direction.

    But if you want to give a different bonus, depending on swiping left or right and still use the conditions for the follow up card:
    Add two "MakeChanges" script in single game objects and trigger them by the events. E.g.:
    ConditionalFollowUp_withDifferentSwipeResults.PNG

    With some additional scripting:
    As an alternative I made a (quick and dirty, without any coments) script where you can put conditions for follow up cards independently of the event script.
    Usage:
    Add it on your card and call it from the "OnCardDespawn" event:
    ConditionalFollowUpCardScript.PNG
    I attached the script "ConditionalFollowUpCard", put it into your project before using it.
    The script was tested partially but not in each combination. If the event script already defines a follow up card, it will be overwritten by this new script.

    I hope this helps, feedback is welcome.
     

    Attached Files:

  38. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    This helps a bunch! I appreciate you taking the time to do some quick scripting, but I think the first solution should suit my needs! I'll test it out soon, thanks again!
     
  39. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Hey there!

    Is there a simple way for me to limit the number of items a player can hold in their inventory at one time? In my game, items do not stack (they all have a max of 1). I have extended the panel to hold 7 items at once, however if you acquire an 8th item, it goes into your inventory anyway which is undesirable for me. The preferred behavior would be if the item was NOT put into the inventory if the player had no free slots. It would be good if the player was warned first before they lost the item as well... but that might be a problem for another time.
     

    Attached Files:

  40. AxelCasauran

    AxelCasauran

    Joined:
    Dec 3, 2016
    Posts:
    5
    Hello,

    When will be the next update?
    Is it possible to place GIF rather than image? How about Video?

    Thank You
    Stay Covid-19 Safe
     
  41. BOOMCAT1981

    BOOMCAT1981

    Joined:
    Jul 28, 2018
    Posts:
    37
    Hi
    1) How to make the CardStack that can continuously loop infinitely?
    2) How to avoid triggering the fallback_gameover event (when No Card)

    thank you
     
  42. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi,

    @Chekmate : An limited inventory panel was discussed at page 12 with @interpretasyo, two different solutions are there
    1. you could make your inventory UI scrollable to hold more Item types
    2. you could add the patch, were the different item count is put to an value. With this value you can prevent the e.g. the card which gives you items from spawning.

    @AxelCasauran :
    1. At the moment I focus on solving individual requests of users. At some point I should update the Asset, but I have no concrete shedule for this.
    2. Kings strongly relies on Unity. The cards are prefabs with canvas, if you put an Unity compatible element on it (this is a Unity task) then it should play. I did a quick search and found this example which describes the inserting a video or gif in unity on a button (which is similar to the game objects with RectTransforms used in cards). I didn't test it myself.

    @BOOMCAT1981 :
    The CardStack should repeat almost infinitely until there are no more criteria that fit the cards or the game is over. If there are no cards left due to your conditions, it is empty and the replacement card is drawn.
    To avoid both problems: Make sure that there are some cards that can be drawn under all circumstances, such as
    • add some cards that have no conditions on the card
    • be sure that you have a subcard pile with no conditions
    • reduce the number of draw blocks per card (see: eventScript), this will block a card that should be drawn again within 'n' moves
    • increase the maximum allowed draws per card ( see: eventScript )
    • create more cards
    I hope this helps, feedback is welcome.
     
    BOOMCAT1981 likes this.
  43. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    I followed the steps from page 12, but I am still receiving over the number of items that I have set to be my maximum. Screenshot attached, is there something I did wrong?
     

    Attached Files:

  44. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Also, since importing the new inventory script, I am now getting this error:

    SocketException: An attempt was made to access a socket in a way forbidden by its access permissions.

    System.Net.Sockets.Socket.Bind (System.Net.EndPoint localEP) (at <c9226b2f33b7421e85bb391f94075e49>:0)
    SyntaxTree.VisualStudio.Unity.Messaging.UdpSocket.Bind (System.Net.IPAddress address, System.Int32 port) (at <8a9a886d1faa4d4992c674a8ac391afd>:0)
    SyntaxTree.VisualStudio.Unity.Messaging.Messager..ctor (System.Int32 port) (at <8a9a886d1faa4d4992c674a8ac391afd>:0)
    SyntaxTree.VisualStudio.Unity.Messaging.Messager.BindTo (System.Int32 port) (at <8a9a886d1faa4d4992c674a8ac391afd>:0)
    SyntaxTree.VisualStudio.Unity.Bridge.VisualStudioIntegration+<>c.<.cctor>b__4_0 () (at <1c5e759f86f34c21831610c2b42933f9>:0)
    SyntaxTree.VisualStudio.Unity.Bridge.Project+<>c__DisplayClass40_0.<RunOnceOnUpdate>b__0 () (at <1c5e759f86f34c21831610c2b42933f9>:0)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:200)
     
  45. BOOMCAT1981

    BOOMCAT1981

    Joined:
    Jul 28, 2018
    Posts:
    37
    thank you
     
    KMDeclius likes this.
  46. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi,
    sorry I was not clear on this point.
    You should not limit the value, keep the maximum high.
    The idea is another: In your game, at some point you made an condition where your follow up card ("recruit") for getting an Item is drawn if the item of one type is not below 1. You could add another condition here: If the value "DifferentItems" is below 7.
    If you have more than one condition, all must be true.
    I hope I understand your game logic enough, this is still an suggestion from me.

    Additional:
    I adjusted the Inventory script (attached) to allow an max. number of different items. If the max was reached I fire the general event "OnItemsMax". I also fire the event (per item) "itemsOverMax". See following picture
    Inventory_MaxItemCount.PNG

    Regarding the errors you get:
    This seems like Unity errors. This could happen if you replace the script while Unity is opened. Are the errors still there after you restarted Unity? If they are still there, you could try to delete the file "Inventory.meta" in the same folder as the Inventory script. This file will be regenerated by Unity automatically.

    And like always: don't forget to make Backups of your project.

    I hope this helps. Gn8.
     

    Attached Files:

  47. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    Hi again!

    Your post was very helpful and I managed to get things working :) However, I am getting a bunch of warnings regarding "Multiple values of the same type detected". Here is on example, but it happens dozens of times when I boot up the game:

    Multiple values of the same type detected: differentitems
    UnityEngine.Debug:LogWarning(Object)
    valueManager:setValue(values, Single) (at Assets/Kings/scripts/valueManager.cs:266)
    Inventory:inventoryChanged(Boolean) (at Assets/Kings/addons/Inventory/Scripts/Inventory.cs:532)
    Inventory:AddItemAmount(InventoryItem, Int32) (at Assets/Kings/addons/Inventory/Scripts/Inventory.cs:413)
    Inventory:SetItemAmount(InventoryItem, Int32) (at Assets/Kings/addons/Inventory/Scripts/Inventory.cs:429)
    Inventory_ChangeItem:executeItemChange(itemModifier) (at Assets/Kings/addons/Inventory/Scripts/Inventory_ChangeItem.cs:36)
    EventScript:executeExtraChanges(C_AdditionalModifiers[]) (at Assets/Kings/scripts/EventScript.cs:1007)
    EventScript:executeValueChanges(modifierGroup, Boolean) (at Assets/Kings/scripts/EventScript.cs:968)
    EventScript:ComputeResultTypeDependant(result, Boolean) (at Assets/Kings/scripts/EventScript.cs:696)
    ConditionsAndEffects:ComputeEffects(C_Changes) (at Assets/Kings/scripts/ConditionsAndEffects.cs:47)
    C_Changes:ExecuteEffect() (at Assets/Kings/scripts/ConditionsAndEffects.cs:32)
    MakeChanges:ExecuteEffect() (at Assets/Kings/scripts/MakeChanges.cs:24)
    UnityEngine.Events.UnityEvent:Invoke()
    GameStateManager:executeGameover() (at Assets/Kings/scripts/GameStateManager.cs:88)
    UnityEngine.EventSystems.EventSystem:Update()


    I am also getting a bug regarding the new item pop-up. It is no longer appearing when the player gets an item:

    The 'New Item Panel' for the inventory item 'Whiz' could not be created.
    UnityEngine.Debug:LogWarning(Object)
    <ShowNewItems>d__11:MoveNext() (at Assets/Kings/addons/Inventory/Scripts/Inventory.cs:199)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    Inventory:AddItemAmount(InventoryItem, Int32) (at Assets/Kings/addons/Inventory/Scripts/Inventory.cs:404)
    Inventory_ChangeItem:executeItemChange(itemModifier) (at Assets/Kings/addons/Inventory/Scripts/Inventory_ChangeItem.cs:33)
    EventScript:executeExtraChanges(C_AdditionalModifiers[]) (at Assets/Kings/scripts/EventScript.cs:1007)
    EventScript:executeValueChanges(modifierGroup, Boolean) (at Assets/Kings/scripts/EventScript.cs:968)
    EventScript:ComputeResultTypeDependant(result, Boolean) (at Assets/Kings/scripts/EventScript.cs:696)
    EventScript:computeResult(result) (at Assets/Kings/scripts/EventScript.cs:674)
    EventScript:onRightSwipe() (at Assets/Kings/scripts/EventScript.cs:455)
    CardStack:rightSwipe() (at Assets/Kings/scripts/CardStack.cs:953)
    UnityEngine.Events.UnityEvent:Invoke()
    Swipe:processSwipe() (at Assets/Kings/scripts/Swipe.cs:452)
    Swipe:onRelease() (at Assets/Kings/scripts/Swipe.cs:367)
    Swipe:Update() (at Assets/Kings/scripts/Swipe.cs:287)


    And most crucially, if I click on an item in my item panel, the game freezes up on Unity and force-closes on my phone, but doesn't throw any errors! I have no idea what's going wrong :(

    Thanks again for your continued help!
     
  48. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi @Chekmate ,
    for your first issue: "Multiple values of the same type detected: differentitems" is a Warning I throw, if multible valueScripts are configured to the same valueDefinition. This is not allowed. In your case, the duplicate value definition is for "differentitems" like the error displays. E.g.:
    NoMultibleSameValueScripts.PNG
    Could you please look at your scripts if you find the dublicate configuration?

    Regarding the second issue: Does it work in Unity or shows an error or warning in Unity?

    In the mean time I will check the errors you get in detail.
     
  49. KMDeclius

    KMDeclius

    Joined:
    Aug 12, 2019
    Posts:
    213
    Hi @Chekmate,
    I think I found the issue ( 63.18% certain ;) ).
    The behaviour you describe is fitting to missing UI-GameObjects in the Inventory script. This happend propably when you deleted the meta file, sorry. Could you please check, if the configuration for your script looks exactly like in following image:
    InventoryUILinks.PNG
    This could also be linked to the crashing behaviour, I tried to catch most of wrong configuration links and then I throw debug warnings or errors. If I missed catchin one it could lead to an app crash. Nevertheless Unity should throw an error if you are testing in Play mode.

    The easiest way would be to load the backup of your project (I will never get tired of saying how important backups are) and then replacing the inventory script again without deleting the meta file.

    I hope this helps, feedback is welcome.
     
    Chekmate likes this.
  50. Chekmate

    Chekmate

    Joined:
    Sep 24, 2017
    Posts:
    77
    All issues have been resolved! Thank you very much!
     
    KMDeclius likes this.