Beispiel #1
0
        /// <summary>
        /// Creates a new <code>FlxButton</code> object with a gray background
        /// and a callback function on the UI thread.
        /// </summary>
        /// <param name="X">The X position of the button.</param>
        /// <param name="Y">The Y position of the button.</param>
        /// <param name="Callback">The function to call whenever the button is clicked.</param>
        public FlxButton(int X, int Y, FlxButtonClick Callback)
            : base()
        {
            x          = X;
            y          = Y;
            width      = 100;
            height     = 20;
            _off       = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
            _off.solid = false;
            add(_off, true);
            _on       = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
            _on.solid = false;
            add(_on, true);
            _offT        = null;
            _onT         = null;
            _callback    = Callback;
            _onToggle    = false;
            _pressed     = false;
            _initialized = false;
            _sf          = Vector2.Zero;
            pauseProof   = false;

            _controllerButtonIndex = -1;
            //_controllerButton = new FlxSprite((int)width+5,0);
            //_controllerButton.loadGraphic(FlxG.Content.Load<Texture2D>("buttons/BP3_SSTRIP_32"),true,false,32,32);
            //_controllerButton.solid = false;
            ////_controllerButton.scale
            //add(_controllerButton, true);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new <code>FlxButton</code> object with a gray background
        /// and a callback function on the UI thread.
        /// Also appends a GamePad symbol to allow for using a gamepad to select the menu.
        /// </summary>
        /// <param name="X">The X position of the button.</param>
        /// <param name="Y">The Y position of the button.</param>
        /// <param name="Callback">The function to call whenever the button is clicked.</param>
        /// <param name="Button">Button number. Uses FlxButton.ControlPad** to select a button</param>
        public FlxButton(int X, int Y, FlxButtonClick Callback, int Button)
            : base()
        {
            x          = X;
            y          = Y;
            width      = 100;
            height     = 20;
            _off       = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
            _off.solid = false;
            add(_off, true);
            _on       = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
            _on.solid = false;
            add(_on, true);
            _offT                  = null;
            _onT                   = null;
            _callback              = Callback;
            _onToggle              = false;
            _pressed               = false;
            _initialized           = false;
            _sf                    = Vector2.Zero;
            pauseProof             = false;
            _controllerButtonIndex = Button;

            //_controllerButton = new FlxSprite((int)width + 5, 0);
            //_controllerButton.loadGraphic(FlxG.Content.Load<Texture2D>("buttons/BP3_SSTRIP_32"), true, false, 31, 32);
            //_controllerButton.width = 29;
            //_controllerButton.height = 30;
            //_controllerButton.offset.X = 1;
            //_controllerButton.offset.Y = 1;
            //_controllerButton.addAnimation("frame", new int[] {Button});
            //_controllerButton.play("frame");
            //_controllerButton.solid = false;
            //add(_controllerButton, true);
        }
Beispiel #3
0
 /// <summary>
 /// Add a text label to the button.
 /// </summary>
 /// <param name="Text">A FlxText object to use to display text on this button (optional).</param>
 /// <param name="TextHighlight">A FlxText object that is used when the button is highlighted (optional).</param>
 /// <returns>This FlxButton instance (nice for chaining stuff together, if you're into that).</returns>
 public FlxButton loadText(FlxText Text, FlxText TextHighlight)
 {
     if (Text != null)
     {
         if (_offT == null)
         {
             _offT = Text;
             add(_offT);
         }
         else
         {
             _offT = replace(_offT, Text) as FlxText;
         }
     }
     if (TextHighlight == null)
     {
         _onT = _offT;
     }
     else
     {
         if (_onT == null)
         {
             _onT = TextHighlight;
             add(_onT);
         }
         else
         {
             _onT = replace(_onT, TextHighlight) as FlxText;
         }
     }
     _offT.scrollFactor = scrollFactor;
     _onT.scrollFactor  = scrollFactor;
     return(this);
 }
Beispiel #4
0
        public FlxRecord()
        {
            vcrGroup = new FlxGroup();


            // Customizable things
            filename   = "File";
            controller = PlayerIndex.One;


            //int xPos = 150;
            int yPos = 30;


            openSprite = new FlxSprite(130, yPos);
            openSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/open"));
            openSprite.setScrollFactors(0, 0);
            openSprite.debugName = "open";
            vcrGroup.add(openSprite);
            openSprite.boundingBoxOverride = false;

            pauseSprite = new FlxSprite(230, yPos);
            pauseSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/pause"));
            pauseSprite.setScrollFactors(0, 0);
            pauseSprite.debugName = "pause";
            vcrGroup.add(pauseSprite);
            pauseSprite.boundingBoxOverride = false;

            playSprite = new FlxSprite(330, yPos);
            playSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/play"));
            playSprite.setScrollFactors(0, 0);
            playSprite.debugName = "play";
            vcrGroup.add(playSprite);
            playSprite.boundingBoxOverride = false;

            recordSprite = new FlxSprite(430, yPos);
            recordSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/record_on"));
            recordSprite.setScrollFactors(0, 0);
            recordSprite.debugName = "record";
            vcrGroup.add(recordSprite);
            recordSprite.boundingBoxOverride = false;

            restartSprite = new FlxSprite(530, yPos);
            restartSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/restart"));
            restartSprite.setScrollFactors(0, 0);
            restartSprite.debugName = "restart";
            vcrGroup.add(restartSprite);
            restartSprite.boundingBoxOverride = false;

            stopSprite = new FlxSprite(630, yPos);
            stopSprite.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/vcr/stop"));
            stopSprite.setScrollFactors(0, 0);
            stopSprite.debugName = "stop";
            vcrGroup.add(stopSprite);

            stopSprite.boundingBoxOverride = false;

            infoText = new FlxText(360, yPos, FlxG.width);
            infoText.boundingBoxOverride = false;
        }
Beispiel #5
0
        public FlxPause()
        {
            //icons for the pause screen
            _imgKeyX       = FlxG.Content.Load <Texture2D>("flixel/key_x");
            _imgKeyC       = FlxG.Content.Load <Texture2D>("flixel/key_c");
            _imgKeyMouse   = FlxG.Content.Load <Texture2D>("flixel/key_mouse");
            _imgKeysArrows = FlxG.Content.Load <Texture2D>("flixel/keys_arrows");
            _imgKeyMinus   = FlxG.Content.Load <Texture2D>("flixel/key_minus");
            _imgKeyPlus    = FlxG.Content.Load <Texture2D>("flixel/key_plus");
            _imgKey0       = FlxG.Content.Load <Texture2D>("flixel/key_0");
            _imgKey1       = FlxG.Content.Load <Texture2D>("flixel/key_1");

            if (FlxG.height > 240)
            {
                _pauseScale = 2;
            }

            _pauseRect.Width  *= _pauseScale;
            _pauseRect.Height *= _pauseScale;
            _pauseRect.X       = (FlxG.width - _pauseRect.Width) / 2;
            _pauseRect.Y       = (FlxG.height - _pauseRect.Height) / 2;

            _pauseText = new FlxText(_pauseRect.X, _pauseRect.Y + (7 * _pauseScale), _pauseRect.Width, "GAME PAUSED");
            _pauseText.setFormat(null, (2 * _pauseScale) - 1, Color.White, FlxJustification.Center, Color.White);

            _posKeyX       *= _pauseScale;
            _posKeyC       *= _pauseScale;
            _posKeyMouse   *= _pauseScale;
            _posKeysArrows *= _pauseScale;
            _posKeyMinus   *= _pauseScale;
            _posKeyPlus    *= _pauseScale;
            _posKey0       *= _pauseScale;
            _posKey1       *= _pauseScale;

            _posKeyX.X       += _pauseRect.X;
            _posKeyC.X       += _pauseRect.X;
            _posKeyMouse.X   += _pauseRect.X;
            _posKeysArrows.X += _pauseRect.X;
            _posKeyMinus.X   += _pauseRect.X;
            _posKeyPlus.X    += _pauseRect.X;
            _posKey0.X       += _pauseRect.X;
            _posKey1.X       += _pauseRect.X;

            _posKeyX.Y       += _pauseRect.Y;
            _posKeyC.Y       += _pauseRect.Y;
            _posKeyMouse.Y   += _pauseRect.Y;
            _posKeysArrows.Y += _pauseRect.Y;
            _posKeyMinus.Y   += _pauseRect.Y;
            _posKeyPlus.Y    += _pauseRect.Y;
            _posKey0.Y       += _pauseRect.Y;
            _posKey1.Y       += _pauseRect.Y;
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="x">The x coordinate location of the resulting bar (in world pixels)</param>
        /// <param name="y">The y coordinate location of the resulting bar (in world pixels)</param>
        /// <param name="direction">One of the FlxBar.FILL_ constants (such as FILL_LEFT_TO_RIGHT, FILL_TOP_TO_BOTTOM etc)</param>
        /// <param name="width">The width of the bar in pixels</param>
        /// <param name="height">The height of the bar in pixels</param>
        /// <param name="parentRef">A reference to an object in your game that you wish the bar to track</param>
        /// <param name="variable">The variable of the object that is used to determine the bar position. For example if the parent was an FlxSprite this could be "health" to track the health value</param>
        /// <param name="min">The minimum value. I.e. for a progress bar this would be zero (nothing loaded yet)</param>
        /// <param name="max">The maximum value the bar can reach. I.e. for a progress bar this would typically be 100.</param>
        /// <param name="border">Include a 1px border around the bar? (if true it adds +2 to width and height to accommodate it)</param>
        public FlxBar(int x,
                      int y,
                      uint direction      = FILL_LEFT_TO_RIGHT,
                      uint width          = 100,
                      uint height         = 10,
                      FlxSprite parentRef = null,
                      string variable     = "",
                      float min           = 0,
                      float max           = 100,
                      bool border         = false)
            : base()
        {
            barWidth  = width;
            barHeight = height;
            _border   = border;
            //if (border)
            //{
            //    makeGraphic(barWidth + 2, barHeight + 2, 0xffffffff, true);
            //    filledBarPoint = new Point(1, 1);
            //}

            emptyBar  = new FlxSprite(x, y).createGraphic((int)width, (int)height, Color.DarkSlateGray);
            filledBar = new FlxSprite(x, y).createGraphic((int)width, (int)height, Color.Green);

            if (_border)
            {
                outline = new FlxSprite(x - 1, y - 1).createGraphic((int)width + 2, (int)height + 2, Color.LightGray);
            }
            if (parentRef != null)
            {
                parent         = parentRef;
                parentVariable = variable;
            }

            //setFillDirection(direction);

            setRange(min, max);

            //createFilledBar(0xff005100, 0xff00F400, border);

            //emptyKill = false;

            _text = new FlxText(x, y, 100);
            _text.setFormat(null, 1, Color.White, FlxJustification.Left, Color.Black);
            _text.text = variable;

            health = max;
        }
Beispiel #7
0
        public FlxConsole(int targetLeft, int targetWidth)
        {
            visible = false;

            _FPS = new int[8];

            _consoleRect = new Rectangle(0, 0,
                FlxG.spriteBatch.GraphicsDevice.Viewport.Width, FlxG.spriteBatch.GraphicsDevice.Viewport.Height);
            _consoleColor = new Color(0, 0, 0, 0x7F);

            _consoleText = new FlxText(targetLeft, -800, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
            _consoleText.height = FlxG.height; //FlxG.spriteBatch.GraphicsDevice.Viewport.Height;

            _consoleFPS = new FlxText(targetLeft + targetWidth - 30, -800, 30, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White);

            _consoleLines = new List<string>();

            MAX_CONSOLE_LINES = (FlxG.spriteBatch.GraphicsDevice.Viewport.Height / (int)(_consoleText.font.MeasureString("Qq").Y)) - 1;
        }
Beispiel #8
0
        public MessageBox()
            : base()
        {

            int midX = (FlxG.width / 2) - (320 / 2);
            int midY = 10;

            box = new UIBox(midX, midY, 320, 180);
            box.setScrollFactors(0, 0);
            add(box);

            textBox = new FlxText(midX+10, 20, 320, "");
            textBox.setFormat(null, 2, Color.White, FlxJustification.Left, Color.Black);
            textBox.setScrollFactors(0, 0);
            add(textBox);

            visible = false;

        }
Beispiel #9
0
        public FlxConsole(int targetLeft, int targetWidth)
        {
            visible = false;

            _FPS = new int[8];

            _consoleRect = new Rectangle(0, 0,
                                         FlxG.spriteBatch.GraphicsDevice.Viewport.Width, FlxG.spriteBatch.GraphicsDevice.Viewport.Height);
            _consoleColor = new Color(0, 0, 0, 0x7F);

            _consoleText        = new FlxText(targetLeft, -800, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
            _consoleText.height = FlxG.height; //FlxG.spriteBatch.GraphicsDevice.Viewport.Height;

            _consoleFPS = new FlxText(targetLeft + targetWidth - 30, -800, 30, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White);

            _consoleLines = new List <string>();

            MAX_CONSOLE_LINES = (FlxG.spriteBatch.GraphicsDevice.Viewport.Height / (int)(_consoleText.font.MeasureString("Qq").Y)) - 1;
        }
Beispiel #10
0
        /// <summary>
        /// Initialize the console.
        /// </summary>
        /// <param name="targetLeft">Target Left</param>
        /// <param name="targetWidth">Target Width</param>
        public FlxConsole(int targetLeft, int targetWidth)
        {
            visible = false;

            _FPS = new int[8];

            _consoleRect = new Rectangle(FlxG.spriteBatch.GraphicsDevice.Viewport.X, 0,
                                         FlxG.spriteBatch.GraphicsDevice.Viewport.Width,
                                         FlxG.spriteBatch.GraphicsDevice.Viewport.Height);

            width  = FlxG.spriteBatch.GraphicsDevice.Viewport.Width;
            height = FlxG.spriteBatch.GraphicsDevice.Viewport.Height;
            dx     = (int)(width * 0.05);
            dy     = (int)(height * 0.05);

            _titleSafeRect = new Rectangle(dx * 2, dy * 2,
                                           width - 4 * dx,
                                           height - 4 * dy);

            _consoleColor = new Color(0, 0, 0, 0x7F);

            _consoleText        = new FlxText(targetLeft + (dx * 2), -800, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
            _consoleText.height = FlxG.height; //FlxG.spriteBatch.GraphicsDevice.Viewport.Height;
            _consoleText.boundingBoxOverride = false;

            _consoleCommand      = new FlxText(targetLeft + (dx * 2) + 50, -800, targetWidth, "").setFormat(null, 1, Color.HotPink, FlxJustification.Left, Color.Black);
            _consoleCommand.text = "";
            _consoleCommand.boundingBoxOverride = false;

            _consoleCheatActivated = new FlxSprite(targetLeft + (dx * 2), -800, FlxG.Content.Load <Texture2D>("flixel/vcr/cheat_on"));
            _consoleCheatActivated.setScrollFactors(0, 0);
            _consoleCheatActivated.boundingBoxOverride = false;

            _consoleFPS = new FlxText(targetLeft + targetWidth - (dx * 3), -800, 30, "").setFormat(null, 2, Color.White, FlxJustification.Right, Color.White);
            _consoleFPS.boundingBoxOverride = false;

            _consoleLines = new List <string>();

            MAX_CONSOLE_LINES = (FlxG.spriteBatch.GraphicsDevice.Viewport.Height / (int)(_consoleText.font.MeasureString("Qq").Y)) - 1;

            vcr = new FlxRecord();
        }
Beispiel #11
0
        //@benbaird initializes the console, the pause overlay, and the soundbar
        private void initConsole()
        {
            //initialize the debug console
            _console = new FlxConsole(targetLeft, targetWidth);

            _console.log(FlxG.LIBRARY_NAME +
                         " v" + FlxG.LIBRARY_MAJOR_VERSION.ToString() + "." + FlxG.LIBRARY_MINOR_VERSION.ToString());
            _console.log("---------------------------------------");

            //Pause screen popup
            _pausePanel = new FlxPause();
            if (_helpStrings != null)
            {
                _pausePanel.helpX      = _helpStrings[0];
                _pausePanel.helpC      = _helpStrings[1];
                _pausePanel.helpMouse  = _helpStrings[2];
                _pausePanel.helpArrows = _helpStrings[3];
            }

            //Sound Tray popup
            _soundTrayRect    = new Rectangle((FlxG.width - 80) / 2, -30, 80, 30);
            _soundTrayVisible = false;

            _soundCaption = new FlxText((FlxG.width - 80) / 2, -10, 80, "VOLUME");
            _soundCaption.setFormat(null, 1, Color.White, FlxJustification.Center, Color.White).height = 10;

            int bx = 10;
            int by = 14;

            _soundTrayBars = new FlxSprite[10];
            for (int i = 0; i < 10; i++)
            {
                _soundTrayBars[i]              = new FlxSprite(_soundTrayRect.X + (bx * 1), -i, null);
                _soundTrayBars[i].width        = 4;
                _soundTrayBars[i].height       = i + 1;
                _soundTrayBars[i].scrollFactor = Vector2.Zero;
                bx += 6;
                by--;
            }
        }
Beispiel #12
0
        public BattleUI()
            : base()
        {

            int midX = (FlxG.width / 2) - (320 / 2);
            int midY = 10;

            box = new UIBox(midX, midY, 320, 180);
            box.setScrollFactors(0, 0);
            add(box);

            FlxText t = new FlxText(midX, midY, 320, "BATTLE");
            t.setScrollFactors(0, 0);
            add(t);

            visible = false;
            
            keys = new KeyGroup();
            add(keys);

#if DEBUGX2
            playerTweener = new Tweener(0, box.x + 50, 1.0f, Circular.EaseOut);
            playerTweener.Start();

            targetTweener = new Tweener(FlxG.width, box.x + box.width - 50, 0.9f, Circular.EaseOut);
            targetTweener.Start();
#else
            playerTweener = new Tweener(0, box.x - 50, 1.0f, Circular.EaseOut);
            playerTweener.Start();

            targetTweener = new Tweener(FlxG.width, box.x + box.width + 50, 0.9f, Circular.EaseOut);
            targetTweener.Start();
#endif



            directions = new int[] { FlxHud.Keyboard_Arrow_Down, FlxHud.Keyboard_Arrow_Up, FlxHud.Keyboard_Arrow_Left, FlxHud.Keyboard_Arrow_Right};

        }
Beispiel #13
0
 /**
  * Creates a new <code>FlxButton</code> object with a gray background
  * and a callback function on the UI thread.
  *
  * @param	X			The X position of the button.
  * @param	Y			The Y position of the button.
  * @param	Callback	The function to call whenever the button is clicked.
  */
 public FlxButton(int X, int Y, FlxButtonClick Callback)
     : base()
 {
     x          = X;
     y          = Y;
     width      = 100;
     height     = 20;
     _off       = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
     _off.solid = false;
     add(_off, true);
     _on       = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
     _on.solid = false;
     add(_on, true);
     _offT        = null;
     _onT         = null;
     _callback    = Callback;
     _onToggle    = false;
     _pressed     = false;
     _initialized = false;
     _sf          = Vector2.Zero;
     pauseProof   = false;
 }
Beispiel #14
0
        public override void create()
        {
            base.create();

            FlxSprite bg = new FlxSprite(0, 0);

            bg.createGraphic(FlxG.width, FlxG.height, FlxG.splashBGColor);
            add(bg);

            _f         = null;
            _poweredBy = FlxG.Content.Load <Texture2D>("flixel/poweredby");
            _fSound    = FlxG.Content.Load <SoundEffect>(FlxG.splashAudioWaveFlixel);

            _initialsLogo = FlxG.Content.Load <Texture2D>(FlxG.splashLogo);

            //_logo = new FlxSprite();
            //_logo.loadGraphic(_initialsLogo, false, false, 216,24);
            //_logo.x = FlxG.width / 2 - 216 / 2;
            //_logo.y = FlxG.height / 2 - 24;
            //add(_logo);

            logoParts = new FlxGroup();

            for (int i = 0; i < 18; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    _logo = new FlxLogoSprite(i, j);
                    _logo.loadGraphic(_initialsLogo, false, false, 12, 12);
                    _logo.x = (FlxG.width / 2 - 216 / 2) + (i * 12);
                    _logo.y = (FlxG.height / 2 - 24) + (j * 12);
                    _logo.addAnimation("bugs", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24),
                                                           (j * 18) + i }, FlxU.randomInt(12, 18), false);

                    _logo.addAnimation("bugs2", new int[] { 0, 1, 2, FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24), FlxU.randomInt(0, 24),
                                                            0 }, FlxU.randomInt(18, 24), false);

                    _logo.play("bugs");
                    logoParts.add(_logo);

                    float offset = 25.0f;
                    if (j >= 1)
                    {
                        offset *= -1.0f;
                    }
                    _logo.t = new Tweener((float)(_logo.y + offset), (float)_logo.y, 0.25f + (i / 18.0f), XNATweener.Quadratic.EaseInOut);
                    _logo.t.Start();
                }
            }
            add(logoParts);


            _logoTweener = new Tweener(-150, FlxG.height / 2 - 24, TimeSpan.FromSeconds(0.9f), Bounce.EaseOut);

            SndTag = FlxG.splashAudioWave;
            //FlxG.play(SndTag,1.0f);



            debugMode         = new FlxText(10, 90, 200, "DEBUG MODE!");
            debugMode.visible = false;
            add(debugMode);

            Console.WriteLine(" !!! Type {0} To Enter Debug Mode !!! ", FlxGlobal.titleScreenDebugMode);
        }
Beispiel #15
0
        /// <summary>
        /// FlxHud
        /// </summary>
        /// <param name="targetLeft"></param>
        /// <param name="targetWidth"></param>
        public FlxHud(int targetLeft, int targetWidth)
        {
            _consoleRect  = new Rectangle(0, 0, FlxG.spriteBatch.GraphicsDevice.Viewport.Width, FlxG.spriteBatch.GraphicsDevice.Viewport.Height);
            _consoleColor = new Color(0, 0, 0, 0x00);

            visible = false;

            hudGroup = new FlxGroup();
            hudGroup.scrollFactor.X = 0;
            hudGroup.scrollFactor.Y = 0;

            string keys    = "flixel/buttons/MapWhite";
            string xbox360 = "flixel/buttons/Map360";
            string ouya    = "flixel/buttons/MapOuya";

            if (FlxG.buildDescription == "GAMEBOY")
            {
                keys    = "flixel/buttons/MapWhiteGameboy";
                xbox360 = "flixel/buttons/Map360Gameboy";
                ouya    = "flixel/buttons/MapOuyaGameboy";
            }

            p1OriginalPosition = new Vector2(targetLeft, 0);
            p2OriginalPosition = new Vector2(targetLeft, 0);
            p3OriginalPosition = new Vector2(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20);
            p4OriginalPosition = new Vector2(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20);


            //FlxG.Content.Load<SpriteFont>("flixel/initials/SpaceMarine")

            if (FlxG.hudFont == null)
            {
                p1HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
                p2HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White);
                p3HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Left, Color.White);
                p4HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(null, 1, Color.White, FlxJustification.Right, Color.White);
            }
            else
            {
                p1HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Left, Color.Black);
                p2HudText = new FlxText(targetLeft, 0, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Right, Color.Black);
                p3HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Left, Color.Black);
                p4HudText = new FlxText(targetLeft, FlxG.spriteBatch.GraphicsDevice.Viewport.Height - 20, targetWidth, "").setFormat(FlxG.Content.Load <SpriteFont>(FlxG.hudFont), 1, Color.White, FlxJustification.Right, Color.Black);
            }


            keyboardButton = new FlxSprite(targetLeft, -1000);
            keyboardButton.loadGraphic(FlxG.Content.Load <Texture2D>(keys), true, false, 100, 100);
            keyboardButton.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            keyboardButton.play("frame");
            keyboardButton.solid               = false;
            keyboardButton.visible             = true;
            keyboardButton.scrollFactor.X      = 0;
            keyboardButton.scrollFactor.Y      = 0;
            keyboardButton.boundingBoxOverride = false;

            xboxButton = new FlxSprite(targetLeft, -1000);
            xboxButton.loadGraphic(FlxG.Content.Load <Texture2D>(xbox360), true, false, 100, 100);
            xboxButton.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            xboxButton.play("frame");
            xboxButton.solid               = false;
            xboxButton.visible             = true;
            xboxButton.scrollFactor.X      = 0;
            xboxButton.scrollFactor.Y      = 0;
            xboxButton.boundingBoxOverride = false;


            ouyaButton = new FlxSprite(targetLeft, -1000);
            ouyaButton.loadGraphic(FlxG.Content.Load <Texture2D>(ouya), true, false, 100, 100);
            ouyaButton.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            ouyaButton.play("frame");
            ouyaButton.solid               = false;
            ouyaButton.visible             = true;
            ouyaButton.scrollFactor.X      = 0;
            ouyaButton.scrollFactor.Y      = 0;
            ouyaButton.boundingBoxOverride = false;


            keyboardDirection = new FlxSprite(targetLeft, -1000);
            keyboardDirection.loadGraphic(FlxG.Content.Load <Texture2D>(keys), true, false, 100, 100);
            keyboardDirection.addAnimation("frame", new int[] { Keyboard_Arrow_Up });
            keyboardDirection.play("frame");
            keyboardDirection.solid               = false;
            keyboardDirection.visible             = true;
            keyboardDirection.scrollFactor.X      = 0;
            keyboardDirection.scrollFactor.Y      = 0;
            keyboardDirection.boundingBoxOverride = false;


            xboxDirection = new FlxSprite(targetLeft, -1000);
            xboxDirection.loadGraphic(FlxG.Content.Load <Texture2D>(xbox360), true, false, 100, 100);
            xboxDirection.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            xboxDirection.play("frame");
            xboxDirection.solid               = false;
            xboxDirection.visible             = true;
            xboxDirection.scrollFactor.X      = 0;
            xboxDirection.scrollFactor.Y      = 0;
            xboxDirection.boundingBoxOverride = false;


            ouyaDirection = new FlxSprite(targetLeft, -1000);
            ouyaDirection.loadGraphic(FlxG.Content.Load <Texture2D>(ouya), true, false, 100, 100);
            ouyaDirection.addAnimation("frame", new int[] { FlxButton.ControlPadA });
            ouyaDirection.play("frame");
            ouyaDirection.solid               = false;
            ouyaDirection.visible             = true;
            ouyaDirection.scrollFactor.X      = 0;
            ouyaDirection.scrollFactor.Y      = 0;
            ouyaDirection.boundingBoxOverride = false;



            //add(_gamePadButton, true);

            timeToShowButton = float.MaxValue;
            _elapsedSinceLastButtonNeeded = 0.0f;
        }
