コード例 #1
0
        public void Localization_LocalizedTextFormatting()
        {
            LoadTestLocalizationDatabaseFromXml();

            UsingCulture("fr-FR", () =>
            {
                var formatter = new StringFormatter();
                var buffer    = new StringBuilder();

                formatter.Reset();
                formatter.AddArgument(Localization.Get("SWORD").GetPluralVariant(1));
                formatter.AddArgument(Localization.Get("GLOWING"));
                formatter.Format("test: {?:match:0:def_art}{0} {1:match:0:adj}", buffer);

                TheResultingString(buffer)
                .ShouldBe("test: l'epée rougeoyante");

                formatter.Reset();
                formatter.AddArgument(Localization.Get("SWORD").GetPluralVariant(2));
                formatter.AddArgument(Localization.Get("GLOWING"));
                formatter.Format("test: {?:match:0:def_art}{0} {1:match:0:adj}", buffer);

                TheResultingString(buffer)
                .ShouldBe("test: les epées rougeoyantes");
            });
        }
コード例 #2
0
        public void StringFormatter_CanFormatBooleanArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument(true);
            formatter.AddArgument(false);
            formatter.Format("this is {0} and this is {1}", buffer);

            TheResultingString(buffer).ShouldBe("this is True and this is False");
        }
コード例 #3
0
        public void StringFormatter_CanFormatBooleanArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument(true);
            formatter.AddArgument(false);
            formatter.Format("this is {0} and this is {1}", buffer);

            TheResultingString(buffer).ShouldBe("this is True and this is False");
        }
コード例 #4
0
        public void StringFormatter_CanFormatSingleArgumentWithDecimalsCommand()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument(123.456789f);
            formatter.Format("this is a Single value: {0:decimals:2}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Single value: 123.46");
        }
コード例 #5
0
        public void StringFormatter_CanFormatSingleArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument(123.45f);
            formatter.Format("this is a Single value: {0}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Single value: 123.45000");
        }
コード例 #6
0
        public void StringFormatter_CanFormatInt32Argument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument(12345);
            formatter.Format("this is an Int32 value: {0}", buffer);

            TheResultingString(buffer).ShouldBe("this is an Int32 value: 12345");
        }
コード例 #7
0
        public void StringFormatter_CanFormatCharArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument('Z');
            formatter.Format("this is a Char value: {0}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Char value: Z");
        }
コード例 #8
0
        public void StringFormatter_CanFormatByteArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument((Byte)123);
            formatter.Format("this is a Byte value: {0}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Byte value: 123");
        }
コード例 #9
0
        public void StringFormatter_CanFormatStringArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument("world");
            formatter.Format("hello {0}", buffer);

            TheResultingString(buffer).ShouldBe("hello world");
        }
コード例 #10
0
        public void StringFormatter_CanFormatDoubleArgumentWithDecimalsCommand()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument(123.456789);
            formatter.Format("this is a Double value: {0:decimals:2}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Double value: 123.46");
        }
コード例 #11
0
        public void StringFormatter_CanFormatDoubleArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument(123.45);
            formatter.Format("this is a Double value: {0}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Double value: 123.45000");
        }
コード例 #12
0
        public void StringFormatter_CanFormatCharArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument('Z');
            formatter.Format("this is a Char value: {0}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Char value: Z");
        }
コード例 #13
0
        public void StringFormatter_CanFormatByteArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument((Byte)123);
            formatter.Format("this is a Byte value: {0}", buffer);

            TheResultingString(buffer).ShouldBe("this is a Byte value: 123");
        }
コード例 #14
0
        public void StringFormatter_CanFormatStringArgument()
        {
            var formatter = new StringFormatter();
            var buffer    = new StringBuilder();

            formatter.Reset();
            formatter.AddArgument("world");
            formatter.Format("hello {0}", buffer);

            TheResultingString(buffer).ShouldBe("hello world");
        }
コード例 #15
0
        public void Localization_LocalizedTextFormatting()
        {
            LoadTestLocalizationDatabaseFromXml();

            UsingCulture("fr-FR", () =>
            {
                var formatter = new StringFormatter();
                var buffer = new StringBuilder();

                formatter.Reset();
                formatter.AddArgument(Localization.Get("SWORD").GetPluralVariant(1));
                formatter.AddArgument(Localization.Get("GLOWING"));
                formatter.Format("test: {?:match:0:def_art}{0} {1:match:0:adj}", buffer);

                TheResultingString(buffer)
                    .ShouldBe("test: l'epée rougeoyante");

                formatter.Reset();
                formatter.AddArgument(Localization.Get("SWORD").GetPluralVariant(2));
                formatter.AddArgument(Localization.Get("GLOWING"));
                formatter.Format("test: {?:match:0:def_art}{0} {1:match:0:adj}", buffer);

                TheResultingString(buffer)
                    .ShouldBe("test: les epées rougeoyantes");
            });
        }
