// Heittää poikkeuksen jos komponenttia ei pystytty luomaan.
        private void ThrowFailedToResolve(MapComponentData mapComponentData)
        {
            string namespaces = "";

            Array.ForEach(componentNamespaces, s => namespaces += s + Environment.NewLine);

            throw new Exception("Component " + mapComponentData.ComponentName + " could not be resolved! " +
                                "Namespaces are " + namespaces + Environment.NewLine +
                                "Please check syntax and namespaces.");
        }
Пример #2
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Пример #3
0
        /// <summary>
        /// Luo uuden komponentin datan perusteella.
        /// </summary>
        public MapComponent MakeNew(MapComponentData mapComponentData)
        {
            Type         componentType = null;
            MapComponent mapComponent  = null;

            foreach (string componentNamespace in componentNamespaces)
            {
                componentType = Type.GetType(componentNamespace + "." + mapComponentData.ComponentName);
                if (componentType != null)
                {
                    break;
                }
            }
            if (componentType != null)
            {
                ILayer layer = map.LayerManager.GetLayer <ILayer>(l => l.Name == mapComponentData.LayerName);

                mapComponent = (MapComponent)Activator.CreateInstance(componentType, game, map, layer);

                mapComponent.Initialize(mapComponentData);
            }

            return(mapComponent);
        }
Пример #4
0
 /// <summary>
 /// Metodi jossa tulee alustaa komponentin toiminnallisuus
 /// ja parsia tarvittavat tiedot MapComponentData oliosta.
 /// </summary>
 public abstract void Initialize(MapComponentData data);