Пример #1
0
        /// <summary>
        /// Creates the ServiceLocator and registers MonoBehaviors that already exist in the scene.
        /// Does an optional call to ProcessInitializationQueue to resovle the references in the loded monobehaviors.
        /// </summary>
        public void Awake()
        {
            _locator = Locator.Create();

            _locator.Register <IStructureDefinitionManager>(new StructureDefinitionManager());

            _locator.Register <ISpawnManager>(FindObjectOfType <SpawnManager>());
            _locator.Register <ICameraController>(FindObjectOfType <CameraController>());
            _locator.Register <IMapManager>(FindObjectOfType <MapManager>());

            _locator.Register <IStructureFactory>(new StructureFactory());
            _locator.Register <IFactionManager>(new FactionManager());

            _locator.Register <IPlacementValidator>(new PlacementValidator());

            _locator.Register <NewGameManager>(new NewGameManager());

            _locator.Register <IUIManager>(FindObjectOfType <UIManager>());
        }
Пример #2
0
        IGameObject IResourceConverter.Convert(IResource resource)
        {
            if (resource == null)
            {
                return(null);
            }

            IGameObject gob = null;

            if (resource.Type == ResourceTypes.Model)
            {
                Locator locator = Locator.Create();
                IReference <IResource> resRef = ResourceReference.Create(resource);
                locator.Reference = resRef;
                locator.DomNode.InitializeExtensions();
                gob = locator;
            }
            return(gob);
        }