Beispiel #16
0
        /// <summary>
        /// @benbaird initializes the console, the pause overlay, and the soundbar
        /// </summary>
        private void initConsole()
        {
            hud = new FlxHud(targetLeft, targetWidth);


            //initialize the debug console
            _console = new FlxConsole(targetLeft, targetWidth);

            _console.log(FlxG.LIBRARY_NAME +
                         " v" + FlxG.LIBRARY_MAJOR_VERSION.ToString() + "." + FlxG.LIBRARY_MINOR_VERSION.ToString());

            // Display some information about the engine we are using.
            Console.WriteLine("\nFlxFactory initialization\nFlixel Details LIBRARY:{0} -- v{1}.{2}", FlxG.LIBRARY_NAME, FlxG.LIBRARY_MAJOR_VERSION, FlxG.LIBRARY_MINOR_VERSION);


            /*
             * Assembly assembly = Assembly.GetExecutingAssembly();
             * FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
             * string version = fileVersionInfo.ProductVersion;
             * string gameName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
             * Console.WriteLine(gameName + " - Build version: " + version);
             *
             * _console.log(gameName + " - Build version: " + version);
             */


            _console.log("---------------------------------------");



            //Pause screen popup
            _pausePanel = new FlxPause();
            if (_helpStrings != null)
            {
                _pausePanel.helpX      = _helpStrings[0];
                _pausePanel.helpC      = _helpStrings[1];
                _pausePanel.helpMouse  = _helpStrings[2];
                _pausePanel.helpArrows = _helpStrings[3];
            }

            //Sound Tray popup
            _soundTrayRect    = new Rectangle((FlxG.width - 80) / 2, -30, 80, 30);
            _soundTrayVisible = false;

            _soundCaption = new FlxText((FlxG.width - 80) / 2, -10, 80, "VOLUME [=Lower ]=Higher \\=Mute or Unmute");
            _soundCaption.setFormat(null, 1, Color.White, FlxJustification.Center, Color.White).height = 10;

            int bx = 10;
            int by = 14;

            _soundTrayBars = new FlxSprite[10];
            for (int i = 0; i < 10; i++)
            {
                _soundTrayBars[i]              = new FlxSprite(_soundTrayRect.X + (bx * 1), -i, null);
                _soundTrayBars[i].width        = 4;
                _soundTrayBars[i].height       = i + 1;
                _soundTrayBars[i].scrollFactor = Vector2.Zero;
                bx += 6;
                by--;
            }
        }
