C#, using a delegate function in a dictionary, code optimization public vs protected : Hi there I'm currrently trying to optimize some code. As I'm still new to coding I try to use this oppurtunity to learn new "complicated" features.  So now I'm stuck with delegate functions and lambda operators and don't know how to use them properly. My goal is to have a class which has one static Dictionary in which all values for different types of enemies I want for my game are stored. My current code probably works(didn't test it yet) but I don't fully understand it...



public class EnemyTypes {



    private class TypeValues
    {
        public delegate void Func(Transform Entity);//just used for handing over values on initialization, somehow has to be public

        private string Name; //the Name of an EnemyType, NOT the name of a specific entity
        private float BaseSpeed; //actual speed of each enemy is randomly set within (BaseSpeed +/- SpeedTolerance) everytime it respawns
        private float SpeedTolerance;
        private Func Animate;

        public TypeValues(string Name, float BaseSpeed, float SpeedTolerance, Func Animate) //constructor apparently needs to be public too?
        {
            this.Name = Name;
            this.BaseSpeed = BaseSpeed;
            this.SpeedTolerance = SpeedTolerance;
            this.Animate = Animate;
        }

    }

    [SerializeField]
    private static Dictionary<int, TypeValues> Types = new Dictionary<int, TypeValues>
    {
        {1, new TypeValues("Standard", 1f, 0.5f, Entity => Entity.Rotate(new Vector3(0, 5, 0)))}

    };
}



As you can read form the comments I don't understand why the delegate and the constructor have to have the same access modifier. And why can't it be protected? Also is there a way to get rid of Func and define the delegate directly when creating the ANimate variable?
I feel kinda dumb...please help ^^
Also excuse my bad english and some capital letters that may have found their way into my question...

