Пример #1
0
        public Battle(ContentManager contentManager, RenderTarget2D final, GraphicsDevice graphicsDevice, PresentationParameters pp, int score)
        {
            //Generates 0, 1, 2
            enemyType = new Random().Next(0, 3);

            exitReady = false;
            curPhase  = Phase.IntroPhase;
            effect    = contentManager.Load <Effect>("Battle/BattleBG");
            effect.CurrentTechnique = effect.Techniques[0];
            flash           = contentManager.Load <Effect>("Battle/SpriteFlash");
            combatTimer     = 0;
            threshHold      = 0.15;
            combatIndicator = contentManager.Load <Texture2D>("Battle/Icons/Attack");
            youWon          = contentManager.Load <Texture2D>("Battle/Icons/YouWon");
            victoryColor    = Color.White;
            flashColor      = Color.White;
            secondsPerBeat  = 0.5f;
            world           = new World(ConvertUnits.ToSimUnits(0, Game1.width));
            waiter          = null;
            options         = new Icons(contentManager, score >= 20);    //shuffle spells only after 20 wins
            blackRect       = new Texture2D(graphicsDevice, 1, 1);
            blackRect.SetData(new Color[] { Color.Black });

            travis    = new Battler(contentManager, world);
            enemy     = new Enemy(contentManager, world, secondsPerBeat, enemyType, threshHold);
            enemyDraw = true;

            MultiSampleCount = pp.MultiSampleCount;
            palette          = contentManager.Load <Texture2D>("Battle/003Palette");
            effect.Parameters["palette"].SetValue(palette);
            effect.Parameters["paletteWidth"].SetValue((float)palette.Width);
            effect.Parameters["time"].SetValue((float)bgTimer);
            flash.Parameters["time"].SetValue((float)flashTimer);
            firstEffect = new RenderTarget2D(graphicsDevice, Game1.width, Game1.height, false, SurfaceFormat.Color, DepthFormat.None, MultiSampleCount, RenderTargetUsage.DiscardContents);
            content     = contentManager;

            background  = contentManager.Load <Texture2D>("Battle/005_GRN");
            background2 = content.Load <Texture2D>("Battle/Yellow");
            magic       = contentManager.Load <Texture2D>("Battle/Effects/PkFireA");
            magicAnim   = new Animation(0, 24);
            bgTimer     = 0;

            this.final          = final;   //required for scaling
            this.graphicsDevice = graphicsDevice;
            text = new Hud(new string[] { "@" + enemy.GetStageName() + " draws near!" }, content, 22, 2, posY: 3, canClose: true);
            text.finishMessage();
            text.finishText();
            //text.finishText();
            commandName        = new Hud(new string[] { options.GetSelectedName() }, content, 6, 0, Game1.width / 3 - 50, 2, canClose: false, centered: true);
            offsetHeightBottom = text.getHeight();
            offsetHeightTop    = 32;
            flashCounter       = 1;
            timerMult          = 1;

            magicColor = Color.White;

            darkenTimer = 1;
            toReturn    = 1;
        }