コード例 #16
0
ファイル: ExampleGame.cs プロジェクト: warmuuh/SpriterDotNet
        protected override void OnUpdating(UltravioletTime time)
        {
            Vector2 scale = animator.Scale;

            if (Actions.SwitchEntity.IsPressed())
            {
                SwitchEntity();
            }
            if (Actions.NextAnimation.IsPressed())
            {
                animator.Play(animator.GetNextAnimation());
            }
            if (Actions.DecreaseSpeed.IsPressed())
            {
                animator.ChangeAnimationSpeed(-0.2f, 5.0f);
            }
            if (Actions.IncreaseSpeed.IsPressed())
            {
                animator.ChangeAnimationSpeed(0.2f, 5.0f);
            }
            if (Actions.ReverseAnimation.IsPressed())
            {
                animator.Speed = -animator.Speed;
            }
            if (Actions.Transition.IsPressed())
            {
                animator.Transition(animator.GetNextAnimation(), 1000.0f);
            }
            if (Actions.PushCharMap.IsPressed())
            {
                animator.PushNextCharacterMap();
            }
            if (Actions.PopCharMap.IsPressed())
            {
                animator.SpriteProvider.PopCharMap();
            }
            if (Actions.ToggleColour.IsPressed())
            {
                animator.Color = animator.Color == Color.White ? Color.Red : Color.White;
            }
            if (Actions.MoveUp.IsPressed())
            {
                animator.Position += new Vector2(0, -10);
            }
            if (Actions.MoveDown.IsPressed())
            {
                animator.Position += new Vector2(0, 10);
            }
            if (Actions.MoveLeft.IsPressed())
            {
                animator.Position += new Vector2(-10, 0);
            }
            if (Actions.MoveRight.IsPressed())
            {
                animator.Position += new Vector2(10, 0);
            }
            if (Actions.RotateLeft.IsPressed())
            {
                animator.Rotation -= 15 * (float)Math.PI / 180;
            }
            if (Actions.RotateRight.IsPressed())
            {
                animator.Rotation += 15 * (float)Math.PI / 180;
            }
            if (Actions.ScaleUp.IsPressed())
            {
                animator.Scale += new Vector2(Math.Sign(scale.X) * 0.2f, Math.Sign(scale.Y) * 0.2f);
            }
            if (Actions.ScaleDown.IsPressed())
            {
                animator.Scale -= new Vector2(Math.Sign(scale.X) * 0.2f, Math.Sign(scale.Y) * 0.2f);
            }
            ;
            if (Actions.FlipX.IsPressed())
            {
                animator.Scale *= new Vector2(-1, 1);
            }
            if (Actions.FlipY.IsPressed())
            {
                animator.Scale *= new Vector2(1, -1);
            }
            //if (actions.DrawOutlines.IsPressed()) (currentAnimator as MonoGameDebugAnimator).DrawSpriteOutlines = !(currentAnimator as MonoGameDebugAnimator).DrawSpriteOutlines;
            if (Actions.ToggleVSync.IsPressed())
            {
                SynchronizeWithVerticalRetrace = !SynchronizeWithVerticalRetrace;
            }

            float deltaTime = time.ElapsedTime.Ticks / (float)TimeSpan.TicksPerMillisecond;

            animator.Update(deltaTime);

            elapsedTime += deltaTime;
            if (elapsedTime >= 100)
            {
                elapsedTime -= 100;
                string entity = animator.Entity.Name;
                status   = string.Format("{0} : {1}", entity, animator.Name);
                metadata = string.Format("Variables:\n{0}\nTags:\n", animator.GetVarValues(), animator.GetTagValues());

                textFormatter.Reset();
                textFormatter.AddArgument(Ultraviolet.GetGraphics().FrameRate);
                textFormatter.AddArgument(GC.GetTotalMemory(false) / 1024);
                textFormatter.AddArgument(Environment.Is64BitProcess ? "64-bit" : "32-bit");
                textFormatter.Format("{0:decimals:2} FPS\nAllocated: {1:decimals:2} kb\n{2}", textBuffer);
            }

            base.OnUpdating(time);
        }