示例#1
0
        public LevelLoader(Game1 game, Player player, Storage storage, Camera camera)
        {
            this.game = game;
            this.player = player;
            this.camera = camera;
            this.storage = storage;
            storage = new Storage();

            NumberOfJewelry = 0;
        }
示例#2
0
        /// <summary>
        /// Конструктор класса
        /// </summary>
        /// <param name="playerTexture">Текстура охранника</param>
        /// <param name="width">Ширина кадра</param>
        /// <param name="height">Высота кадра</param>
        public Guards(Texture2D idlTexture, Texture2D runTexture, Rectangle position, Game1 game, Player player, Camera camera)
        {
            Init();
            this.idlTexture = idlTexture;
            this.runTexture = runTexture;

            this.game = game;
            this.camera = camera;
            this.player = player;

            this.step = 1;

            //присваиваем положение охранника
            x = position.X / game.Size;
            y = position.Y / game.Size;

            this.oldPosGuardX = x / game.Size;
            this.oldPosGuardY = y / game.Size;

            frameInfo.height = frameInfo.width = runTexture.Height;

            // вычислим сколько кадров в анимации
            frameInfo.count = this.runTexture.Width / frameInfo.width;

            this.position = position;

            //массив для патрулирования
            // временный. Потом будет считываться из файла
            wayToPatrol.Add(new List<int>());// добавляем новую строку под координату
            wayToPatrol[0].Add(3); // первым указывается координата X
            wayToPatrol[0].Add(3); // второе - координата Y
            wayToPatrol.Add(new List<int>());// добавляем новую строку под координату
            wayToPatrol[1].Add(3);
            wayToPatrol[1].Add(5);
            wayToPatrol.Add(new List<int>());// добавляем новую строку под координату
            wayToPatrol[2].Add(5);
            wayToPatrol[2].Add(5);
            wayToPatrol.Add(new List<int>());// добавляем новую строку под координату
            wayToPatrol[3].Add(7);
            wayToPatrol[3].Add(3);
            targetX = wayToPatrol[0][0];
            targetY = wayToPatrol[0][1];

            //targetX = wayToPatrol[1][0]; // 0 - x
            //targetY = wayToPatrol[1][1]; // 1 - y
        }
示例#3
0
        /// <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();
        }
示例#4
0
        /// <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++;
        }