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


C# AssetManager.GetDictionary方法代码示例

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


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

示例1: Build

 public static AnimatedTexture Build(AssetManager assets, string assetName)
 {
     int columns = 1;
     int rows = 1;
     float scale = 1;
     TextDictionary td = assets.GetDictionary("graphics");
     if (td.CheckPropertyExists(assetName, "columns"))
         columns = td.LookupInt32(assetName, "columns");
     if (td.CheckPropertyExists(assetName, "rows"))
         rows = td.LookupInt32(assetName, "rows");
     if (td.CheckPropertyExists(assetName, "scale"))
         scale = td.LookupSingle(assetName, "scale");
     AnimatedTexture sprite = new AnimatedTexture(assetName, assets.GetTexture(assetName), columns, rows, scale);
     return sprite;
 }
开发者ID:kjin,项目名称:Ribbons,代码行数:15,代码来源:AnimatedTexture.cs

示例2: 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 = assets.GetDictionary("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,项目名称:Ribbons,代码行数:82,代码来源:InputController.cs


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