当前位置: 首页>>代码示例>>C#>>正文


C# AssetManager.GetText方法代码示例

本文整理汇总了C#中AssetManager.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# AssetManager.GetText方法的具体用法?C# AssetManager.GetText怎么用?C# AssetManager.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AssetManager的用法示例。


在下文中一共展示了AssetManager.GetText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultiOptionSelector

        public MultiOptionSelector(AssetManager assets, string themeName, Vector2 position, Anchor anchor, List<Option> options, MultiOptionArrangement arrangement, Cursor cursor, int initialValue)
            : base(themeName, position, initialValue)
        {
            //process arrangement
            if (arrangement == MultiOptionArrangement.ListX)
                arrangement = new MultiOptionArrangement(options.Count, 1);
            if (arrangement == MultiOptionArrangement.ListY)
                arrangement = new MultiOptionArrangement(1, options.Count);
            this.arrangement = arrangement;

            TextDictionary assetDictionary = new TextDictionary(assets.GetText("selector"));
            //load themes
            string cursorTheme = assetDictionary.LookupString(themeName, "cursorTheme");
            string optionTheme = assetDictionary.LookupString(themeName, "optionTheme");
            Anchor justify = Anchor.Center;
            bool justifySuccess = assetDictionary.CheckPropertyExists(themeName, "justify");
            if (justifySuccess)
            {
                string justifyString = assetDictionary.LookupString(themeName, "justify");
                if (justifyString == "Left")
                    justify = Anchor.CenterLeft;
                else if (justifyString == "Right")
                    justify = Anchor.CenterRight;
            }
            //position components
            cursor.Initialize(options, assets, cursorTheme);
            Vector2 individualSize = Vector2.Zero;
            for (int i = 0; i < options.Count; i++)
            {
                options[i].Initialize(assets, optionTheme);
                if (options[i].Dimensions.X > individualSize.X)
                    individualSize.X = options[i].Dimensions.X;
                if (options[i].Dimensions.Y > individualSize.Y)
                    individualSize.Y = options[i].Dimensions.Y;
            }
            for (int i = 0; i < options.Count; i++)
                options[i].Position = (individualSize + cursor.Spacing * Vector2.One) * arrangement.GetPosition(i);
            Vector2 overallSize = new Vector2(arrangement.Columns * (individualSize.X + cursor.Spacing) - cursor.Spacing, arrangement.Rows * (individualSize.Y + cursor.Spacing) - cursor.Spacing);
            for (int i = 0; i < options.Count; i++)
            {
                Vector2 p = options[i].Position;
                if (justify == Anchor.TopCenter || justify == Anchor.Center || justify == Anchor.BottomCenter)
                    p.X += (individualSize.X - options[i].Dimensions.X) / 2;
                else if (justify == Anchor.TopRight || justify == Anchor.CenterRight || justify == Anchor.BottomRight)
                    p.X += individualSize.X - options[i].Dimensions.X;
                if (justify == Anchor.CenterLeft || justify == Anchor.Center || justify == Anchor.CenterRight)
                    p.Y += (individualSize.Y - options[i].Dimensions.Y) / 2;
                else if (justify == Anchor.BottomLeft || justify == Anchor.BottomCenter || justify == Anchor.BottomRight)
                    p.Y += individualSize.Y - options[i].Dimensions.Y;
                options[i].Position = p;
            }
            this.Position -= GraphicsHelper.ComputeAnchorOrigin(anchor, overallSize / GraphicsConstants.VIEWPORT_DIMENSIONS);
            this.options = options;
            this.cursor = cursor;
            //initialize position
            Vector2 initialPosition = arrangement.GetPosition(IntValue);
            x = (int)initialPosition.X;
            y = (int)initialPosition.Y;
            cursor.Update(IntValue);
        }
开发者ID:kjin,项目名称:TubeRacer,代码行数:60,代码来源:MultiOptionSelector.cs

示例2: Initialize

 public override void Initialize(AssetManager assets, string themeName)
 {
     TextDictionary assetDictionary = new TextDictionary(assets.GetText("option"));
     fontFace = assets.GetFont(assetDictionary.LookupString(themeName, "fontFace"));
     try { fontColor = new Color(assetDictionary.LookupVector4(themeName, "fontColor")); }
     catch { fontColor = new Color(assetDictionary.LookupVector3(themeName, "fontColor")); }
     dimensions = fontFace.MeasureString(text) + new Vector2(0, -5);
 }
开发者ID:kjin,项目名称:TubeRacer,代码行数:8,代码来源:Option.cs

