Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Implementing Pokemon style system

Discussion in 'Scripting' started by Acissathar, Mar 11, 2015.

  1. Acissathar

    Acissathar

    Joined:
    Jun 24, 2011
    Posts:
    669
    Hey everyone, looking for some ideas / advice.

    Basically what I am trying to do is make a combat system based off of Pokemon and I'm trying to think of the best way to implement it.

    Right now each Pokemon species is going to be it's own class, and they will have an array to store the total number of moves. Using this each move would be an object, and that object's class would store the power, pp, element, name, and accuracy.

    The problem I see with this is I will easily reach a large number of classes containing only a few lines of code just setting the values for the variables in each move.

    I'm sure there is an easier way about this but I'm drawing a blank.
     
  2. Random_Civilian

    Random_Civilian

    Joined:
    Nov 5, 2014
    Posts:
    55
    You might want to look at ScriptableObjects. Make a base move as a container for name, stats, moves, etc.
     
    Last edited: Mar 11, 2015
  3. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    You only need one class for all the moves. And I would also store them in a serializable list so you can save it to disk.

    All you need to do is decide how to determine which moves a pokemon can learn.
    Code (CSharp):
    1. // This class is nothing more then a model and
    2. // can be serialized. That way you can just save
    3. // the entire move store in some serialized
    4. // data file on disk.
    5. [Serializable]
    6. public class Move
    7. {
    8.     string name;
    9.     string maxPP;
    10.     string power;
    11.     string accuracy;
    12.     // etc.
    13. }
    14.  
    15. // This is the data store of the entire moveset.
    16. // Add moves by adding this object to a gameObject,
    17. // and make sure you have a save and load script so
    18. // you can save and load a serialized object to disk.
    19. [Serializable]
    20. public class MoveStore
    21. {
    22.     public List<Move> moves;
    23. }
     
  4. Acissathar

    Acissathar

    Joined:
    Jun 24, 2011
    Posts:
    669
    Thank you very much for this. It makes a lot more sense, and I'm not sure why I was thinking every move needs its own class.
     
  5. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Don't worry about that. I make that type if mistake myself often enough ;)