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


C# World.Initialize方法代码示例

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


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

示例1: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        public override void Initialize()
        {
            if (!this.IsInitialized)
            {
                tileEngine = new TileEngine();

                fullScreenSettings = new ResolutionSettings(640, 480, 640,
                                                                      480,
                                                                      true);

                ScreenManager.Instance.ResolutionService.CurrentResolutionSettings = windowedSettings;

                batchService = (ISpriteBatchService)this.Game.Services.GetService(typeof(ISpriteBatchService));

                // Create a new, empty world:
                world = new World(this, WORLD_FILENAME);

                // We need to disable the SpriteSpriteCollisionManager because it makes some assumptions about
                //  the gameScreen...
                world.SpriteCollisionManager.Enabled = false;

                // Create an empty, maximally-sized tilemap to center
                //  the loaded map onto:
                TileMap bigMap = new TileMap(MAX_TILEMAP_WIDTH, MAX_TILEMAP_HEIGHT,
                                          DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT,
                                          LAYER_COUNT, SUB_LAYER_COUNT);
                bigMap.FileName = world.Map.FileName;

                // Backup the original map:
                TileMap map = world.Map;

                // Compute the point where we want to blit it onto the empty map:
                this.offsetX = (bigMap.Width / 2) - (map.Width / 2);
                this.offsetY = (bigMap.Height / 2) - (map.Height / 2);

                bigMap.BlitTileMap(map, offsetX, offsetY);

                world.Map = bigMap;
                foreach (TileMapLayer tml in world.interactiveLayers.Values)
                {
                    Components.Remove(tml);
                }
                world.interactiveLayers.Clear();
                world.ShiftWorldObjects(new Vector2(world.Map.TileWidth * offsetX, world.Map.TileWidth * offsetY));

                for (int i = 0; i < world.Map.LayerCount; ++i)
                {
                    TileMapLayer tml = new TileMapLayer(this, batchService.GetSpriteBatch(TileMapLayer.SpriteBatchName), world.Map, i);
                    if (i == 0)
                    {
                        tml.DrawOrder = World.PLAYER_DRAW_ORDER - DEFAULT_LAYER_SPACING;
                    }
                    else
                    {
                        if (i == world.Map.LayerCount - 1)
                        {
                            tml.DrawBlanksEnabled = true;
                            tml.DrawEdgesEnabled = true;
                            tml.DrawDestructablesEnabled = true;
                        }
                        tml.DrawOrder = World.PLAYER_DRAW_ORDER + i * DEFAULT_LAYER_SPACING;
                    }
                    world.interactiveLayers[tml.DrawOrder] = tml;
                    Components.Add(world.interactiveLayers[tml.DrawOrder]);
                }

                world.Initialize();
                world.Camera.Position = world.Player.Position;// -new Vector2(world.Camera.VisibleArea.Width / 2, world.Camera.VisibleArea.Height / 2);
                world.Paused = true;

                Components.Add(world);

                // Set up editor controls:
                inputMonitor = InputMonitor.Instance;
                inputMonitor.AssignPressable("EditorLeft", new PressableKey(Keys.A));
                inputMonitor.AssignPressable("EditorRight", new PressableKey(Keys.D));
                inputMonitor.AssignPressable("EditorUp", new PressableKey(Keys.W));
                inputMonitor.AssignPressable("EditorDown", new PressableKey(Keys.S));
                inputMonitor.AssignPressable("EditorAppend", new PressableKey(Keys.LeftShift));
                inputMonitor.AssignPressable("ToggleFullScreen", new PressableKey(Keys.F));
                inputMonitor.AssignPressable("EditorCycleMode", new PressableKey(Keys.Tab));
                Components.Add(inputMonitor);

                CreateUIComponents();

                Mode = EditMode.SpriteEdit;
                CycleMode();

                // Initialize all components
                base.Initialize();
            }
        }
开发者ID:RochesterIndiesAnonymous,项目名称:Ironstag,代码行数:98,代码来源:EditorScreen.cs

示例2: LoadLevel

        private void LoadLevel(string file)
        {
            World w;

            try {
                w = new World(this, Level.LoadFromFile("../../../../levels/" + file + ".xml"));
            } catch (System.Exception) {
                return;
            }

            CurrentLevel = file;
            w.Score.LoadScores();
            w.Score.GetBestMedalByLevelName(CurrentLevel);

            _currentWorld = w;
            _currentWorld.Initialize();
            _currentWorld.LoadContent();

            UpdateSplitScreenNumber(1);

            Menu.CurrentMenu = null;
        }
开发者ID:steynh,项目名称:GamingMinor,代码行数:22,代码来源:TheGame.cs

示例3: Start

 // Use this for initialization
 void Start()
 {
     XmlSerializer serializer = new XmlSerializer (typeof(World));
     TextReader reader = new StringReader (overworldXML.text);
     overworld = serializer.Deserialize (reader) as World;
     reader.Close ();
     initializeprefabdict ();
     overworld.Initialize (world_width, world_height);
     overworld.loadRoom (startx, starty);
 }
开发者ID:jothwarr,项目名称:Project1Zelda,代码行数:11,代码来源:LoadWorld.cs


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