Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TowerDefense ToolKit 4

Discussion in 'Assets and Asset Store' started by Song_Tan, Apr 18, 2012.

  1. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    There's no update in 8Jan. I simply end the christmas/new year sale by adjusting the price.

    I'm still working on various adjustment and addition before the next update. The pie menu adjustment tho is done. I can send you the new UI.cs script in advance if you want.
     
  2. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    yes... plz send me the ui songtan thank you very much....

    so how does the pie chart work when it touches the edge?
     
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Sent it to your email.

    The pie menu should now be restricted within the screen, even when the selected buildpoint is out of view.
     
  4. dong dong

    dong dong

    Joined:
    Jan 12, 2013
    Posts:
    4
    so great work,it is amazing, and i have most interest in it, and i want to use this engine to build a 2d game due to hard work on 3d models,can i get a 2d asset package version for this asset.thanks,if you have please let me know .
     
  5. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    i imported the package and when i try to play the game this is what it says..... $Capture.JPG
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    @dong dong, I'm afraid there's no 2D asset package version as such for TDTK. It's basically a scripting framework that goes with a wide variety of assets. Although it's designed with 3D asset in mind but you should have no problem using 2D asset instead to certain extent. As long as you you retain a top down view for your game that is.


    @Tsurugi, I'm afraid there's a little mix up with some of the update I added later. I've resent another copy to you. Please try that instead.
     
  7. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    I'm encountering the same problems again as from before..... the pie chart icon will stack after a certain number of towers and the cancel button is not centered.....
    i tried to modify the script base on the answers you gave on the forum but it didn't fully work...
    plz fix.....
    thank you very much....
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I dont really see too much problem there. I have tried with pie menu with 9 towers/button and there's only a minimal amount of overlapping (slightly over the edge, not enough to cover any icon/text of the button). Also the cancel button is there right where it's intended.

    I'm afraid if you want any other setting/layout than the default you are going to have to modify it yourself. Please understand it's impossible for me to tailor make the UI to suite every user. Especially given that I'm constantly update and add in new feature. That would simply mean I have to keep up and maintain hundreds of copy of TDTK each with their own little variation in every update/bug-fix I do. Although I will try my best to make the individual modification if I can but please keep in mind that I cant comply to all of them.

    What I can do is to point in the right direction to do what you want. In this case, you can modify the spacing of the pie-menu via line312 of UI.cs. Simply increase the value of the default modifier of 1.8f in that line to increase the spacing.

    For the cancel button, the position is specified in line788. If you want it to center around the click position, change it to:

    buildButtonRectList[currentBuildList.Length]=new Rect(screenPos.x-width/2, Screen.height-screenPos.y-height*0.5f, width, height);
     
  9. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    Sorry for the confusion..... The border readjustment feature works flawless the only problem is thethe tower icons will overlaps each other when I have even number towers.... For.example if I have six towers the chat will appear to have five towers and the sixth one behind the first......
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Hm... I dont understand. I tried on both even and odd number of towers. Nothing get overlapped like the way you describe it. Can you show me a screen-shot. The default should look like this:

     
  11. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    thank for the quick respond really appreciated.....
    the overlapping icon will occur when you sat the angle to 360 instead of 200......
    i fixed it myself by substituting some of the parts in the ui script you sent me before (like three to four weeks ago) to the ui i script you sent me a couple days ago....
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Try change line316 to following to gt rid of the overlapping.
    Code (csharp):
    1.             float angle=360/(Mathf.Max(1, num));
    And to you can disable the angle offset by changing both line320 line321 to following. That would make you buttons arrangement appears sysmetrical.
    Code (csharp):
    1.             float x = pos.x+radius*Mathf.Sin(i*angle*Mathf.PI/180);
    2.             float y = pos.y+radius*-Mathf.Cos(i*angle*Mathf.PI/180);
    Try to keep track of these changes, you will need it again very soon when in the next update. I've added information display for current/next wave. And probably some other changes that are still in progress.
     
  13. spyketherobot

    spyketherobot

    Joined:
    Sep 25, 2012
    Posts:
    15
    songtan i got a bug on saving the DamageArmor table on MAC OSX the files are not updated. Probably the line affectd is line 91 of DamageArmorTableEditor.cs:
    xmlDoc.Save(Application.dataPath + "\\TDTK\\Resources\\ArmorType.txt");

    any help?
     
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Thanks for the feedback. I'll look into it and get back to you asap.
     
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I figure out what is wrong. Apparently the pathing in Mac OS and window is different, duh! Instead of "\\TDTK\\Resources\\ArmorType.txt", you need "/TDTK/Resources/ArmorType.txt" for Mac OS. Alternatively to make it work in both platform, you can change the line in question to something like this:

    Code (csharp):
    1.         if(Application.platform == RuntimePlatform.OSXEditor){
    2.             xmlDoc.Save(Application.dataPath  + "/TDTK/Resources/ArmorType.txt");
    3.         }
    4.         else if (Application.platform == RuntimePlatform.WindowsEditor){
    5.             xmlDoc.Save(Application.dataPath  + "\\TDTK\\Resources\\ArmorType.txt");
    6.         }
    You will need to do the same change to line59 too for new damage type to save properly in Mac OS.

    Terribly sorry for the inconvenience caused by my inexperience with Mac OS.
     
  16. tucano

    tucano

    Joined:
    Nov 9, 2011
    Posts:
    30
    Question: continuos path.

    Hello I am trying to create a "continous path": the creeps should arrive to the last waypoint of the path, removing lifes from player life and respwan at waypoint ONE. It is possible? Which is the correct way to do it with TDTK?

    Thanks in advance!
     
  17. tucano

    tucano

    Joined:
    Nov 9, 2011
    Posts:
    30
    Sorry for the stupid question, but I don't have experience with delegates and events in C#. Can you please post me an example on how to catch events:

    onWaveStartSpawnE
    onWaveSpawnedE
    onWaveClearedE
    onClearForSpawningE

    From a custom C# script attached to the GameManager?

    Thanks in advance!
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    You mean the creep will loop back to the start of the path until they get destroyed? Unfortunately it's not supported by default. But with a little modification it can be done. first add this function to UnitCreep.cs

    Code (csharp):
    1.     public void WarpBackToSpawnPoint(){
    2.         if(path!=null){
    3.             thisT.position=path.waypoints[0].position;
    4.             thisT.rotation=path.waypoints[0].rotation;
    5.         }
    6.         else{
    7.             thisT.position=wp[0];
    8.             Quaternion rot=Quaternion.LookRotation(wp[1]-wp[0]);
    9.             thisT.rotation=rot;
    10.         }
    11.        
    12.         if(flying) thisT.position+=new Vector3(0, flightHeightOffset, 0);
    13.        
    14.         if(path.dynamicWP>0){
    15.             float allowance=path.dynamicWP;
    16.             dynamicOffset=new Vector3(Random.Range(-allowance, allowance), 0, Random.Range(-allowance, allowance));
    17.             thisT.position+=dynamicOffset;
    18.         }
    19.         else dynamicOffset=Vector3.zero;
    20.        
    21.         SetWPCounter(0);
    22.         currentPS=null;
    23.     }
    Then comment out whatever that is in function Score(). Simply call the new function instead. So it should look like this:

    Code (csharp):
    1.     public void Score(){
    2.         WarpBackToSpawnPoint();
    3.        
    4.         //~ if(scoreEffect!=null) ObjectPoolManager.Spawn(scoreEffect, thisT.position, Quaternion.identity);
    5.         //~ float duration=PlayScore();
    6.        
    7.         //~ StartCoroutine(Unspawn(duration));
    8.     }
    Do this and you creep should loop back to the start point after they reach the destination and deduct a life from player.


    For catching event. there are example in UI.cs and NGUI.cs. They generally goes like this:
    Code (csharp):
    1.     void OnEnable(){
    2.         SpawnManager.onWaveStartSpawnE += OnWaveStart;
    3.         SpawnManager.onWaveSpawnedE += OnWaveSpawned;
    4.         SpawnManager.onWaveClearedE += OnWaveCleared;
    5.         SpawnManager.onClearForSpawningE += OnClearForSpawning;
    6.     }
    7.    
    8.     void OnDisable(){
    9.         SpawnManager.onWaveStartSpawnE += OnWaveStart;
    10.         SpawnManager.onWaveSpawnedE += OnWaveSpawned;
    11.         SpawnManager.onWaveClearedE += OnWaveCleared;
    12.         SpawnManager.onClearForSpawningE -= OnClearForSpawning;
    13.     }
    14.    
    15.     void OnWaveStart(int waveID){
    16.         Debug.Log("wave"+waveID+" has is now spawning");
    17.     }
    18.    
    19.     void OnWaveSpawned(){
    20.         Debug.Log("wave"+waveID+" has finished spawning");
    21.     }
    22.    
    23.     void OnWaveCleared(){
    24.         Debug.Log("wave"+waveID+" is cleared");
    25.     }
    26.    
    27.     void OnClearForSpawning(bool flag){
    28.         enableSpawnButton=flag;
    29.     }
     
  19. Crackman

    Crackman

    Joined:
    Apr 18, 2011
    Posts:
    1
    Hi there, really nice toolkit. Everything is just as you expect it to be.
    However, here's a small suggestion (I guess there will be couple more from me as I dig into the details):
    Components that are supposed to be added by game developer could have AddComponentMenu annotations, so that they could be added quicker. Like for example, you have a creep class, that starts as:

    Code (csharp):
    1. public class UnitCreep : Unit {
    it could be

    Code (csharp):
    1. [AddComponentMenu("TDTK/UnitCreep")]
    2. public class UnitCreep : Unit {
    Small change, but very convenient.
    Thanx.
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Thanks for the suggestion. I'll do that in the next update.
     
  21. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    I'm trying to change a tower from DirectionCone to AllAround when one upgrades it. So in UpgradeStat I added the following lines of code:

    matchTowerDir2TargetDir = upgradeStat[levelM].matchTowerDir2TargetDir;

    targetingFOV = upgradeStat[levelM].targetingFOV;

    targetingArea = upgradeStat[levelM].targetingArea;

    SetTargetingArea(targetingArea);

    During play once I upgrade the tower it no longer shoots or anything.
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Instead of assigning the targetingArea before calling the function SetTargetingArea(), you just need to call the function directly with the needed targetingArea. As such:

    Code (csharp):
    1.     matchTowerDir2TargetDir = upgradeStat[levelM].matchTowerDir2TargetDir;
    2.     targetingFOV = upgradeStat[levelM].targetingFOV;
    3.     SetTargetingArea(upgradeStat[levelM].targetingArea);
     
  23. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    i set the min radius to 10 or -10 for the camera zoom function and it will not zoom in...
    the max radius function works fine.. it can zoom out ....
    the pic i posted with this post has the camera control component and the position where i set my camera....

    $camera.JPG

    oh yea.. when is the update coming out? can wait to see the ui you made for the enemy display....:D
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    For your information, the min radius for zoom is limited to 1. That means any value lower than 1 will automatically be set to 1. If for some reason you want it to be able to go below 1, try disable line minRadius=Mathf.Max(1, minRadius); in function Start() in script CameraControl.cs.

    I'm working for the update, extensively I might add. You can follow the progress here at my blog.

    It's a relatively big update. Apart from the small addition here and there, I've reworked some of the major component as well as adding a new perk system. I'll try my best to finish things by a week or two. But it's hard to say for sure as I'm still trying to adding in new stuff.
     
  25. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    i deleted the code and the camera seems to zoom in but it will jump back to the original position.....
     
  26. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    sorry songtan.... ignore the previous post.....
    what i want the camera to do is that when it is displaying the whole map the player cant not scroll in any direction but
    once the player zooms in, the player can scroll in any direction till the edges....
     
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I dont think that is possible with current implementation. At least not without adding in some kind of algorithm to determine how much the camera can see and hence restrict the movement/zoom accordingly. And such algorithim wouldnt be straight forward.

    An easy hack would be tie the size of the rect area in which the camera can move in with the zoom. It wont be accurate, but it's the easiest way I can think of. It would be modifying the final section of Update() in CameraControl.cs to something like this:

    Code (csharp):
    1.         float modifier=cam.localPosition.z/(Mathf.Abs(maxRadius-minRadius));
    2.        
    3.         float x=Mathf.Clamp(thisT.position.x, minPosX*modifier, maxPosX*modifier);
    4.         float z=Mathf.Clamp(thisT.position.z, minPosZ*modifier, maxPosZ*modifier);
    5.        
    6.         thisT.position=new Vector3(x, thisT.position.y, z);
     
  28. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    with the coming update can you add the option where i can the choose the pie chart with ngui is activated
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I will try but there's no guarantee. I need to get a bunch of other things ready, along with the next update before the end of next week so things are a bit hectic.
     
  30. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    thanks songtan for the hard and great work that you are doing... keep it up...
    i came across a problem with the ngui... the problem is when i build and installed it on my android device
    everything works great but when i pause the game the map and towers and creeps will disappear and the game itself wil be running still
    you still can hear towers firing but i can see a thing....
     
  31. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    In what way they disappear? Does it happen in an instance? Is everything in game disappear or there are still other elements that still can be seen. There's a chance that your pause menu has occupy the whole screen, blocking whatever that is still running. Have you try this on a webplayer with the same resolution? Does the same thing happen?
     
  32. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    the ngui will still be there and the buttons are still functional.....
    when i press the pause button the map and creeps and towers i built will disappear in an instance but when i unpause the game i still can hear the towers firing and creeps dying but no image only the ngui buttons....
     
  33. John-Sandrey

    John-Sandrey

    Joined:
    Jul 2, 2012
    Posts:
    119
    You will need to change the following for the pause to work .

    line384 in UInGUI.cs to
    if(Time.timeScale>=0.0000000001f) Time.timeScale=1;

    line403 in UINGUI.cs to
    if(Time.timeScale>0.0000000001f) Time.timeScale=0.0000000001f;

    I think those are the right line numbers, if not they are close. Should fix the disappearing screen.
     
  34. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    thx john.... really appreciated
     
  35. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    After I defeated wave one the next wave doesnt spawn..... It the same for all the levels....
    This will only happen when I build and run on my android phone.... Plz help
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Thanks John for clearing the earlier problem.

    So it doesnt happen in editor and other build? What is the spawn mode you are using? I'll look into it.
     
  37. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    i think the problem is that the wave counter doesn't go up.... on my phone the counter stays at zero and in the editor the counter will something go according and sometimes stays at zero....
    the spawn mode in using is wave cleared....
     
    Last edited: Feb 2, 2013
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    When playing in your editor, you should see debug from the SpawnManager, specifically "wave n has done spawning" and "wave n has been cleared". So do you see that?

    Are all the first wave in all your level are similar? What are the creeps and creeps combination you are using in each wave? Have you try a simple wave with just one basic creep type, would that cause similar issue? Try use a example scene with default creep, set the spawn mode to wave-cleared and see if the same problem happen.
     
  39. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    yea i see the "wave n has done spawning" and "wave n has been cleared" but when on wave 1 its says wave 0 and on wave 2 its says 1
     
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    That is right. Seems like it's working. But do you see second and subsequent wave spawning in the ExampleScene?
     
  41. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    It's works in the editor.... But when I build and run on my android phone to the problem will occur.....
    When I open the app for the first time the level will run smoothly but if I advance on to the next level or restart the same level then the wave problem will occur ....
     
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I see. Can you let me know is the same problem happen when you are using the default examples?
     
  43. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    yea the same same problem occurs with the example scene(nGui)......
     
  44. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Right, I'll check it out. I have to say so far I didnt manage to replicate the error on my mobile device as well as editor. Did you ever modify the code in the main script components, such as SpawnManager ro GameControl?

    Forgive me that I might have to put this on holduntil I get the next update ready, before I need to travel in 2 days time and hence need to work remotely. I cant work on the update remotely due to various hardware and software restriction. With that said, expect the new update coming. Information here.
     
  45. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    the tower editor and tower manager have problems..... the console display this two thing when i open the tower editor and tower manager window....

    NullReferenceException: Object reference not set to an instance of an object
    TowerManager.OnGUI () (at Assets/TDTK/Scripts/C#/Editor/TowerManager.cs:128)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    AND......

    NullReferenceException: Object reference not set to an instance of an object
    TowerEditor.OnGUI () (at Assets/TDTK/Scripts/C#/Editor/TowerEditor.cs:164)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  46. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Did you import the new update to a new empty project or an existing project? Have you change the hierarchy or naming of the asset folder in ProjectTab? The arrangement and naming of some of the folder is crucial, particularly Resource folder as that is where the resources, towers and perks information is stored. I have to say I tried import the new update to a new empty project and an existing project, none give me any issue. Also the errors is very baffling, line164 in TowerManager doesnt seems to have anything that would give a NullReferenceException error.
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I'm pleased to announce a new update is now live on AssetStore. The new version 2.2b see a lot of improvement over various editors to give user a more streamlined experience. It also feature another major addition, a perk system that will take the strategic element of your TD game to new height. You can essentially use the perk system to customized a tech tree or in game shop.

    I didnt want to re-posting the same information here in the thread so for full details of the update please goes to my development blog.

    Alternatively you can just check out the new demo. Have fun!
     
  48. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    I imported the updated on to the older version because my projects are in it...
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Try a clean project to see if the error happen. If so it may well be a bug and I'll need to find out what is causing it. In the current project you import the update to, did the error occur as soon as the first time you open TowerManager and TowerEditor? Or it happen after you assign some additional tower to TowerManager?
     
  50. John-Sandrey

    John-Sandrey

    Joined:
    Jul 2, 2012
    Posts:
    119
    Nice update to the TDTK, haven had time to dig into it but looks nice.