public static ICellRegistrator CreateCellRegistrator()
        {
            INotifier        notifier        = new Notifier();
            IUpdateManager   updateManager   = CreateUpdateManager();
            ICellRegistrator cellRegistrator = new CellRegistrator(notifier, updateManager);

            return(cellRegistrator);
        }
        public static IBoard CreateBoard(int width, int height)
        {
            IMasterManager masterManager = CreateMasterManager();

            ISpawnManager    spawnManager    = masterManager.SpawnManager;
            INotifier        notifier        = masterManager.GameplayNotifier;
            IUpdateManager   updateManager   = masterManager.UpdateManager;
            ICheckManager    checkManager    = new CheckManager();
            ICellRegistrator cellRegistrator = new CellRegistrator(notifier, updateManager);

            IBoard board = new Board(width, height, spawnManager, checkManager, cellRegistrator);

            return(board);
        }
        public IEnumerator Cell_SwapAndUndo(SwapTypes swapType)
        {
            #region Create Managers

            IMasterManager masterManager = ObjectsCreator.CreateMasterManager();

            ISpawnManager    spawnManager    = masterManager.SpawnManager;
            INotifier        notifier        = masterManager.GameplayNotifier;
            IUpdateManager   updateManager   = masterManager.UpdateManager;
            ICellRegistrator cellRegistrator = new CellRegistrator(notifier, updateManager);

            #endregion

            #region Create Cell

            Vector3 position = new Vector3(1, 1, 0);
            ICell   cellA    = spawnManager.SpawnRandomNormalCell(position);
            cellRegistrator.RegistrateNormalCell(cellA as NormalCell);

            #endregion

            #region SetUp UpdateManager

            updateManager.AddUpdatable(cellA as IUpdatable);
            updateManager.IsUpdate = true;

            #endregion

            yield return(new WaitForSeconds(0.3f));

            #region Swap Cell and do Undo

            ICommand swapCommand = TestHelper.GetSwapCommand(swapType, cellA);
            swapCommand.Execute();

            yield return(new WaitForSeconds(0.5f));

            swapCommand.Undo();

            #endregion

            #region Remove From Scene

            yield return(new WaitForSeconds(0.5f));

            GameObject.Destroy(cellA.CurrentGameObject);

            #endregion
        }
Beispiel #4
0
        /// <summary>
        /// Used by datasource when registering all cells to the collection view. If user
        /// did not register custom cells, this method registers default cells
        /// </summary>
        /// <param name="collectionView">Collection view.</param>
        /// <param name="registrator">Registrator.</param>
        /// <param name="cameraMode">Camera mode.</param>
        public static void Apply(this UICollectionView collectionView, CellRegistrator registrator,
                                 CameraMode cameraMode)
        {
            //register action items considering type
            //if user did not register any nib or cell, use default action cell
            if (registrator.HasUserRegisteredActionCell == false)
            {
                registrator.RegisterCellClassForActionItems(typeof(ActionCell));
                var identifier = registrator.CellIdentifier(int.MaxValue);

                if (identifier == null)
                {
                    throw new ImagePickerException("Image Picker: unable to register default action item cell");
                }

                collectionView.RegisterNibForCell(
                    UINib.FromName(nameof(ActionCell), NSBundle.FromIdentifier(nameof(ActionCell))),
                    identifier);
            }
            else
            {
                collectionView.Register(registrator.ActionItemNibsData?.Values);
                collectionView.Register(registrator.ActionItemClassesData?.Values);
            }

            if (registrator.CameraItemNib == null && registrator.CameraItemClass == null)
            {
                switch (cameraMode)
                {
                case CameraMode.Photo:
                case CameraMode.PhotoAndLivePhoto:
                    collectionView.RegisterNibForCell(
                        UINib.FromName(nameof(LivePhotoCameraCell),
                                       NSBundle.FromIdentifier(nameof(LivePhotoCameraCell))),
                        CellRegistrator.CellIdentifierForCameraItem);
                    break;

                case CameraMode.PhotoAndVideo:
                    collectionView.RegisterNibForCell(
                        UINib.FromName(nameof(VideoCameraCell), NSBundle.FromIdentifier(nameof(VideoCameraCell))),
                        CellRegistrator.CellIdentifierForCameraItem);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(cameraMode), cameraMode, null);
                }
            }
            else if (registrator.CameraItemNib != null && registrator.CameraItemClass == null)
            {
                collectionView.RegisterNibForCell(registrator.CameraItemNib, CellRegistrator.CellIdentifierForCameraItem);
            }
            else
            {
                collectionView.RegisterClassForCell(registrator.CameraItemClass.GetType(),
                                                    CellRegistrator.CellIdentifierForCameraItem);
            }

            //register asset items considering type
            collectionView.Register(registrator.AssetItemNibsData?.Values);
            collectionView.Register(registrator.AssetItemClassesData?.Values);

            if (registrator.AssetItemNib == null && registrator.AssetItemClass == null)
            {
                //if user did not register all required classes/nibs - register default cells
                collectionView.RegisterClassForCell(typeof(VideoAssetCell), registrator.CellIdentifierForAssetItems);
                //fatalError("there is not registered cell class nor nib for asset items, please user appropriate register methods on `CellRegistrator`")
            }
            else if (registrator.AssetItemNib != null && registrator.AssetItemClass == null)
            {
                collectionView.RegisterNibForCell(registrator.AssetItemNib, registrator.CellIdentifierForAssetItems);
            }
            else
            {
                collectionView.RegisterClassForCell(registrator.AssetItemClass.GetType(),
                                                    registrator.CellIdentifierForAssetItems);
            }
        }