Example #1
0
 public static void RegistEvent(EVENTTYPE eventType, EVENTID eventID, UnityAction action)
 {
     if (dic.Get(eventType, eventID) == default(UnityEvent))
     {
         dic.Set(eventType, eventID, new UnityEvent());
     }
     dic.Get(eventType, eventID).AddListener(action);
 }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        prefabMap = new MultiDictionary <int, int, GameObject>();
        foreach (UIConfig cfg in uiConfig)
        {
            prefabMap.Set(cfg.order, cfg.idx, cfg.prefab);
        }
        curUIOrder = 0;
        curUIIdx   = 0;
        GameObject prefab = prefabMap.Get(curUIOrder, curUIIdx);

        curUIInst = Instantiate(prefab);
        curUIInst.transform.SetParent(gameObject.transform);
        curUIInst.GetComponent <LobbyUIBase>().SetLobbyInst(this);
    }
Example #3
0
        private TypeMethodInfo resolveGenericBinding(TypeMethodInfo methodDefinition)
        {
            if (!_genericBindings.Keys.Any())
            {
                //there are no bindings available
                return(methodDefinition);
            }

            var translations = new Dictionary <string, string>();

            foreach (var param in _genericBindings.Keys)
            {
                var translatedName = param.Type.TypeName;
                if (translations.ContainsKey(translatedName))
                {
                    //we already have translation
                    continue;
                }

                var bindings = _genericBindings.Get(param).ToArray();
                if (bindings.Length > 1)
                {
                    throw new NotImplementedException("Determine binding for parametric parameters");
                }

                translations.Add(translatedName, bindings[0].TypeName);
            }

            //remap argument bindings from definitions parameters to current method parameters
            var genericMethod = methodDefinition.MakeGenericMethod(translations);

            for (var i = 0; i < genericMethod.Parameters.Length; ++i)
            {
                var currentParameter = genericMethod.Parameters[i];
                var oldParameter     = methodDefinition.Parameters[i];

                var args = _argBindings.Get(oldParameter);
                _argBindings.Set(currentParameter, args);
            }

            return(genericMethod);
        }