void camera(Game1 game, LevelLoader levelLoader) { this.game = game; this.levelLoader = levelLoader; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // настройка хранилища storage.TexturesLoader = Content.Load<Texture2D>; storage.FontLoader = Content.Load<SpriteFont>; // загрузка всех текстур из заданной папки // !!! пока, обязательно указывать CONTENT/ storage.LoadTexture2DFolder("Content/Textures"); storage.LoadTexture2DFolder("Content/players"); storage.LoadTexture2DFolder("Content/advices"); storage.PushFont("font", Content.Load<SpriteFont>("myFont1")); storage.PushFont("menufont", Content.Load<SpriteFont>("menufont")); // выбираем все возможные номера уровней storage.GetLevelNumbers(); xmlCoreMissionLoader = Content.Load<XMLCoreMissionLoader>("lvls/tasks/mission_description1"); foreach (XMLExpressionTarger st in xmlCoreMissionLoader.expressions) { toDraw.Add("Key point: " + st.point); toDraw.Add("Name: " + st.name + ", EXP: " + st.expression); } // инициализируем нового игрока Rectangle plaerPosition = new Rectangle(120, 120, LevelLoader.SizePeople, LevelLoader.SizePeople); player = new Player(storage.Pull2DTexture("player"), storage.Pull2DTexture("player_run"), storage.Pull2DTexture("player_run_goriz"), plaerPosition, this, camera); this.levelLoader = new LevelLoader(this, player, storage, camera); player.setLinkLevelLoader(levelLoader); // передадим игроку ссылку на загрузчик уровней maxLvl = storage.GetMaxLevelNumber(); // стоит проверять существование уровня /*if (storage.IsExist(1)) { levelLoader.CreateLevel(1); currentLvl = 1; } else levelLoader.CreateLevel(maxLvl);*/ menuFont = storage.PullFont("menufont"); inventory = storage.Pull2DTexture("inventory"); menuButton = new Button(new Vector2(screenWidth - 40, 0), storage.Pull2DTexture("menu_active"), storage.PullFont("menufont"),new Vector2(0.6f,0.8f), "меню"); menuButton.Click += new EventHandler(menuButton_Click); cursor = new Cursor(storage.Pull2DTexture("cursor"), storage.Pull2DTexture("pointer")); buttonTexture = storage.Pull2DTexture("button"); LoadMenu(); LoadLvlMenu(); }
/// <summary> /// Передаем ссылку на загрузчик уровней /// </summary> /// <param name="levelLoader"></param> public void setLinkLevelLoader(LevelLoader levelLoader) { this.levelLoader = levelLoader; }
/// <summary> /// Конструктор класса /// </summary> /// <param name="playerTexture">Текстура охранника</param> /// <param name="width">Ширина кадра</param> /// <param name="height">Высота кадра</param> public Guards(Texture2D idlTexture, Texture2D runTextureVert, Texture2D runTextureGoriz, Texture2D eyeTextureVertic, Texture2D eyeTextureGoriz, Rectangle position, Game1 game, Player player, Camera camera, LevelLoader levelLoader) { Init(); this.idlTexture = idlTexture; this.runTextureGoriz = runTextureGoriz; this.runTextureVert = runTextureVert; this.eyeTextureGoriz = eyeTextureGoriz; this.eyeTextureVertic = eyeTextureVertic; this.game = game; this.camera = camera; this.player = player; this.levelLoader = levelLoader; this.step = 1; //присваиваем положение охранника x = position.X / LevelLoader.Size; y = position.Y / LevelLoader.Size; this.oldPosGuardX = x / LevelLoader.Size; this.oldPosGuardY = y / LevelLoader.Size; frameInfo.height = frameInfo.width = runTextureVert.Height; // вычислим сколько кадров в анимации frameInfo.count = this.runTextureVert.Width / frameInfo.width; this.position = position; countGuards++; }