Beispiel #17
0
        //@benbaird initializes the console, the pause overlay, and the soundbar
        private void initConsole()
        {
            //initialize the debug console
            _console = new FlxConsole(targetLeft, targetWidth);

            _console.log(FlxG.LIBRARY_NAME +
                " v" + FlxG.LIBRARY_MAJOR_VERSION.ToString() + "." + FlxG.LIBRARY_MINOR_VERSION.ToString());
            _console.log("---------------------------------------");

            //Pause screen popup
            _pausePanel = new FlxPause();
            if (_helpStrings != null)
            {
                _pausePanel.helpX = _helpStrings[0];
                _pausePanel.helpC = _helpStrings[1];
                _pausePanel.helpMouse = _helpStrings[2];
                _pausePanel.helpArrows = _helpStrings[3];
            }

            //Sound Tray popup
            _soundTrayRect = new Rectangle((FlxG.width - 80) / 2, -30, 80, 30);
            _soundTrayVisible = false;

            _soundCaption = new FlxText((FlxG.width - 80) / 2, -10, 80, "VOLUME");
            _soundCaption.setFormat(null, 1, Color.White, FlxJustification.Center, Color.White).height = 10;

            int bx = 10;
            int by = 14;
            _soundTrayBars = new FlxSprite[10];
            for(int i = 0; i < 10; i++)
            {
                _soundTrayBars[i] = new FlxSprite(_soundTrayRect.X + (bx * 1), -i, null);
                _soundTrayBars[i].width = 4;
                _soundTrayBars[i].height = i + 1;
                _soundTrayBars[i].scrollFactor = Vector2.Zero;
                bx += 6;
                by--;
            }
        }
