Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

[RELEASED] Turn Based Strategy Framework

Discussion in 'Assets and Asset Store' started by michal-zetkowski, Jul 2, 2019.

  1. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Hey :)

    Yes, this belongs in Unit script. I would code it in Unit.DefenceActionPerformed. This method is called after the unit is attacked. Basically, you would trigger a counter attack in there.

    The problem is that this method does not have the reference to the unit that attacked. You would have to add this parameter.

    Other than that, you could code it in Unit.AttackHandler or Unit.AttackActionPerformed. In this case, unit would trigger the counter attack himself, which is a bit counter intuitive. You would need to make AttackHandler method virtual though and add another parameter to AttackActionPerformed, just like with DefenceActionPerformed
     
  2. sudahi51

    sudahi51

    Joined:
    Aug 17, 2020
    Posts:
    4
    Hey I love the framework so far! I just got through the tutorial and have been going through the rest of the example code to see how they all operate differently since I'm thinking I'll need a little bit of each example for my game.

    So for the project I'm working on I noted some of the functionalities that I will need to add to get the UI and combat system running how I'm hoping, and I was wondering if you'd be able to give me any answers for them? Sorry if any of these are obvious or redundant I only skimmed a couple pages of the comments and I'm not the most experienced with strategy game dev.

    1. Can counter movements be integrated? such as counter attacking an enemy, defending from an attack, or evading one.
    2. Can obstacles be assigned values that allow units to sit on top of them? Like if you have an aerial unit can it sit on a square that has a ground level obstacle? Would a height function need to be added to the obstacle and unit for them to read that?
    3. Similar to Question 2, would it be possible to make terrain transferring units? Ex: an amphibious unit that can sit on ground tiles and water tiles. A more complex example would be implementing a toggle for allowing an aerial unit to land on the ground and vice versa in the unit menu.
    4. Can the on-click events for unit selection, empty tile selection and attacking/defending be replaced with selection menus similar to Advance Wars?
    5. Following up on Questions 1 & 4, can a menu be implemented for combat that would allow players to choose a unit's weapon it attacks with? Or when being attacked by an enemy can a player choose whether to counterattack, evade, or defend? Similar to Super Robot Wars.
    6. How difficult would it be to add additional unit attributes such as multiple weapons, fuel consumption, terrain type, ammunition per weapon, and evasion?
    7. Would it be possible to add scripted events? Such as defeating a certain enemy causing a dialogue scene or more enemies to spawn?
    8. Can troop deployments and deployment costs be added and tracked?

    Thanks,
    Josh
     
  3. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Hey,

    1. Yes, please check out couple of my previous answers where I describe it in more detail. Basically you can do it in either Unit.AttackHandler or Unit.DefendHandler / Unit.DefenceActionPerformed

    2. Yes, you should subclass Cell and add this information in your derived class. You could utilize this information in Unit.OnMoveCompleted

    3. There are Unit.IsCellTraversable and Unit.IsCellMovableTo where you define where your unit can move. In the first example you would add terrainType field you your derived Cell and based on that information allow or disallow movement over water in your different kinds of units.

    4. Yes, I would code these menus in CellGridStateUnitSelected.OnUnitClicked. Instead of simply performing action (like it is now) you could display the menu there

    5. Regarding seleciting weapon it would be the same as in #4. I would put counterattacking menu in Unit.Defendhandler

    6. You can just add these fields to your subclassed Cells and Units

    7. Cells and Units have some events included in them. If you need more, you can add them yourself. In your example, you would assign the unit that needs to be killed to your script and subscribe to its UnitDestroyed event. You can trigger the dialog in handler function

    8. I would add deploymentCost field to your derived Unit and track the cost in your deployment script
     
    sudahi51 likes this.
  4. PopRockLex

    PopRockLex

    Joined:
    Sep 13, 2018
    Posts:
    17
    Thank you for the help! It took me way longer than it should have. I finally got it working as I wanted. Recoil but only for the first attack once a turn per unit.
    Here's my edited code for anyone having trouble. This is all in the "Unit" script btw.

    Code (CSharp):
    1.         public void DefendHandler(Unit aggressor, int damage)
    2.         {
    3.  
    4.             MarkAsDefending(aggressor);
    5.             int damageTaken = Defend(aggressor, damage);
    6.             HitPoints -= damageTaken;
    7.             DefenceActionPerformed(damageTaken);
    8.             if (UnitAttacked != null)
    9.             {
    10.                 UnitAttacked.Invoke(this, new AttackEventArgs(aggressor, this, damage));
    11.             }
    12.  
    13.             if (HitPoints <= 0)
    14.             {
    15.                 if (UnitDestroyed != null)
    16.                 {
    17.                     UnitDestroyed.Invoke(this, new AttackEventArgs(aggressor, this, damage));
    18.                 }
    19.                 OnDestroyed();
    20.             }
    21.             if(!hitBack)
    22.             {
    23.                 hitBack = true;
    24.                 aggressor.RecoilHandler(DefenceFactor);
    25.             }
    26.  
    27.         }
    28.  
    29.  
    30.         public void RecoilHandler(int recoilDamage)
    31.         {
    32.  
    33.                 int tempDamageTaken = Mathf.Clamp(recoilDamage - DefenceFactor, 1, recoilDamage);
    34.                 HitPoints -= tempDamageTaken;
    35.                 DefenceActionPerformed(tempDamageTaken);
    36.                 if (UnitAttacked != null)
    37.                 {
    38.                     UnitAttacked.Invoke(this, new AttackEventArgs(this, this, tempDamageTaken));
    39.                 }
    40.  
    41.                 if (HitPoints <= 0)
    42.                 {
    43.                     if (UnitDestroyed != null)
    44.                     {
    45.                         UnitDestroyed.Invoke(this, new AttackEventArgs(this, this, tempDamageTaken));
    46.                     }
    47.                     OnDestroyed();
    48.                 }
    49.  
    50.         }
    51.  
    52.  
    Just that and add in a bool for "hitback", make it start as false, and reset it to false at the start of each turn.

    The current problem I'm having is trying to spawn units. I read through the docs and all of this thread and tried for a few hours but I just can't get it.
    I'm trying to make a menu pop up appear when you click on the town, (Unit w/ zero movements was a great idea!) and then 3 buttons where you would choose a unit to create, then click on a space adjacent to the town and it will spawn there.
    So far, the menu and all is fine. But then I'm not sure what to do.
    As far as I understand, I'm supposed to instantiate it in "OnCellClicked()", make it the child of "Units", then feed in its transform to "AddUnit()" under the "Cell" class? I can't figure out what I'm doing wrong or how to get this to work. Any advice would be much appreciated!
     
  5. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Yes, instantiatethe prefab and pass transform to CellGrid.AddUnit. No need to make it child of Units gameobject. Also, before passing it to AddUnit you should assign some cell to Unit.Cell (you can use cell reference from OnCellClicked) and assign transform.position to your newly spawned unit manually. Let me know if that heleped :)
     
  6. GameMarshal

    GameMarshal

    Joined:
    Nov 9, 2020
    Posts:
    8
    Hi,

    I have another question, I will try to explain it well so you can reuse it for your FAQ ;)

    - Can I use your framework only in some scenes?
    The idea is to alternate a turn phase with a no-turn phase.

    For example, for a RPG like Baldur's Gate, Shadowrun Returns or Fallout, there are real-time moments (when there is no combat) and turn-based moments.
    I would like to keep it simple, quite like Shadowrun Returns, with areas with no enemies, and others dedicated to a fight. So for example, scene 01 would be without enemy, and so not using your framework. The player clicks on the map and the character goes where the mouse has clicked.
    Scene 02 would be a fight, and so would use your framework.

    Do you consider this possible with your framework?
    Except for the grid and turns, I would have to keep the player's info saved between the scenes: inventory, quests...

    Or maybe there is a simpler way to achieve this.
    By playing with an action points variable which turns infinite when there is no enemy. So the character can move without limit, and since there is no enemy, the player turns starts and ends automatically.

    Thank you ;)
     
  7. PopRockLex

    PopRockLex

    Joined:
    Sep 13, 2018
    Posts:
    17
    That definitely helped! Works like a charm now. For anyone else struggling. You also need to call "GetComponent<Unit>().Initialize();" on the game object you instantiate. Thanks dev for being so responsive and helpful even with these repeat questions!
    Final problem. I can't find out how to just have them spawn on the cells that are reachable. Is there a bool reference or something to determine if the cell is reachable??
     
  8. sudahi51

    sudahi51

    Joined:
    Aug 17, 2020
    Posts:
    4
    Hi,

    Thanks for the help so far been working through it and it's going alright so far. I was wondering if you also knew if there was an easy way to integrate save and load states into the framework?
     
  9. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Right, I forgot about Initialize.

    What do you mean by reachable? If you need to find cells in given distance from other cell, you can use the following code (it uses Linq):
    Code (CSharp):
    1.  cellGrid.Cells.FindAll(c => c.GetDistance(sourceCell) <= maxDistance)
     
  10. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    You could serialize information about units on the grid to file and restore it on load by spawning the units and assigning serialized values to them.
     
    sudahi51 likes this.
  11. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163

    Ok, but you still wnat to make it seems like a single scene, right? Not loading separate battlefield scene?

    If you removed game over condition that is currently hardcoded and either assign Integer.MAX movement points to your units or disable subtracting movement points when moving, then you could move your units around the map real-time like. You could set up some triggers that would revert this behaviour to normal (for example when certain cell is reached) and have normal turn-based battles.
     
  12. GameMarshal

    GameMarshal

    Joined:
    Nov 9, 2020
    Posts:
    8
    I'm not sure, maybe a single or separate scenes. Does it change a lot how to handle it?

    Thanks ;)
     
    Last edited: Dec 18, 2020
  13. PopRockLex

    PopRockLex

    Joined:
    Sep 13, 2018
    Posts:
    17
    First I was thinking I could access "MarkAsReachable();" and find out if the cell I clicked on was marked in some way. Then I was hoping there was a list of cells stored somewhere from the "GetNeighbours()". Which I found under "Cell" but I don't know how to check if my clicked cell was on that list. I'll try to figure out the "GetDistance" thing instead. Thank you for your help!
     
    Last edited: Dec 18, 2020
  14. sudahi51

    sudahi51

    Joined:
    Aug 17, 2020
    Posts:
    4
    Hi Michal,

    Sorry for asking so many questions, but I've been having a little issue moving the events into the OnCellClick and OnUnitClick events. So I managed to create my menus and the UI calls my script but it doesn't respond to the button inputs correctly and it seems to break the actual unit movement and gameplay when it's running in the script. Maybe I didn't make the change in the correct place as I changed the CellHighlight code in GuiController to CellClicked.
    upload_2020-12-18_18-47-12.png

    I also created a UnitClickMenu with similar code to the CellClickMenu where it's going to contain all the movement, attack, and stats but I haven't called it into the project yet. I can also attach my code if that would be helpful as well.

    For reference this is the kind of menu system I'm trying to use (starting at 1:25) -


    Thanks again,
    Josh
     
  15. PopRockLex

    PopRockLex

    Joined:
    Sep 13, 2018
    Posts:
    17
    I'm sure they can help you more than me. Just chiming in becuase I think I had the same issue and solved it. I had to leave "CellHighlight" alone, I think that's just called when you hover over a space. I had to go under "CellGrid"
    Code (CSharp):
    1.  public virtual void OnCellClicked(object sender, EventArgs e)
    2.         {              
    3.           CellGridState.OnCellClicked(sender as Cell);
    4.         }
    I added the code I need there and made a bool to detect if the menu was open so it would stop selecting the underlying cells.
    I hope that helped you some. If not I'm sure the main man will be back to answer soon.
     
    Last edited: Dec 19, 2020
  16. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    @GameMarshal If I understand correctly then making it separate scenes would be way easier, just load the battle scene when you reach an enamy in the overworld

    @sudahi51 Could you export your project and send it to me by email?
     
    sudahi51 likes this.
  17. PopRockLex

    PopRockLex

    Joined:
    Sep 13, 2018
    Posts:
    17
    This should be my final question. Is it possible to generate maps at runtime/in-game using a script to access the "Grid Helper"?
     
    Last edited: Dec 22, 2020
  18. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    @PopRockLex GridHelper is editor extension, i don't think you can access it at runtime. You can extract the relevant code to another script though and use it that way. At the least you will need grid generation scripts that you can find in Editor/GridGenerators folder (right, you will need to copy / move them somewhere else, because scripts from Editor folder can only be used in editor).

    To sum up, I don't see any reason why grid generation scripts wouldn't work at runtime, you just need to put the pieces together in a separate script.
     
  19. xv16

    xv16

    Joined:
    Jul 25, 2018
    Posts:
    2
    Tell me how to make an auto-completion while walking, if all units have completed their moves, so as not to constantly press the button
     
  20. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Make a script that ckecks if any of the units has ActionPoints left and if not, call CellGrid.EndTurn
     
  21. xv16

    xv16

    Joined:
    Jul 25, 2018
    Posts:
    2
    At what stage do you call this script? Sorry for my English
     
  22. PopRockLex

    PopRockLex

    Joined:
    Sep 13, 2018
    Posts:
    17
    Awesome. Thank you, you're amazing and super helpful to us all. Much appreciated!
     
  23. oldschoolgamer72

    oldschoolgamer72

    Joined:
    Nov 3, 2018
    Posts:
    1
    Hello and thanks for the awesome asset!

    I want to add gamepad support to this asset for playing couch coop games. I have bought and tried the Hex controller asset which works good for hex games. This does not work for square tiles. I bought UI cursor asset which works good with game cursor controlled by mouse, using gamepad cursor instead for game cursor to follow. I hope this made sense.

    Any way I need to find the game cursor in TBS Framework which is the highlighting box that moves around the map with the mouse for selecting tiles so I can have that follow the gamepad cursor like it did with mouse cursor. UI cursor standalone input module is asking for Cursor image. I looked all over hierarchy for it in the scene and searched your forum.

    Please help me to locate the game cursor that selects tiles so I can control with gamepad. If you have a better way of doing this than what I am trying to do please give me some pointers. Any help is appreciated!
    Thanks in advance!
    Joe
     
  24. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    39
    unknown (1).png unknown.png more updates, resource icons, borders, so on,
    unknown (2).png
     
  25. Panhypersebastos

    Panhypersebastos

    Joined:
    Feb 21, 2017
    Posts:
    31
    In response to a question I got via PM here is what I did to get attacking units to take damage:

    Code (CSharp):
    1. public void AttackHandler(Unit unitToAttack)
    2.         {
    3.             if (!IsUnitAttackable(unitToAttack, Cell))
    4.             {
    5.                 return;
    6.             }
    7.  
    8.             AttackAction attackAction = DealDamage(unitToAttack);
    9.             MarkAsAttacking(unitToAttack);
    10.             unitToAttack.DefendHandler(this, attackAction.Damage);
    11.             if(unitType == "Melee")
    12.             {
    13.                 unitToAttack.CounterAttack(this, attackAction.Damage);
    14.             }
    15.             AttackActionPerformed(attackAction.ActionCost);
    16.         }
    Code (CSharp):
    1. public void CounterAttack(Unit aggressor, int damage)
    2.         {
    3.             float _hpf = HitPoints;
    4.             float _Mhpf = MaxHitPoints;
    5.             //float HPRatio = _hpf / _Mhpf;
    6.             float _adj1 = (aggressor.HitPoints / aggressor.MaxHitPoints) * aggressor.AttackFactor - DefenceFactor; //adjusts for the fact that this unit has already taken damage.
    7.             float HPRatio = (_hpf + _adj1) / _Mhpf;
    8.             int AdjustedAttackFactor = (int)Mathf.Round(AttackFactor * (HPRatio));
    9.             //Debug.Log("Counter adj1" + _adj1);
    10.             //Debug.Log("Counter HPRatio " + HPRatio);
    11.             //Debug.Log("Counter AdjAttFac " + AdjustedAttackFactor);
    12.             aggressor.CounterDefendHandler(this, AdjustedAttackFactor);
    13.         }
    unitType is a property that I added to units so that I could differentiate them by ranged, melee, artillery, etc... I added a counterattack function in the unit script (which is basically a duplicate of the existing attack function) and then called it in the attack handler.

    Here is a screenshot from my test game so far. It is ancient alien themed with you commanding the egyptian army against a race of invading extraterrestrials.

     
  26. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Sorry for delayed replies, I was away for Christmas

    @xv16 I would create separate script that would check if any units have ActionPoints left (in Update function). Not the prettiest method, but tit will work.

    @oldschoolgamer72 Any chance to get this Hex controller asset to work with square tiles? I have no idea how it works, but maybe if you contacted the developer it would turn out to be a easy fix?

    I'm not sure about working with cursor. I would create a separate script for this kind of control. The script would hold the coordinates of selected cell and modify it by reading the input from the controller. To select the cell you could call Cell.OnMouseEnter, just make it public.

    Ok, but how to map coordinates stored in your controller script to cells? Cells are stored in CellGrid.Cells list. The problem is that it is a list and not a 2d array. You could either select the appropriate cell with Linq by checking its OffsetCoords field, or create the 2d array yourself at the start of the game.
     
  27. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    39
    I would really recommend using an enum for unit type rather than a string, i use an enum. Strings are harder to keep track of.
     
  28. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    39
    Also if you don't mind me asking how did you do your minimap?
     
  29. Adynod

    Adynod

    Joined:
    Feb 12, 2015
    Posts:
    1
    Hi there. Could anyone here help with 8-directional movement and pathfinding? I've adjusted my Square : Cell (based on Example4's AdvWrsSquare) to list the extra 4 directions required and diagonal movement is now possible, which is great.

    My issue is that it produces some strange paths which seem to be due to the _directions order and movement cost. I want it to prefer straight paths but I can't seem to account for slightly increased diagonal movement costs in GetDistance which I think is what I need to do?

    Changing the GetDistance calculation doesn't seem to affect the path's behaviour. I've only managed to adjust it by re-ordering the _directions array (to worse effect).

    I'm a bit of a beginner so I feel like I'm missing something fundamental to how this is all working (even after a week of grid logic and pathfinding research). Any help/pointers appreciated, thanks!

    This is stepping through what should be a straight path: FunkyPath1.gif
     
    michal-zetkowski likes this.
  30. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    I think you should look into pathfinding algorithm implementation - you can find it in DijkstraPathfinding.cs script. Basically, dijkstra pathfinding uses priority queue when procesing graph nodes. To fix your issue you should assign higher priority to nodes that are on the straight line towards destination instead of diagonally. Use the following link as reference https://www.redblobgames.com/pathfinding/a-star/introduction.html
     
    Adynod likes this.
  31. squirmonkey

    squirmonkey

    Joined:
    May 29, 2018
    Posts:
    3
    Hello!

    I've just picked up this tool, and I'm looking forward to using it.

    I'm having trouble getting the unit painting tool to work in a 2D game. I'm able to use the tile painting, and see the cursor come up when I'm using it, and paint tiles successfully. But I haven't been able to get the unit painter working, either on the example scenes or on my own scene. No special cursor appears when I'm in that mode, and I'm not able to add units to the scene with a click.

    I'm using Unity version 2020.2.1f1 Personal on a Windows 10 desktop. I believe, based on the readme that I'm using version 2.0.1 of your framework.

    I'd really appreciate any help you can give me in troubleshooting this issue.

    Thanks,
    --Squirmonkey
     
    Last edited: Jan 15, 2021
  32. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Hey, I just check it out in this version and it works for me. Could you try restarting unity / creating a new project and reimporting the asset there? I assume you did'nt make any changes, it doesn't work "out of the box", right?

    upload_2021-1-15_8-7-43.png
     
  33. squirmonkey

    squirmonkey

    Joined:
    May 29, 2018
    Posts:
    3
    Okay, my problem appears to be twofold:

    1) (Appears to be a bug) If you enter the unit edit mode, then exit the unit edit mode, entering unit edit mode again doesn't appear to work until Unity is restarted. I was able to reproduce this on example 4 you provided, both in my project and a clean project.

    2) (Appears to be my problem) The unit prefab I created, when unit painted, appears behind the tiles until the project is run. I solved this issue
     
    Last edited: Jan 15, 2021
  34. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    39
    I'm not the dev but, i am very experianced with this asset
    1) press ctrl+r a couple times and it will work (that toggles the unit edit mode properly, and fixes it for me)
    2) Make sure your tiles have the correct offset settings on them
     
  35. squirmonkey

    squirmonkey

    Joined:
    May 29, 2018
    Posts:
    3
    Ah thanks. Ctrl+r does make it work. Strange that the buttons don't work correctly, but I guess that is what it is.

    Do you happen to know how to unpaint a unit? Is it sufficient to just delete the unit? Or do I also need to undo some link to the grid?
     
  36. Panhypersebastos

    Panhypersebastos

    Joined:
    Feb 21, 2017
    Posts:
    31
    I have a camera with a render texture that only renders my "miniMapLayer". (The normal camera does not render the miniMapLayer). Each unit and terrain hex has a child object on a "miniMapLayer". There is a semi-transparent rectangular object on the miniMapLayer attached to the main camera that shows the visible area. When you click on the minimap it does some basic interpolation to translate the location on the minimap RectTransform to world space and warp the main camera to that location.

    Thanks for the advice... I am pretty n00by when it comes to programming structure (completely self taught) and usually just bash away until I get something that works. What exactly about enums make them easier to keep track of?
     
  37. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    39
    Oh that's how you are doing it? I was going to use that approach but i was worried it would be a pain in the butt to implement for everything since i would have to add the image to all my prefabs and such lol. Maybe i should do it that way. It looks great.

    About enums,

    They are more readable in code, They are less open to human error, since you could make a typo if you just are keeping track of the unit type as a string, and also you always have a reference to what enum number corresponds to what, and your editor will keep track of it too. And unity also understands enums and you can assign by dropdown in the unity UI instea dof having to type or code it in
    Capture.PNG .
    Enum ^


    Use case (This code needs to be cleaned up but you get the point):
    Capture2.PNG


    And you can still retrieve the string representation if you want:
    Capture.PNG Capture.PNG
    Also makes it easier to keep track of for things like switch statements, and its easier to save, and makes using it for things easier, eg i also use this enum in my map gen, i just assign a number in a 2d array (which is just a 2d array of ushorts and can generate and load the map that way. In the past i have used strings but strings become unmanageable extremely quickly and its inefficient from a speed and memory perspective as-well (a string versus an unsigned short)
    Capture3.PNG
     
    Last edited: Jan 16, 2021
    Panhypersebastos likes this.
  38. Untrustedlife

    Untrustedlife

    Joined:
    Apr 21, 2020
    Posts:
    39
    I usually just delete the unit, it should run its OnDestroyed event and assuming thats set up properly it should clean up the data
     
  39. Panhypersebastos

    Panhypersebastos

    Joined:
    Feb 21, 2017
    Posts:
    31
    Just released a playable version of my game "Egypt vs. Aliens" for free on itch.io

    https://tensionsplice.itch.io/egyptvsaliens



    Not sure if I'll develop it further or start on a new one taking advantage of everything I've learned on this one.

    Some stuff that I added above what is contained in the base kit

    • Different unit types with different behaviours including:
      • Fortifying to increase defensive strength
      • Healing other units
      • Ships that can ferry units across rivers
      • Artillery that can support adjacent units in combat
    • Basic economic system (cities generate gold which you can use to buy units)
    • Fog of war
    • Attacking units take damage
    • Minimap
    Overall I liked working with this asset and it saved alot of time vs developing from scratch. If I had one criticism I would say that it should contain fog of war out of the box since almost everyone is going to want to add that to their game.
     
  40. grugroo128

    grugroo128

    Joined:
    Oct 2, 2020
    Posts:
    2
    Hello There! I wonder if someone has made a Final Fantasy Tactics Like game out of this Framework ?
    I did manage to make a "Turn Order Manager" that take place on End Turn and allows only one unit to play each turn but now I 'm lost and don't know where to start to add Skills (i want to supress the Attack State and add a "choose one skill do the skill" ...) where should i write the logic ? in a new state ? cell grid state ? in the Units ?

    By the way thank you for the Asset !
     
    Last edited: Jan 19, 2021
  41. Letvio

    Letvio

    Joined:
    Jan 5, 2021
    Posts:
    1
    Hello,
    @grugroo128 i would really like if you explain in details how you did make your "Turn Order Manager" i'm trying to do something similar but as i am a beginner i am breaking my teeth on it.
    I want to make the units play in an order managed by an initiative statistic, and playing only once per turn for every units then its next turn.
    It is a bit different than FFT but should be made in a similar way i would guess.
    Sry for bad english.
     
  42. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    @Untrustedlife Thanks for this ctrl+r trick :)
    @squirmonkey Glad it works for you. It's a really obscure bug that's hard for me to track, If you happen to find a reliable way to reproduce it, please let me know

    @grugroo128 It would be great if you could describe what you did so far. Regarding special skills, I would definately code it in GridState. Either use GridStateUnitSelected or a new one
     
  43. grugroo128

    grugroo128

    Joined:
    Oct 2, 2020
    Posts:
    2
    Hello there !
    @Letvio Hey Letvio ! I would be glad to help you ! just send me an E-Mail (grugroo128@gmail.com) and i can show you the TurnManager stuff i did.

    @michal-zetkowski Michal first thing first Thank You a lot for your Asset !
    since I writed the message I managed to make skill work even with radius and i glad with that for the moment my code is a bit messy and there is no Art on it so i will share more latter ^^ but I have now an other question,

    do you know how to use the Pathfinding to create Lign of sight ? I would like that my ranged units can't attack thrue obstacle or other units...

    if there is some documentation about this it could save me some time ^^

    sorry for my inconsistent english ^^
     
  44. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Hey, as always mr Amit Patel got us covered :) Take a look at these resources. You could code it in unit.IsUnitAttackable, but the problem is that this function has only the unit as the parameter. You will need to add additional parameters, but that's a minor issue.

    https://www.redblobgames.com/grids/hexagons/#line-drawing
    https://www.redblobgames.com/grids/line-drawing.html
     
  45. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    By the way, I'm working on a total AI overhaul. The new system will be modular, reusable and heavily parameterizable. It's already possible to get pretty cool results with it, and messing around with different parameters is a lot of fun. In the screenshots you can see AI debug mode where you can check out how the AI evaluates different positions. Looking forward to releasing it!

    scr3.png scr4.png scr5.png scr1.png scr2.png
     
    Last edited: Jan 24, 2021
  46. Jor_Brando

    Jor_Brando

    Joined:
    Jan 24, 2021
    Posts:
    4
    Hello, sir.

    Is there a way to make it so that, even if you have a total of six units, you can only move 2 units at a time (and not all six) during each of your turns, then your turn ends?

    Thank you for all your wonderful work on this asset.
     
  47. easterberry

    easterberry

    Joined:
    Nov 19, 2020
    Posts:
    2
    Hello, I was wondering if there's a way to implement walls in your framework. To clarify: I want to have a square grid map functioning as a building floorplan, with the walls being between squares IE I don't want the walls to be a full cell thick, I want it to be possible for 1 unit to be in cell 1,1 and another to be in cell 1,2 and a wall to be between them. Is this possible?
     
  48. tblan

    tblan

    Joined:
    Jan 23, 2018
    Posts:
    3
    @easterberry I asked this question the other day and michal-zetkowski was able to point me in the right direction. I don't think he would mind if I post my implementation based on his feedback.

    (I should note that all of the code below should be added to a class that is derived from Square)

    1. Add flags, in the form of bool fields, to your Square called hasWallNorth, hasWallEast, hasWallSouth, and hasWallWest.

    2. Set up the flags for each cell that has walls in the editor .

    3. Override GetNeighbours method in you Cell script to only return cells that have no walls between them (additionally I made a helper method called CheckWalls to make the code more readable).

    AddVariables.png Set Up Flags.png Override GetNeighbours.png
     
    Last edited: Jan 26, 2021
    michal-zetkowski and easterberry like this.
  49. easterberry

    easterberry

    Joined:
    Nov 19, 2020
    Posts:
    2
    thanks! Exactly what I needed
     
  50. michal-zetkowski

    michal-zetkowski

    Joined:
    Mar 11, 2015
    Posts:
    163
    Hey, Take a look at CellGridStateUnitSelected script, I would code it there. You could add a static field to the script that would store number of moves taken in the current turn (increase it in OnUnitClicked or OnCellClicked - this is where moving and attacking is handled). When the variable reaches your maximum value, just call _cellGrid.EndTurn()
     
unityunity