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


C# Level.getItemByName方法代码示例

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


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

示例1: start

        public void start(Level level, List<Level> menus, List<Level> huds)
        {
            Console.WriteLine("SceneManager.start");

            mouseCursor = new MouseCursor();
            TextureItem textureItem;
            string name = null;

            /*
            * Load mouse cursor
            * */
            Item mouseItem = level.getItemByName("MouseCursor");
            textureItem = (TextureItem)mouseItem;

            name = ResourceManager.getInstance.loadName(textureItem, "Name");
            mouseCursor = new MouseCursor(textureItem.texture, textureItem.Position, textureItem.Rotation, textureItem.Origin,
                textureItem.Scale, name);

            /*
            * Initializes camera and set its view
            * IMPORTANT: The item used here have to point to the player
            * */
            //2389 and 5227 is hard coded players start position
            camera = new Camera(Matrix.Identity, new Vector2(Renderer.getInstance.getScreenCenter().X - 2389,
                Renderer.getInstance.getScreenCenter().Y - 5227));

            camera.setView(Matrix.CreateTranslation(new Vector3(camera.getPosition() - Renderer.getInstance.getScreenCenter(), 0f)) *
                Matrix.CreateTranslation(new Vector3(Renderer.getInstance.getScreenCenter(), 0f)));

            loadMenus(menus);
            loadHud(huds);

            Console.WriteLine("Camera: " + camera.getPosition());
            //Console.WriteLine("Player: " + item.Position);
        }
开发者ID:Gardern,项目名称:Imagine_Cup_code,代码行数:35,代码来源:SceneManager.cs

示例2: loadLevel

        public void loadLevel(Level level)
        {
            player1 = new Character();
            backgroundObjects = new List<BackgroundObject>();
            middleObjects = new List<MiddleObject>();
            resourceObjects = new List<MiddleObject>();
            collision = false;
            List<TextureItem> textureItems;
            AABB axisAlignedBox = null;
            List<AABB> axisAlignedBoxes = null;
            List<Polygon> polygons = null;
            float depthPosition = 0.0f;
            string name = null;
            bool isAnimated = false;

            RectangleItem levelCollisionBox = (RectangleItem)level.getItemByName("LevelAABB");
            axisAlignedBox = new AABB(levelCollisionBox.Position, levelCollisionBox.Width, levelCollisionBox.Height);
            this.axisAlignedBox = axisAlignedBox;

            /*
               * Load background objects
            * */
            textureItems = level.getTextureItems("ObjectType", "BackgroundObject");
            foreach (TextureItem item in textureItems)
            {
                polygons = null;
                axisAlignedBoxes = null;

                axisAlignedBoxes = ResourceManager.getInstance.loadAxisAlignedBoxes(item, "CollisionBox"); //AABB
                polygons = ResourceManager.getInstance.loadPolygons(item, "Polygon"); //Polygon
                name = ResourceManager.getInstance.loadName(item, "Name");

                if (axisAlignedBoxes != null)
                {
                    backgroundObjects.Add(new BackgroundObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, axisAlignedBoxes, name));
                }
                else if (polygons != null)
                {
                    backgroundObjects.Add(new BackgroundObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, polygons, null, name));
                }
                else
                {
                    backgroundObjects.Add(new BackgroundObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, null, name));
                }
            }

            /*
             * Load resource objects
             * */
            textureItems = level.getTextureItems("ObjectType", "ResourceObject");
            foreach (TextureItem item in textureItems)
            {
                depthPosition = ResourceManager.getInstance.loadDepthPosition(item, "DepthPosition");
                name = ResourceManager.getInstance.loadName(item, "Name");

                resourceObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, null, depthPosition, name));
            }

            /*
            * Load middle objects
             * */
            textureItems = level.getTextureItems("ObjectType", "MiddleObject");
            foreach (TextureItem item in textureItems)
            {
                polygons = null;
                axisAlignedBoxes = null;

                axisAlignedBoxes = ResourceManager.getInstance.loadAxisAlignedBoxes(item, "CollisionBox"); //AABB
                polygons = ResourceManager.getInstance.loadPolygons(item, "Polygon"); //Polygon
                depthPosition = ResourceManager.getInstance.loadDepthPosition(item, "DepthPosition");
                name = ResourceManager.getInstance.loadName(item, "Name");
                isAnimated = ResourceManager.getInstance.loadIsAnimated(item, "IsAnimated");

                if (!isAnimated)
                {
                    if (axisAlignedBoxes != null)
                    {
                        middleObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, axisAlignedBoxes, depthPosition, name));
                    }
                    else if (polygons != null)
                    {
                        middleObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, polygons, null, depthPosition, name));
                    }
                    else
                    {
                        middleObjects.Add(new MiddleObject(item.texture, item.Position, item.Rotation, item.Origin, item.Scale, null, null, depthPosition, name));
                    }
                }
                else
                {
                    Texture2D[] animationSprites = ResourceManager.getInstance.loadAnimationSprite(item, "AnimationPath");
                    int numberOfAnimations = ResourceManager.getInstance.loadAnimationProperty(item, "NumberOfAnimations");
                    int[] animationSpeeds = ResourceManager.getInstance.loadAnimationProperty2(item, "AnimationSpeed");
                    int[] numberOfFrames = ResourceManager.getInstance.loadAnimationProperty2(item, "NumberOfFrames");
                    int[] numberOfRows = ResourceManager.getInstance.loadAnimationProperty2(item, "NumberOfRows");

                    if (name == "Player")
                    {
                        if (axisAlignedBoxes != null && polygons != null)
                        {
//.........这里部分代码省略.........
开发者ID:Gardern,项目名称:Imagine_Cup_code,代码行数:101,代码来源:SceneManager.cs


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