Beispiel #18
0
        /// <summary>
        /// Sprite Constructor
        /// </summary>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        public Diver(int xPos, int yPos)
            : base(xPos, yPos)
        {
            loadGraphic("diver_05", true, false, 128, 128);

            width = 48;
            height = 48;

            setOffset(32 + 8, 32 + 16);

            addAnimation("idle", new int[] { 81,82 }, 4, true);

            addAnimation("run1", this.generateFrameNumbersBetween(0, 5), 1, true);
            addAnimation("run2", this.generateFrameNumbersBetween(0, 5), 2, true);
            addAnimation("run4", this.generateFrameNumbersBetween(0, 5), 4, true);
            addAnimation("run8", this.generateFrameNumbersBetween(0, 5), 8, true);
            addAnimation("run16", this.generateFrameNumbersBetween(0, 5), 16, true);
            addAnimation("run24", this.generateFrameNumbersBetween(0, 5), 24, true);
            addAnimation("run32", this.generateFrameNumbersBetween(0, 5), 32, true);

            addAnimation("swan", this.generateFrameNumbersBetween(7, 18), 16, false);
            addAnimation("dive", this.generateFrameNumbersBetween(18,27), 16, false);

            addAnimation("enterWater", this.generateFrameNumbersBetween(28,31), 16, false);

            addAnimation("glide", this.generateFrameNumbersBetween(31, 52), 16, true);
            addAnimation("swim", this.generateFrameNumbersBetween(44, 64), 16, true);

            addAnimation("exitWater", this.generateFrameNumbersBetween(65, 72), 16, false);

            addAnimation("fall", new int[] { 7,26 }, 24, true);

            addAnimation("breathe", new int[] { 83,84 }, 2, true);

            addAnimation("hitFloor", new int[] { 85,86,86,86,87 }, 16, false);

            addAnimationCallback(animCallback);

            //addAnimationsFromGraphicsGaleCSV("content/_.csv");

            play("idle");

            this.maxVelocity = new Vector2(350, 600);

            this.velocity.X = 0;
            acceleration.Y = 980;

            mode = "idle";

            hasEnteredWater = false;

            //FlxG.showBounds = true;

            deepestPointOfDive = 0;

            debugText = new FlxText(xPos, yPos, 100);
            debugText.setScrollFactors(1, 1);
            debugText.alignment = FlxJustification.Left;
        }
