-1

I've got this error and need help, it is on (92,28), but the error has remained, any help would be appreciated, Im relatively new to programming in c# so I'm not entirely familiar with the programming language yet, so this is probably a beginner question, but even so, an answer and and explanation as to what i did wrong as so I can improve upon myself is always appreacited.

using UnityEngine;

[CreateAssetMenu(fileName = "Pokemon", menuName = "Pokemon/Create New Pokemon")]

public class PokemonBase : ScriptableObject
{
    [SerializeField] string name;

    [TextArea]
    [SerializeField] string description;

    [SerializeField] Sprite frontSprite;
    [SerializeField] Sprite backSprite;

    [SerializeField] PokemonType type1;
    [SerializeField] PokemonType type2;

    //Base Stats
    [SerializeField] int maxHp;
    [SerializeField] int attack;
    [SerializeField] int defense;
    [SerializeField] int spAttack;
    [SerializeField] int spDefense;
    [SerializeField] int speed;

    [SerializeField] List<LearnableMove> learnableMoves;


    public string Name
    {
        get { return name; }
    }

    public string Description
    {
        get { return description; }
    }

    public Sprite FrontSprite
    {
        get { return frontSprite; }
    }

    public Sprite BackSprite
    {
        get { return backSprite; }
    }

    public PokemonType Type1
    {
        get { return type1; }
    }

    public PokemonType Type2
    {
        get { return type2; }
    }

    public int MaxHp
    {
        get { return maxHp; }
    }

    public int Attack
    {
        get { return attack; }
    }

    public int Defense
    {
        get { return defense; }
    }

    public int SpAttack
    {
        get { return spAttack; }
    }

    public int SpDefense
    {
        get { return spDefense; }
    }

    public int Speed
    {
        get { return speed; }
    }

}

public List<LearnableMove> LearnableMoves 
{
    get { return learnableMoves; }
}

[System.Serializable]

public class LearnableMove
{
    [SerializeField] MoveBase moveBase;
    [SerializeField] int level;

    public MoveBase Base
    {
        get { return moveBase; }
    }

    public int Level
    {
        get { return level; }
    }
}

public enum PokemonType
{
    None,
    Normal,
    Fire,
    Water,
    Grass,
    Electric,
    Ice,
    Fighting,
    Poison,
    Ground,
    Flying,
    Physic,
    Bug,
    Rock,
    Ghost,
    Dragon
} ``` 
  • 1
    `LearnableMoves` doesn't appear to be inside a class. It must be. –  Mar 27 '21 at 02:58
  • In general in C#, you need to have all class and other definitions within a namespace. With definitions extending some Unity bases like `MonoBehaviour`s and `ScriptableObject`s this is not the case. You should put everything but `PokemonBase` in another file within a namespace. See for example usage. https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/ – Omar Abdel Bari Mar 27 '21 at 12:49
  • Note this is how `using` keyword works. It includes all accessible classes, structs... etc within a namespace so you can use it in another file. Also, I'm not sure if you would be able to keep it in the same file. I never tried but I generally advise you keep classes and structs in separate files. – Omar Abdel Bari Mar 27 '21 at 12:51
  • Probably a **TYPO**: your class is closed to early by the `}` before `LearnableMoves` – derHugo Mar 27 '21 at 15:47

1 Answers1

1

Move the closing brace between Speed and LearnableMoves so that the latter is enclosed inside the class

    public int Speed
    {
        get { return speed; }
    }

}

public List<LearnableMove> LearnableMoves 
{
    get { return learnableMoves; }
}

To

    public int Speed
    {
        get { return speed; }
    }

    public List<LearnableMove> LearnableMoves 
    {
        get { return learnableMoves; }
    }
}
Hellium
  • 7,206
  • 2
  • 19
  • 49