コード例 #1
0
        // TODO: check filesize by zero or less than min rows
        public Algorithm(AlgorithmType algorithmType, long filesize)
        {
            AlgorithmType = algorithmType;

            switch (algorithmType)
            {
            case AlgorithmType.Fast:
            {
                TextGenerator = new FastTextGenerator(filesize);
                break;
            }

            case AlgorithmType.Rand:
            {
                TextGenerator = new RandomTextGenerator(filesize, new RowGenerator());
                break;
            }

            case AlgorithmType.RandWithDuplicates:
            {
                TextGenerator = new RandomTextGenerator(filesize, new RowGeneratorWithRepeat(10));
                break;
            }

            default:
                throw new ArgumentException($"unknown algorithm {algorithmType}");
            }
        }
コード例 #2
0
 public MainMenuScreenHandler(
     ITextGenerator textGenerator,
     IMainMenuHandler handler,
     IPrinter <MainMenuPrinter.State> printer) : base(textGenerator, printer)
 {
     _createCharacterTyper = MakeUniqueTyper();
     _handler = handler;
 }
コード例 #3
0
    private void Awake()
    {
        if (audioManager == null)
        {
            Debug.LogError("Audio manager is empty");
            return;
        }

        if (particleEffectsManager == null)
        {
            Debug.LogError("Particle effects manager is empty");
            return;
        }

        if (activePlayerProfile == null)
        {
            Debug.LogError("Active player profile is empty");
            return;
        }

        if (playerProfileForGameScene == null)
        {
            Debug.LogError("Temprory player profile is empty");
            return;
        }

        playerProfileForGameScene.Set(new PlayerProfile());

        if (assetsReferences == null)
        {
            Debug.LogError("Assets with dictiinaries is empty!");
            return;
        }

        var textGeneratorFactory = new TextGeneratorFactory(gameSettings.variable, assetsReferences.variable);

        currentTextGenerator = textGeneratorFactory.GetTextGenerator();

        if (currentTextGenerator == null)
        {
            Debug.LogError("Cannot create text generator!");
            return;
        }

        // Components
        AssignComponents();
        AssignCompomnentsReferences();

        // Events
        AssignPlayerProfileEventsToManager();
        AssignTargetEventsToManager();
        AssignPauseEventsFromManager();
        AssignAudioEvents();
        AssignVFXEventsToEventsManager();

        pauseManager.ResumeGame();
        timer.OnTick.AddListener(spawnManager.Spawn);
    }
コード例 #4
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="writer">Генератор текста.</param>
        public Speaker(ITextGenerator writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            _writer = writer;
        }
コード例 #5
0
 public CharacterCreationScreenHandler(
     ITextGenerator textGenerator,
     ICharacterCreationHandler characterCreationHandler,
     IPrinter <CharacterCreationPrintableState> printer)
     : base(textGenerator)
 {
     _returnBackToMainMenuTyper = MakeUniqueTyper();
     _characterCreationHandler  = characterCreationHandler;
     _printer = printer;
 }
コード例 #6
0
        public DialogModalScreenHandler(
            ITextGenerator textGenerator,
            IOutput output) : base(textGenerator)
        {
            _output = output;

            _text         = null !;
            _ok           = null !;
            _cancel       = null !;
            _okAction     = null !;
            _cancelAction = null !;
        }
コード例 #7
0
ファイル: TextChain.cs プロジェクト: kesac/Loremaker
        public TextChain DefineGlobally(string key, ITextGenerator generator)
        {
            if (this.GlobalEntities.Keys.Contains(key))
            {
                throw new InvalidOperationException(string.Format("A global entity with key '{0}' was previously defined.", key));
            }
            else
            {
                this.GlobalEntities[key] = generator;
            }

            return(this);
        }
コード例 #8
0
        public static void Print(this ITextGenerator textGenerator, Comment comment, CommentKind kind)
        {
            var sections = new List <Section> {
                new Section(CommentElement.Summary)
            };

            GetCommentSections(comment, sections);
            foreach (var section in sections)
            {
                TrimSection(section);
            }
            FormatComment(textGenerator, sections, kind);
        }
コード例 #9
0
ファイル: TextTemplate.cs プロジェクト: kesac/Loremaker
        public TextTemplate Define(string key, ITextGenerator generator)
        {
            if (!this.EntityPlaceholders.Contains(key))
            {
                throw new InvalidOperationException(string.Format("No entity with key '{0}' was defined through the TextGenerator constructor.", key));
            }
            else
            {
                this.EntityDefinitions[key] = generator;
            }

            return(this);
        }
コード例 #10
0
        /// <summary>
        /// Constructor initializes all internal instances and bind with external dependencies
        /// </summary>
        /// <param name="_textGenerator">Instance of text generator class</param>
        public Client(ITextGenerator _textGenerator)
        {
            IPHostEntry ipHost     = Dns.GetHostEntry("localhost");
            IPAddress   ipAddr     = ipHost.AddressList[0];
            IPEndPoint  ipEndPoint = new IPEndPoint(ipAddr, 11000);

            sender = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            sender.Connect(ipEndPoint);

            textGenerator = _textGenerator;

            bufferSize    = sender.ReceiveBufferSize;
            messagesCount = 10;
            delay         = 5000;
        }