示例3: BuildMultiOptionSelector

 public static MultiOptionSelector BuildMultiOptionSelector(AssetManager assets, string theme, string selectorName, List<Option> options, MultiOptionArrangement arrangement, Cursor cursor, int initialValue = 0)
 {
     TextDictionary assetDictionary = new TextDictionary(assets.GetText("selector"));
     string selectorTheme = assetDictionary.LookupString(theme, selectorName + "SelectorTheme");
     Vector2 selectorPosition = assetDictionary.LookupVector2(theme, selectorName + "SelectorPosition");
     Anchor selectorAnchor = Anchor.Center;
     if (assetDictionary.CheckPropertyExists(theme, selectorName + "SelectorAnchor"))
         Enum.TryParse<Anchor>(assetDictionary.LookupString(theme, selectorName + "SelectorAnchor"), out selectorAnchor);
     return new MultiOptionSelector(assets, selectorTheme, selectorPosition, selectorAnchor, options, arrangement, cursor, initialValue);
 }
开发者ID:kjin,项目名称:TubeRacer,代码行数:10,代码来源:ContextHelper.cs

示例4: Initialize

 public virtual void Initialize(List<Option> options, AssetManager assets, string themeName)
 {
     TextDictionary assetDictionary = new TextDictionary(assets.GetText("cursor"));
     this.options = options;
     try { cycleDelay = assetDictionary.LookupInt32(themeName, "cycleDelay"); }
     catch { cycleDelay = 1; }
     try { cycleInterval = assetDictionary.LookupInt32(themeName, "cycleInterval"); }
     catch { cycleInterval = 1; }
     spacing = assetDictionary.LookupSingle(themeName, "spacing");
     if (assetDictionary.CheckPropertyExists(themeName, "cycleSound"))
         cycleSound = new SoundObject(assets.GetSFX(assetDictionary.LookupString(themeName, "cycleSound")));
     if (assetDictionary.CheckPropertyExists(themeName, "selectSound"))
         selectSound = new SoundObject(assets.GetSFX(assetDictionary.LookupString(themeName, "selectSound")));
     selected = false;
 }
开发者ID:kjin,项目名称:TubeRacer,代码行数:15,代码来源:Cursor.cs

示例5: SingularSelector

        public SingularSelector(AssetManager assets, string themeName, Vector2 position, Anchor anchor, Option option)
            : base(themeName, position, 0)
        {
            TextDictionary assetDictionary = new TextDictionary(assets.GetText("selector"));
            string optionTheme = assetDictionary.LookupString(themeName, "optionTheme");
            blinkRate = assetDictionary.LookupInt32(themeName, "blinkRate");
            if (assetDictionary.CheckPropertyExists(themeName, "sound"))
                sound = new SoundObject(assets.GetSFX(assetDictionary.LookupString(themeName, "sound")));
            option.Initialize(assets, optionTheme);

            //this.position *= GraphicsConstants.VIEWPORT_DIMENSIONS / GraphicsConstants.DEFAULT_DIMENSIONS;
            this.Position -= GraphicsHelper.ComputeAnchorOrigin(anchor, option.Dimensions / GraphicsConstants.VIEWPORT_DIMENSIONS);
            this.option = option;
            IntValue = 0;
            timer = 0;
            selected = false;
        }
开发者ID:kjin,项目名称:TubeRacer,代码行数:17,代码来源:SingularSelector.cs

示例6: BackgroundParticleSettings

 public BackgroundParticleSettings(AssetManager assets, int actNumber)
 {
     TextDictionary td = new TextDictionary(assets.GetText("particles"));
     string act = "act" + actNumber;
     numParticles = td.LookupInt32(act, "numParticles");
     if (numParticles > 0)
     {
         rotationRateRange = td.LookupVector2(act, "rotationRateRange");
         scaleRange = td.LookupVector2(act, "scaleRange");
         colorLow = td.LookupColor(act, "colorLow");
         colorHigh = td.LookupColor(act, "colorHigh");
         texture = assets.GetTexture(td.LookupString(act, "texture"));
         distance = td.LookupSingle(act, "dist");
     }
 }
开发者ID:kjin,项目名称:TubeRacer,代码行数:15,代码来源:BackgroundParticleSet.cs

