Exemple #1
0
    public void Initialize()
    {
        StateController.AddPieka(this);


        System.Attribute[] att = (System.Attribute[])GetType().GetCustomAttributes(true);


        foreach (System.Attribute attribute in att)
        {
            if (attribute is AllowedState)
            {
                AllowedState allowedState = (AllowedState)attribute;
                isInActiveState = false;
                allowedStates.Add(allowedState.Name);
            }
        }

        MethodInfo[] methods = GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

        foreach (MethodInfo m in methods)
        {
            System.Attribute[] attributes = (System.Attribute[])m.GetCustomAttributes(true);


            foreach (System.Attribute attribute in attributes)
            {
                if (attribute is OnEvent)
                {
                    OnEvent onEventMethod = (OnEvent)attribute;



                    if (m.GetParameters().Length == 2)
                    {
                        PMEvent del = (PMEvent)Delegate.CreateDelegate(typeof(PMEvent), this, m);
                        events.Add(new PairEventString(onEventMethod.Name, del));
                    }
                    else
                    {
                        PMEventLite del = (PMEventLite)Delegate.CreateDelegate(typeof(PMEventLite), this, m);
                        eventsLite.Add(new PairEventLiteString(onEventMethod.Name, del));
                    }



                    //	SEventSystem.Register ( onEventMethod.Name, (PMEvent)PMEvent.CreateDelegate( typeof(PMEvent), m ) );
                }
            }
        }
        RegisterAll();
        OnStateChange(StateController.GetActiveState());
    }