Search Unity

TurnBased-Toolkit (TBTK)

Discussion in 'Assets and Asset Store' started by Song_Tan, Aug 11, 2013.

  1. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, in that case. I think that's a class named FogOfWar where it contain the function to update a unit visibility, or something along that line. You need to look into the Ability or AbilityManager, where the creep is spawned and add in the code to call that update visibility function. Or like you said, you can send me the code. I'll try take a look at it when I have the time.
     
  2. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Thanks ... I believe there's a function called SetToVisible() and SetToInvisible() on UnitTB class. However, if I call these functions on the unit in the InsertUnit function, It doesn't change whether or not the unit is visible. It is always invisible if it is created during the AI turn.

    Interestingly enough, if a unit is spawned on the enemy turn and one of my characters is killed during that same turn, then the visibility is refreshed and I am suddenly able to see the spawned units.

    I'll keep playing around with it but if I can't figure it out, I'll send my code. Thanks again,
     
  3. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Actuallly, I think I got it working. I saw that there was a function in UnitTB start() method that set whether or not the unit was visible or not. It just looked at the faction ID and whether FogOfWar was enabled. If the unit was the player's faction ID, it set it to visible and if not set it to invisible. I modified the code as follows to do a LOS check on all player faction units:

    Code (CSharp):
    1. if(GameControlTB.IsPlayerFaction(factionID)) thisObj.layer=LayerManager.GetLayerUnit();
    2.         else{
    3.             if (GameControlTB.EnableFogOfWar())
    4.             {
    5.                 bool isInLOSofPlayer = false;
    6.  
    7.                 foreach (UnitTB unit in UnitControl.GetAllUnitsOfFaction(GameControlTB.GetPlayerFactionID()))
    8.                 {
    9.                     if (GridManager.IsInLOS(unit.occupiedTile, occupiedTile))
    10.                         isInLOSofPlayer = true;
    11.                 }
    12.  
    13.                 if (isInLOSofPlayer)
    14.                     SetToVisible();
    15.                 else
    16.                     SetToInvisible();
    17.             }
    18.             else SetToVisible();
    19.         }
    This seems to work great. Will test it more but so far so good.
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Good to know. :)
     
  5. StabbingBogan

    StabbingBogan

    Joined:
    Mar 31, 2015
    Posts:
    1
    Hi.

    I purchased TBTK a couple months back as part of a game design course I'm doing and find myself wanting to continue using it as part of another project I had in mind. One issue I've run into is handling unit death at the start of a units turn.

    Basically I'm attempting to add in a Damage Over Time ability (poison for example) by adding a generic ability and using buff/debuff section contained inside the ability editor. While I've been successful in reducing a units health for multiple turns using this method, units still remain in the game even after their health has been reduced past 0 and will only be removed on a successful attack.

    As I'm using "Unit Per Turn" and the damage isn't attributed until the start of that units turn, I'm thinking I can check the units health when that unit is selected for the next turn and if it's 0 or under, trigger that units death. In terms of cancelling that units movement and turn I'm thinking I can do it in a similar way to how a unit dying from overwatch does it (found in the Unit script), however I don't even know where I would implement the check (TurnControl maybe?) Can you help?


    Thanks in advance

    SB.
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, this should have happen. It's a bug and It should have been my responsibility to fix it. So don't need to worry about it. Please email me so I can send the fix to you when I'm done.
     
  7. polliwog

    polliwog

    Joined:
    Mar 6, 2014
    Posts:
    1
    How can I add more tile types? I want to make tiles consume movement and require movement points to move through.
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid you can't. Not without modifying the code anyway.

    To start, you can add a move-cost property in Tile.cs. Then you will need to modify the path-finding algorithm to take account into the move cost of each tile. You can find the relevant code in TBTK_Class_AStar.cs.
     
  9. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hey Songtan,

    Just thought I'd post some more pics of my upcoming dungeon crawler RPG made using this awesome kit.

    War Wyvern by Rajpreet Dhillon, on Flickr

    Daevian Warriors by Rajpreet Dhillon, on Flickr

    I'm going through the latest version of the code to see what code and features I can transplant back into my old version. Trying to get the overwatch attack abilities to work in particular. I'm running into an odd situation where the overwatch attack is triggered but the shoot object of the overwatching unit is created but never moves towards the target. Any idea what that could be?
     
    mahdijj likes this.
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Awesome looking! Is a dragon an actual unit?!

    For your overwatch problem. It's hard to tell why. When using shoot-object You have to call Shoot() function of the shoot-object after it has been spawned. Otherwise the shoot object won't do anything. So I would do a step by step check, starting from if the Shoot() function of the shoot-object is called when using overwatch attack is initiated. Then if the subsequent code is executed. If not, why?
     
  11. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Yep, the dragon is an enemy unit. A hybrid with a long melee attack range, fireball missiles and several abilities that it can perform.

    Cool ... I'll look into that. Thanks for the tips.
     
  12. DarthMasta

    DarthMasta

    Joined:
    May 1, 2013
    Posts:
    2
    I'm looking into buying this asset, looks pretty awesome, but I'd like to know how suitable it is for 2D games. I assume it is, but requiring code rewrites...

    Also, I know it's the wrong forum, but same question for your top down shooter asset? :D
     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The base mechanic should work regardless of the fact that you are using 2D or 3D asset. It's just visualization that you need to worry about. If you are using a full top down view, chance are the toolkit should work for you right out of the box. Anything other than that however (isometric or side for instance), you will need some code extension to have the 2D sprite displayed in the correct manner. Mainly just to have them face the right direction and that should be it.

    The same applies for the top down shooter kit. Hope this answer your questions.
     
  14. mahdijj

    mahdijj

    Joined:
    Sep 24, 2015
    Posts:
    31
    i want purchase this item
    but i want to know it is easy to creating a online multiplayer game with this with photon or unet?
    do you support multiplayer?
    do you freelance for multiplayer for tbtk?
     
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid multiplayer is not supported for TBTK. I can't comment on multiplayer integration with photon or unet either since I don't know much about network multiplayer. Sorry for not being much help.
     
  16. MAeStROx

    MAeStROx

    Joined:
    Mar 20, 2015
    Posts:
    15
    Hey songtan!
    I love the asset found it to be very easy to read and uderstand.

    mahdijj I tried doing what you were talking about adding multiplayer support, and it could be done.
    What I did was to add a replaceable controller through which all the orders will go through with the data needed for that action.
    That way you can implement your own controller,
    implementing virtual functions or interface functions(whichever way should work I think).

    Lets take a unit move order for an example:
    public void MoveUnit(Unit unit, Tile tile);

    So if you're implementing a singleplayer controller:
    public void MoveUnit(Unit unit, Tile tile){
    unit.move(tile);
    }
    If you're implementing a multiplayer controller:
    public void MoveUnit(Unit unit, Tile tile){
    Network.SendMove(unit,tile);
    }
    public void UnitMoved(Unit unit, Tile tile){
    SingleplayerController.MoveUnit(unit,tile);
    }
    that way you can make your own network controller :)
    I don't mind sharing some bits of my code if you'd like to get you going
    That ontop of multi-battle support would be super-cool additions.

    here is a video example: http://screencast.com/t/MQbtcrmJgn
     
    Last edited: Jun 16, 2016
    mahdijj likes this.
  17. gamerkhang

    gamerkhang

    Joined:
    Mar 25, 2013
    Posts:
    1
    Hi,

    With this pack, is it possible to implement tile map heights with significant effects on gameplay/pathfinding, similar to what is done in games like Tactics Ogre and Final Fantasy Tactics?

    I'm also curious about diagonal movement costs on square grids, though I'll probably end up using hexes anyway.
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid not. While you can certainly tweak the grid to add height component, there's won't be any effect on gameplay. The game will treat every tile as if they are on the same height regardless. I would love to add vertical component to the gameplay at some point in the future. However there's no telling if I will ever get to it.

    For diagonal movement, there's no additional move cost.
     
  19. mahdijj

    mahdijj

    Joined:
    Sep 24, 2015
    Posts:
    31
    hi
    can you share your email?for worrking on this...
     
  20. MAeStROx

    MAeStROx

    Joined:
    Mar 20, 2015
    Posts:
    15
    sure i'll send you a pm mahdijj
     
  21. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    259
    But without gameplay effects, different high tiles would work?
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    They would just work like any other normal tiles, apart from having different height visually. The unit can still move in and out of them without any additional movement cost, attacks from or towards the tile will not granted any bonus or penalty, etc.

    A psa on another note, I'll be out of office until Friday. Any question/issue will have to wait until then. I thank you in advance for your patient and understanding.
     
  23. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    259
    sounds good to me - i was more concerned about the grid markers/tinting and if the units are moving also on the Y axis. cause in the screenshots i can only see flat land. so can you confirm that the grid also works on different heights at the units move also to the higher areas and not stuck on the ground? (Y = 0)
    then i will buy it :)
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry for the slow respond, I'm finally back. :)

    To answer your question, yes the unit will always position itself to the position of the tile it's located in. In other words, the y-axis position o the unit will change according to the it's position.
     
  25. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    songtan, your asset library is extremely well-made and fun to use. I do have an issue with the library however. Whenever a tile is calculating its own neighboring tiles, the tile would incorrectly disconnect from an adjacent tile. I do believe that the problem has something to do with Tile.InitWall. I have also attached a screen capture from the TBTK web demo to illustrate the problem. Thank you in advance and thank you twice for writing this excellent library.
     

    Attached Files:

  26. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for pointing this out. I've checked. There's nothing wrong with the code. The error you are experiencing is a setting error on the grid itself. I'm not sure how that got in. Must have been some editor error or my own mistake when I was building the toolkit. You can correct this, by accessing the setting of Tile_2x2 and Tile_2x3 on Inspector and clear the WallList. The same problem shouldn't happen in other scene you created.
     
  27. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    Thank you for the fast reply. I only brought up the web demo because it was a good test case and featured no customizations. However, I am noticing this for my own project, which I started by creating a new square grid and added some walls.

    Is it safe to clear the wall list if the tile has no children (representing a wall) on it?
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I took a closer look and ran a few quick test. You are right, there's indeed a bug with the code to place/remove wall. I'll need to spend some time to find out what's wrong and fix this. I'll let you know what I manage to fix it.

    You can't clear a wall list if the tile has no children. Sometime the wall object is placed on the neighbor tile which the wall is connect to. You can only safely clear the wall list if there's no connecting wall in adjacent list.
     
  29. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    Thank you so much for your time. I would like to know how you ended up fixing the bug. Good luck!
     
    Last edited: Jul 3, 2016
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've managed to find out what's wrong. It's very easy to fix. You simply need to change line462 in Tile.cs to following: if((angle+=180)>=360) angle-=360;
     
  31. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    Ah okay. Thanks for the update. Thankfully the map that I was using can be quickly regenerated; just in case for anyone else who is reading this thread, is it possible to fix pre-existing maps with invisible walls?
     
  32. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    At the moment, I'm afraid the only way to fix the pre-existing map is to manually clear the wall list on the tile.
     
  33. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    Thank you for the support! The TBTK library is still great. :)
     
  34. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi Songtan,

    I'm hoping you can help me trouble shoot an issue with my old version. During the enemy turn, I see spikes in CPU usage that cause weird delays. Seems to happen when going from one AI unit to another.

    spikes by Rajpreet Dhillon, on Flickr

    From the profiler, it happens during AIManager InvokeMoveNext coroutine. However, I don't have any such coroutine with that name. Therefore, I'm thinking I must not be interpreting the profiler correctly. Do you have any thoughts?
     
  35. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Interesting. Can you send me a copy the scripts (all of them if possible) so I can have a reference?
     
  36. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Sure thing. I'll send you a pm to get your mail addresd to send the scripts.
     
  37. ponasoft

    ponasoft

    Joined:
    Oct 6, 2013
    Posts:
    42
    Hi,
    Does this kit compatible with unity 5.4 which released today? i am about to start to make a game and i would prefer new version if i can use it with this kit. If it is not compatible can you guess how long it would take to update?
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It should be compatible. I haven't test it yet myself but I don't see any reason why it's not compatible with Unity5.4. I'll try to confirm this and fix any issue, if there's any over the weekend. If you are running it on 5.4 and come across any error, please let me know.

    I hope that answer your question.
     
    ponasoft likes this.
  39. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Congratulation!
     
    drewradley likes this.
  41. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    I have another question; are you familiar with the "Dungeons & Dragons version 3.5" rule where the cost of diagonals are "1-2-1"? A long thread can be found here:
    http://www.enworld.org/forum/showthread.php?218953-1-2-1-Diagonal-Movement

    The purpose of the higher cost of diagonals is to make attack and movement reach appear as a circle-like shape as oppose to a square.
     
    Last edited: Jul 29, 2016
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    No I'm afraid I'm not familiar with D&D rule set. I understand the reason why some may prefer it but frankly it's subjective at best. Different player/game-designer prefer different movement rule for different reason.
     
  43. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    Ah, thank you for your speedy reply~!!
     
  44. JessieK

    JessieK

    Joined:
    Feb 4, 2014
    Posts:
    148
    Is there anyway to slow down the movement speed on the map. Right now I have big mechs zipping about which looks very odd. On top of that at this point they are moving so fast they are out moving the movement animations so is there a way I can slow some units down?
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Yes. You can adjust the move speed of each individual prefab by changing the value of 'Move Speed' on the unit component. However this is not shown on UnitEditor, it is only shown in Inspector when you expand the 'Show Default Editor' option.
     
  46. JessieK

    JessieK

    Joined:
    Feb 4, 2014
    Posts:
    148
    Thank you! That's perfect
     
  47. ponasoft

    ponasoft

    Joined:
    Oct 6, 2013
    Posts:
    42
    Thanks so much for updating so quick. i am starting new game today and i will share updates of my game. i also reviewed to thank you :)
     
  48. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You are welcome!
     
  49. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    I just tried out your latest release of the TBTK library and I think that something broke. The AI player cannot end their turn or something. For quick testing, just try out the DemoSimple or DemoFullFeature scenes. For some reason, DemoSimpleAlt and DemoJRPG does work properly.
     
    Last edited: Aug 1, 2016
  50. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for pointing that out. I'm aware of that and have already been working on a fix. Another update will come very soon.