Beispiel #19
0
        public override void create()
        {
            base.create();

            ImgTech=FlxG.Content.Load<Texture2D>("Mode/tech_tiles");
            ImgDirtTop=FlxG.Content.Load<Texture2D>("Mode/dirt_top");
            ImgDirt=FlxG.Content.Load<Texture2D>("Mode/dirt");
            ImgNotch=FlxG.Content.Load<Texture2D>("Mode/notch");
            ImgGibs=FlxG.Content.Load<Texture2D>("Mode/gibs");
            ImgSpawnerGibs = FlxG.Content.Load<Texture2D>("Mode/spawner_gibs");

            FlxG.mouse.hide();
            reload = false;

            //get the gibs set up and out of the way
            _littleGibs = new FlxEmitter();
            _littleGibs.delay = 3;
            _littleGibs.setXSpeed(-150,150);
            _littleGibs.setYSpeed(-200,0);
            _littleGibs.setRotation(-720,-720);
            _littleGibs.createSprites(ImgGibs,100,true,0.5f,0.65f);
            _bigGibs = new FlxEmitter();
            _bigGibs.setXSpeed(-200,200);
            _bigGibs.setYSpeed(-300,0);
            _bigGibs.setRotation(-720,-720);
            _bigGibs.createSprites(ImgSpawnerGibs,50,true,0.5f,0.35f);

            //level generation needs to know about the spawners (and thusly the bots, players, etc)
            _blocks = new FlxGroup();
            _decorations = new FlxGroup();
            _bullets = new FlxGroup();
            _player = new Player(316,300,_bullets.members,_littleGibs);
            _bots = new FlxGroup();
            _botBullets = new FlxGroup();
            _spawners = new FlxGroup();

            //simple procedural level generation
            int i;
            int r = 160;
            FlxTileblock b;

            b = new FlxTileblock(0,0,640,16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(0,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(640-16,16,16,640-16);
            b.loadGraphic(ImgTech);
            _blocks.add(b);

            b = new FlxTileblock(16,640-24,640-32,8);
            b.loadGraphic(ImgDirtTop);
            _blocks.add(b);

            b = new FlxTileblock(16,640-16,640-32,16);
            b.loadGraphic(ImgDirt);
            _blocks.add(b);

            buildRoom(r * 0, r * 0, true);
            buildRoom(r*1,r*0);
            buildRoom(r*2,r*0);
            buildRoom(r * 3, r * 0, true);
            buildRoom(r * 0, r * 1, true);
            buildRoom(r*1,r*1);
            buildRoom(r*2,r*1);
            buildRoom(r * 3, r * 1, true);
            buildRoom(r*0,r*2);
            buildRoom(r*1,r*2);
            buildRoom(r*2,r*2);
            buildRoom(r*3,r*2);
            buildRoom(r*0,r*3,true);
            buildRoom(r*1,r*3);
            buildRoom(r*2,r*3);
            buildRoom(r*3,r*3,true);

            //Add bots and spawners after we add blocks to the state,
            // so that they're drawn on top of the level, and so that
            // the bots are drawn on top of both the blocks + the spawners.
            add(_spawners);
            add(_littleGibs);
            add(_bigGibs);
            add(_blocks);
            add(_decorations);
            add(_bots);

            //actually create the bullets now
            for(i = 0; i < 50; i++)
                _botBullets.add(new BotBullet());
            for(i = 0; i < 8; i++)
                _bullets.add(new Bullet());

            //add player and set up scrolling camera
            add(_player);
            FlxG.follow(_player,2.5f);
            FlxG.followAdjust(0.5f,0.0f);
            FlxG.followBounds(0,0,640,640);

            //add gibs + bullets to scene here, so they're drawn on top of pretty much everything
            add(_botBullets);
            add(_bullets);

            //finally we are going to sort things into a couple of helper groups.
            //we don't add these to the state, we just use them for collisions later!
            _enemies = new FlxGroup();
            _enemies.add(_botBullets);
            _enemies.add(_spawners);
            _enemies.add(_bots);
            _objects = new FlxGroup();
            _objects.add(_botBullets);
            _objects.add(_bullets);
            _objects.add(_bots);
            _objects.add(_player);
            _objects.add(_littleGibs);
            _objects.add(_bigGibs);

            //HUD - score
            Vector2 ssf = new Vector2(0,0);
            _score = new FlxText(0,0,FlxG.width);
            _score.color = new Color (0xd8, 0xeb, 0xa2);
            _score.scale = 2;
            _score.alignment = FlxJustification.Center;
            _score.scrollFactor = ssf;
            _score.shadow = new Color(0x13, 0x1c, 0x1b);
            add(_score);
            if (FlxG.scores.Count < 2)
            {
                FlxG.scores.Add(0);
                FlxG.scores.Add(0);
            }

            //HUD - highest and last scores
            _score2 = new FlxText(FlxG.width/2,0,FlxG.width/2);
            _score2.color = new Color(0xd8, 0xeb, 0xa2);
            _score2.alignment = FlxJustification.Right;
            _score2.scrollFactor = ssf;
            _score2.shadow = _score.shadow;
            add(_score2);
            if (FlxG.score > FlxG.scores[0])
                FlxG.scores[0] = FlxG.score;
            if (FlxG.scores[0] != 0)
                _score2.text = "HIGHEST: " + FlxG.scores[0] + "\nLAST: " + FlxG.score;
            FlxG.score = 0;
            _scoreTimer = 0;

            //HUD - the "number of spawns left" icons
            _notches = new List<FlxSprite>();
            FlxSprite tmp;
            for(i = 0; i < 6; i++)
            {
                tmp = new FlxSprite(4+i*10,4);
                tmp.loadGraphic(ImgNotch,true);
                tmp.scrollFactor.X = tmp.scrollFactor.Y = 0;
                tmp.addAnimation("on", new int[] {0});
                tmp.addAnimation("off",new int[] {1});
                tmp.moves = false;
                tmp.solid = false;
                tmp.play("on");
                _notches.Add((FlxSprite)this.add(tmp));
            }

            //HUD - the "gun jammed" notification
            _jamBar = this.add((new FlxSprite(0,FlxG.height-22)).createGraphic(FlxG.width,24, new Color(0x13, 0x1c, 0x1b))) as FlxSprite;
            _jamBar.scrollFactor.X = _jamBar.scrollFactor.Y = 0;
            _jamBar.visible = false;
            _jamText = new FlxText(0,FlxG.height-22,FlxG.width,"GUN IS JAMMED");
            _jamText.color = new Color(0xd8, 0xeb, 0xa2);
            _jamText.scale = 2;
            _jamText.alignment = FlxJustification.Center;
            _jamText.scrollFactor = ssf;
            _jamText.visible = false;
            add(_jamText);

            FlxG.playMusic(SndMode);
            FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 0.5f, null, false);
            _fading = false;
        }
Beispiel #20
0
 /**
  * Add a text label to the button.
  *
  * @param	Text				A FlxText object to use to display text on this button (optional).
  * @param	TextHighlight		A FlxText object that is used when the button is highlighted (optional).
  *
  * @return	This FlxButton instance (nice for chaining stuff together, if you're into that).
  */
 public FlxButton loadText(FlxText Text, FlxText TextHighlight)
 {
     if (Text != null)
     {
         if (_offT == null)
         {
             _offT = Text;
             add(_offT);
         }
         else
             _offT = replace(_offT, Text) as FlxText;
     }
     if (TextHighlight == null)
         _onT = _offT;
     else
     {
         if (_onT == null)
         {
             _onT = TextHighlight;
             add(_onT);
         }
         else
             _onT = replace(_onT, TextHighlight) as FlxText;
     }
     _offT.scrollFactor = scrollFactor;
     _onT.scrollFactor = scrollFactor;
     return this;
 }
Beispiel #21
0
 /**
  * Creates a new <code>FlxButton</code> object with a gray background
  * and a callback function on the UI thread.
  *
  * @param	X			The X position of the button.
  * @param	Y			The Y position of the button.
  * @param	Callback	The function to call whenever the button is clicked.
  */
 public FlxButton(int X, int Y, FlxButtonClick Callback)
     : base()
 {
     x = X;
     y = Y;
     width = 100;
     height = 20;
     _off = new FlxSprite().createGraphic((int)width, (int)height, new Color(0x7f, 0x7f, 0x7f));
     _off.solid = false;
     add(_off, true);
     _on = new FlxSprite().createGraphic((int)width, (int)height, Color.White);
     _on.solid = false;
     add(_on, true);
     _offT = null;
     _onT = null;
     _callback = Callback;
     _onToggle = false;
     _pressed = false;
     _initialized = false;
     _sf = Vector2.Zero;
     pauseProof = false;
 }