I am not sure why but I always struggle with figuring this basic scripting piece out. I am trying to use a Parent and Child class to make my code cleaner and easier to read and work with. So I set a base class with Getters and Setters:
using UnityEngine;
using System.Collections;
public class BaseSkill : MonoBehaviour
{
//These are the different aspects of a skill
private string _name;
private int _maxPoints;
private int _curPoints;
private string _description;
#region Getters and Setters
public string Name
{
get{return _name;}
set{_name = value;}
}
public string MaxPoints
{
get{return _maxPoints;}
set{_maxPoints = value;}
}
public string CurPoints
{
get{return _curPoints;}
set{_curPoints = value;}
}
public string Description
{
get{return _description;}
set{_description = value;}
}
#endregion
}
And then I inherit from it:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// This script is attached to the multiplayerManager and keeps track of what skills the player has available in a list.
/// Skills are kept track of by a point system. Each player has a certain amount of skill points to spend. If they spend a point
/// in a certain skill they gain the function of that skill.
/// </summary>
///
public class PlayerSkills : BaseSkill
{
//Skill points player can spend
public int skillPoints;
//List of Player Skills here
public List<BaseSkill> MySkills = new List<BaseSkill>();
//Create the first skill
BaseSkill SwiftFeet = new BaseSkill();
SwiftFeet.Name = "SwiftFeet";
}
But… On the line SwiftFeet.Name = “SwiftFeet”; I get this error:
error CS1519: Unexpected symbol `=’ in class, struct, or interface member declaration
What am I doing wrong and how can I set those base variables through my getters and setters for my newly created skill? As you can probably see I am trying to create skills that all have similar attibutes, a name, description, maxPoints, etc. I need to set these variables for each skill and then I want to add these into a list for the player. Thanks in advance.