示例7: Build

        public static ParallaxBackgroundSet Build(AssetManager assets, Camera camera, Vector2 seamstressStart, string assetName)
        {
            TextDictionary assetDictionary = new TextDictionary(assets.GetText("parallax"));
            int layers = assetDictionary.LookupInt32(assetName, "layers");
            ParallaxBackground[] backgrounds = new ParallaxBackground[layers];
            BackgroundParticleSet particles = new BackgroundParticleSet(assets, camera.Dimensions, Convert.ToInt32(assetName.Substring(3)));
            int particleLayer = -1;
            for (int i = 0; i < layers; i++)
            {
                Texture2D tex;
                if (assetDictionary.CheckPropertyExists(assetName, "name" + i))
                    tex = assets.GetTexture(assetDictionary.LookupString(assetName, "name" + i));
                else
                    tex = assets.GetTexture(assetName + "_layer" + i);
                float dist, scale;
                Vector2 offset, velocity, repeat;
                Anchor anchor;
                try { dist = assetDictionary.LookupSingle(assetName, "dist" + i); }
                catch { dist = 1; }
                try { offset = assetDictionary.LookupVector2(assetName, "offset" + i); }
                catch { offset = Vector2.Zero; }
                try { velocity = assetDictionary.LookupVector2(assetName, "velocity" + i); }
                catch { velocity = Vector2.Zero; }
                try { scale = assetDictionary.LookupSingle(assetName, "scale" + i); }
                catch { scale = 1; }
                try { repeat = assetDictionary.LookupVector2(assetName, "repeat" + i); }
                catch { repeat = new Vector2(1, 0); }
                if (!assetDictionary.CheckPropertyExists(assetName, "anchor" + i) ||
                    !Enum.TryParse<Anchor>(assetDictionary.LookupString(assetName, "anchor" + i), out anchor))
                    anchor = Anchor.BottomLeft;
                backgrounds[i] = new ParallaxBackground(assets, tex, offset, velocity, dist, scale, anchor, repeat);
                if (dist > particles.Distance)
                    particleLayer = i;
            }
            ParallaxBackgroundSet pbs = new ParallaxBackgroundSet();
            pbs.backgrounds = backgrounds;
            pbs.camera = new Camera(camera.Dimensions, camera.Position, camera.Rotation, camera.Scale);
            pbs.color = assetDictionary.LookupColor(assetName, "color");
            pbs.particleLayer = particleLayer;
            pbs.particles = particles;
            pbs.seamstressStart = seamstressStart;

            return pbs;
        }
开发者ID:kjin,项目名称:TubeRacer,代码行数:44,代码来源:ParallaxBackground.cs

示例8: InputController

        /// <summary>
        /// Constructs a new InputController.
        /// </summary>
        /// <param name="assets">The AssetManager object used in the game.</param>
        public InputController(AssetManager assets)
        {
            controllerConnected = GamePad.GetState(PlayerIndex.One).IsConnected;
            TextDictionary dict = new TextDictionary(assets.GetText("controls"));
            controls = new InputControl[controlNames.Length];
            for (int i = 0; i < controls.Length; i++)
            {
                controls[i] = new InputControl();
                if (dict.CheckObjectExists(controlNames[i]))
                {
                    if (dict.CheckPropertyExists(controlNames[i], "key"))
                    {
                        Keys key = (Keys)Enum.Parse(typeof(Keys), dict.LookupString(controlNames[i], "key"));
                        controls[i].AddKey(key);
                    }
                    else
                    {
                        int j = 0;
                        while (dict.CheckPropertyExists(controlNames[i], "key" + j))
                        {
                            Keys key = (Keys)Enum.Parse(typeof(Keys), dict.LookupString(controlNames[i], "key" + j));
                            controls[i].AddKey(key);
                            j++;
                        }
                    }
                    if (dict.CheckPropertyExists(controlNames[i], "button"))
                    {
                        Buttons button = (Buttons)Enum.Parse(typeof(Buttons), dict.LookupString(controlNames[i], "button"));
                        controls[i].AddButton(button);
                    }
                    else
                    {
                        int j = 0;
                        while (dict.CheckPropertyExists(controlNames[i], "button" + j))
                        {
                            Buttons button = (Buttons)Enum.Parse(typeof(Buttons), dict.LookupString(controlNames[i], "button" + j));
                            controls[i].AddButton(button);
                            j++;
                        }
                    }
                    if (dict.CheckPropertyExists(controlNames[i], "leftjoystick"))
                    {
                        Vector2 dir = dict.LookupVector2(controlNames[i], "leftjoystick");
                        controls[i].SetLeftJoystick(dir);
                    }
                    if (dict.CheckPropertyExists(controlNames[i], "rightjoystick"))
                    {
                        Vector2 dir = dict.LookupVector2(controlNames[i], "rightjoystick");
                        controls[i].SetRightJoystick(dir);
                    }
                    if (dict.CheckPropertyExists(controlNames[i], "lefttrigger"))
                    {
                        bool activated = dict.LookupBoolean(controlNames[i], "lefttrigger");
                        controls[i].SetLeftTrigger(activated);
                    }
                    if (dict.CheckPropertyExists(controlNames[i], "righttrigger"))
                    {
                        bool activated = dict.LookupBoolean(controlNames[i], "righttrigger");
                        controls[i].SetRightTrigger(activated);
                    }
                }
            }

            var keyNames = Enum.GetValues(typeof(Keys));
            allKeys = new InputControl();
            foreach (Keys key in keyNames)
                allKeys.AddKey(key);
            allKeys.AddButton(Buttons.A);
            allKeys.AddButton(Buttons.B);
            allKeys.AddButton(Buttons.Back);
            allKeys.AddButton(Buttons.LeftShoulder);
            allKeys.AddButton(Buttons.LeftTrigger);
            allKeys.AddButton(Buttons.RightShoulder);
            allKeys.AddButton(Buttons.RightTrigger);
            allKeys.AddButton(Buttons.Start);
            allKeys.AddButton(Buttons.X);
            allKeys.AddButton(Buttons.Y);
        }
开发者ID:kjin,项目名称:TubeRacer,代码行数:82,代码来源:InputController.cs


注:本文中的AssetManager.GetText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。