Exemplo n.º 1
0
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
        //     Public Static Method
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

        /// <summary>
        /// コード値から通行許可設定インスタンスを生成する。
        /// </summary>
        /// <param name="code">コード値</param>
        /// <returns>通行許可設定インスタンス</returns>
        public static ITilePathSetting Create(int code)
        {
            var permission = TilePathPermission.FromCode(code);

            if (permission == TilePathPermission.Allow)
            {
                return(new TilePathSettingAllow(code));
            }

            if (permission == TilePathPermission.Dependent)
            {
                return(new TilePathSettingDependent(code));
            }

            if (permission == TilePathPermission.Deny)
            {
                return(new TilePathSettingDeny(code));
            }

            if (permission == TilePathPermission.PartialDeny)
            {
                return(new TilePathSettingPartialDeny(code));
            }

            throw new InvalidOperationException();
        }
Exemplo n.º 2
0
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
        //     Constructor
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

        public TilePathSettingFactoryChangePathPermissionHelper(TilePathPermission pathPermission,
                                                                ITilePathSetting src, TileImpassableFlags impassableFlags, TileCannotPassingFlags cannotPassingFlags)
        {
            this.pathPermission     = pathPermission;
            this.src                = src;
            this.impassableFlags    = impassableFlags;
            this.cannotPassingFlags = cannotPassingFlags;
        }
Exemplo n.º 3
0
        private static ITilePathSetting Create_ImpassableToImpassable(TilePathPermission pathPermission,
                                                                      ITilePathSetting src, TileImpassableFlags impassableFlags)
        {
            if (pathPermission == TilePathPermission.PartialDeny)
            {
                return(new TilePathSettingPartialDeny(impassableFlags ?? src.ImpassableFlags)
                {
                    PathOption = src.PathOption,
                    IsCounter = src.IsCounter
                });
            }

            throw new InvalidOperationException();
        }
Exemplo n.º 4
0
        private static ITilePathSetting Create_ToDifference(TilePathPermission pathPermission,
                                                            ITilePathSetting src)
        {
            if (pathPermission == TilePathPermission.Allow)
            {
                return(new TilePathSettingAllow
                {
                    PathOption = src.PathOption,
                    IsCounter = src.IsCounter
                });
            }

            if (pathPermission == TilePathPermission.Dependent)
            {
                return(new TilePathSettingDependent
                {
                    PathOption = src.PathOption,
                    IsCounter = src.IsCounter
                });
            }

            if (pathPermission == TilePathPermission.Deny)
            {
                return(new TilePathSettingDeny
                {
                    PathOption = src.PathOption,
                    IsCounter = src.IsCounter
                });
            }

            if (pathPermission == TilePathPermission.PartialDeny)
            {
                return(new TilePathSettingPartialDeny
                {
                    PathOption = src.PathOption,
                    IsCounter = src.IsCounter
                });
            }

            throw new InvalidOperationException();
        }
Exemplo n.º 5
0
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
        //     Private Static Method
        // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

        private static ITilePathSetting Create_CannotPassingToCannotPassing(TilePathPermission pathPermission,
                                                                            ITilePathSetting src, TileCannotPassingFlags cannotPassingFlags)
        {
            if (pathPermission == TilePathPermission.Allow)
            {
                return(new TilePathSettingAllow(cannotPassingFlags ?? src.CannotPassingFlags)
                {
                    PathOption = src.PathOption,
                    IsCounter = src.IsCounter
                });
            }

            if (pathPermission == TilePathPermission.Dependent)
            {
                return(new TilePathSettingDependent(cannotPassingFlags ?? src.CannotPassingFlags)
                {
                    PathOption = src.PathOption,
                    IsCounter = src.IsCounter
                });
            }

            throw new InvalidOperationException();
        }
Exemplo n.º 6
0
 /// <summary>
 /// 通行設定を変更したインスタンスを生成する。
 /// </summary>
 /// <param name="pathPermission">[NotNull] 通行設定</param>
 /// <param name="src">[NotNull] 元データ</param>
 /// <param name="impassableFlags">[Nullable] 通行許可設定</param>
 /// <param name="cannotPassingFlags">[Nullable] 通行方向設定</param>
 /// <returns>変更後のインスタンス</returns>
 public static ITilePathSetting Create(TilePathPermission pathPermission, ITilePathSetting src,
                                       TileImpassableFlags impassableFlags = null, TileCannotPassingFlags cannotPassingFlags = null)
 {
     return(new TilePathSettingFactoryChangePathPermissionHelper(pathPermission, src,
                                                                 impassableFlags, cannotPassingFlags).Execute());
 }