コード例 #11
0
        private static void FormatComment(ITextGenerator textGenerator, List <Section> sections, CommentKind kind)
        {
            var commentPrefix = Comment.GetMultiLineCommentPrologue(kind);

            sections.Sort((x, y) => x.Type.CompareTo(y.Type));
            var remarks = sections.Where(s => s.Type == CommentElement.Remarks).ToList();

            if (remarks.Any())
            {
                remarks.First().GetLines().AddRange(remarks.Skip(1).SelectMany(s => s.GetLines()));
            }
            if (remarks.Count > 1)
            {
                sections.RemoveRange(sections.IndexOf(remarks.First()) + 1, remarks.Count - 1);
            }

            foreach (var section in sections.Where(s => s.HasLines))
            {
                var lines      = section.GetLines();
                var tag        = section.Type.ToString().ToLowerInvariant();
                var attributes = string.Empty;
                if (section.Attributes.Any())
                {
                    attributes = ' ' + string.Join(" ", section.Attributes);
                }
                textGenerator.Write($"{commentPrefix} <{tag}{attributes}>");
                if (lines.Count == 1)
                {
                    textGenerator.Write(lines[0]);
                }
                else
                {
                    textGenerator.NewLine();
                    foreach (var line in lines)
                    {
                        textGenerator.WriteLine($"{commentPrefix} <para>{line}</para>");
                    }
                    textGenerator.Write($"{commentPrefix} ");
                }
                textGenerator.WriteLine($"</{tag}>");
            }
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: matyc777/OOPExample
        static void Main(string[] args)//количество фигур, количество групп
        {
            container = ContainerClass.GenerateContainer(int.Parse(args[0]), int.Parse(args[1]));

            Console.WriteLine("Press Spacebar for .html output, other for .txt");

            ConsoleKeyInfo key = Console.ReadKey(false);

            if (key.Key == ConsoleKey.Spacebar)
            {
                container.Configure(_ =>
                {
                    _.For(typeof(IOutput)).Use(typeof(HtmlFileOutput));
                });
            }
            else
            {
                container.Configure(_ =>
                {
                    _.For(typeof(IOutput)).Use(typeof(TextFileOutput));
                });
            }

            try
            {
                IContentGenerator content = container.GetInstance <IContentGenerator>();

                ITextGenerator Text = container.GetInstance <ITextGenerator>();

                IOutput fileOutput = container.GetInstance <IOutput>();

                fileOutput.Write(Text.GenerateText(content.GenerateContent() as IEnumerable <Tuple <List <Figure>, (double Min, double Max)> >));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadKey();
            }
        }
コード例 #13
0
    public ScreenFactory(
        ITextGenerator textGenerator,
        IConnectionManager connectionManager,
        ICharactersClient charactersClient,
        ILocationsClient locationsClient,
        IOutput output,
        IPrinter <MainMenuState> mainMenuPrinter,
        IPrinter <CharacterCreationState> characterCreationPrinter,
        IPrinter <WorldScreenState> worldPrinter)
    {
        _textGenerator            = textGenerator;
        _connectionManager        = connectionManager;
        _charactersClient         = charactersClient;
        _locationsClient          = locationsClient;
        _output                   = output;
        _mainMenuPrinter          = mainMenuPrinter;
        _characterCreationPrinter = characterCreationPrinter;
        _worldPrinter             = worldPrinter;

        // Create this only after initializing everything inside ScreenFactory.
        ScreenNavigation = new ScreenNavigation(this);

        Task.Run(() => ScreenNavigation.Screen = GameScreen.MainMenu);
    }
コード例 #14
0
 public TextSender()
 {
     _httpClient = new HttpClient();
     _generator  = new TextGenerator();
 }
コード例 #15
0
 protected MultiTyperInputHandler(ITextGenerator textGenerator)
 {
     _textGenerator = textGenerator;
 }
コード例 #16
0
 public UniqueTyperPool(ITextGenerator textGenerator)
 {
     _textGenerator = textGenerator;
 }
コード例 #17
0
 public NumberFormatVerifier(INumberVerifierSettings settings, ITextGenerator textGenerator)
 {
     VerificationSettings = settings;
     TextGenerator        = textGenerator;
 }
コード例 #18
0
ファイル: MainProgram.cs プロジェクト: rbteched/HelloWorld
 public MainProgram(IConsole console, ITextGenerator textGenerator)
 {
     _console       = console;
     _textGenerator = textGenerator;
 }
コード例 #19
0
 public TextsController(ITextGenerator textGenerator)
 {
     _textGenerator = textGenerator;
 }
コード例 #20
0
 public HomeController(ITextGenerator TextGenerator, ITrigramGenerator TrigramGenerator)
 {
     _TextGenerator    = TextGenerator;
     _TrigramGenerator = TrigramGenerator;
 }
コード例 #21
0
 public void OneTimeSetUp()
 {
     trigram       = new TrigramGenerator();
     textGenerator = new TextGenerator();
 }