Exemplo n.º 1
0
	public void Initialize(AppManager appManager, AppBehaviour installedApp)
	{
		manager = appManager;
		app = installedApp;

		GetComponent<Image>().sprite = app.iconTexture;
		GetComponent<Button>().onClick.AddListener(LaunchApp);

		_appBehaviourInstance = Instantiate(app);

		_appBehaviourInstance.transform.SetParent(appManager.instanceContainer);

		_appBehaviourInstance.On(AppBehaviour.AppEvent.Done, data =>
		{
			_appBehaviourInstance.Cleanup();

			manager.AppDone(app);
		});

		_appBehaviourInstance.On(AppBehaviour.AppEvent.Notification, data =>
		{
			var notificationData = (Notification) data;

			manager.AddAppNotification(app, notificationData);

			ShowNotifications(manager.GetAppNotifications(app));
		});

		_appBehaviourInstance.On(AppBehaviour.AppEvent.DismissNotification, data =>
		{
			var notificationData = (Notification) data;

			manager.DismissAppNotification(app, notificationData);

			ShowNotifications(manager.GetAppNotifications(app));
		});
	}