Пример #1
0
        public void advanceToNextState()
        {
            Console.WriteLine("Advance to next state");

            if (_nameEntry.text == "")
            {
                FlxG.setHudText(2, "Name cannot be blank");

                return;
            }

            FlxG.username = _nameEntry.text;

            SaveToDevice();

            //FlxOnlineStatCounter.sendStats("slfparttwo", "zero", Lemonade_Globals.PAID_VERSION+1);


            FlxG.level = 1;
            FlxG.score = 0;
            FlxG.hideHud();

                        #if __ANDROID__
            FlxG.state = new IntroState();
                        #endif
                        #if !__ANDROID__
            FlxG.state = new IntroState();
                        #endif

            return;
        }
Пример #2
0
        /**
         * You can use this if you have a lot of text parameters to set instead of
         * the individual properties.
         *
         * @param Font The name of the font face for the text display.
         * @param Size The size of the font (in pixels essentially).
         * @param Color The color of the text in 0xRRGGBB format.
         * @param Alignment A string representing the desired alignment
         *        ("left,"right" or "center").
         * @param ShadowColor An int representing the desired text shadow color
         *        0xAARRGGBB format.
         * @param ShadowX The x-position of the shadow, default is 1.
         * @param ShadowY The y-position of the shadow, default is 1.
         *
         * @return This FlxText instance (nice for chaining stuff together, if
         *         you're into that).
         */
        public FlxText setFormat(String Font, float size, Color color, String Alignment, Color ShadowColor, float ShadowX = 1f, float ShadowY = 1f)
        {
            if (Font == null)
            {
                Font = _font;
            }
            _size = (int)FlxU.floor(size);
            if (Font != null && (!Font.Equals(_font) || size != _size))
            {
                try {
                    //_textField = new SpriteBatch(FlxG.loadFont(Font, FlxU.round(Size), _bitmapFontParameter));
                    //_textField = new SpriteBatch(GraphicsDevice);
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                    FlxG.log(e.Message);
                    //_textField = new SpriteBatch(FlxG.loadFont("org/flixel/data/font/nokiafc.fnt", 22, _bitmapFontParameter));
                }

                _font      = Font;
                LoadedFont = FlxS.ContentManager.Load <SpriteFont> (_font);
            }

            Color = color;
            if (Alignment != null)
            {
                _alignment = (Alignment.ToUpper());
            }
            _shadow  = ShadowColor;
            _shadowX = ShadowX;
            _shadowY = ShadowY;

            calcFrame();

            return(this);
        }
Пример #3
0
        override public void create()
        {
            base.create();

            FlxG.resetHud();
            FlxG.hideHud();

            _world.Gravity.Y = 0;

            team1 = new FlxGroup();
            team2 = new FlxGroup();

            puck = new FarSprite(FlxG.width / 2, FlxG.height / 2, _world);
            puck.createGraphic(20, 20, Color.Green);
            puck.attachCircle(20, 20);
            add(puck);

            puck._body.ApplyLinearImpulse(new Vector2(FlxU.random(-15000, 15000), FlxU.random(-15000, 15000)));


            for (int i = 0; i < 6; i++)
            {
                FarSprite p1 = new FarSprite(i * 80, (int)FlxU.random(0, FlxG.height), _world);

                p1.createGraphic(4, 40, Color.Red);

                p1.attachRectangle(4, 40);

                team1.add(p1);
            }

            add(team1);
            add(team2);
        }
Пример #4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _bat.Velocity.X = 0;

            //TODO : Touch controls

            if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Left, Keys.A }) && _bat.X > 10)
            {
                _bat.Velocity.X = -BAT_SPEED;
            }
            else if (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.Right, Keys.D }) && _bat.X < 270)
            {
                _bat.Velocity.X = BAT_SPEED;
            }

            if (FlxG.Keyboard.JustReleased(Keys.R))
            {
                FlxG.ResetState();
            }

            if (_bat.X < 10)
            {
                _bat.X = 10;
            }
            if (_bat.X > 270)
            {
                _bat.X = 270;
            }

            FlxG.Collide(_ball, _walls);
            FlxG.Collide(_bat, _ball, Ping);
            FlxG.Collide(_ball, _bricks, Hit);
        }
Пример #5
0
        override public void update()
        {
            if (FlxControl.ACTIONJUSTPRESSED || FlxG.mouse.pressed())
            {
                if (elapsedInState > 0.15f)
                {
                    FlxG.play("putt/sfx/blip");
                    toStart        = true;
                    elapsedInState = 0;
                }
            }

            if (toStart)
            {
                text.color = FlxColor.randomColor();

                if (elapsedInState > 0.25f)
                {
                    FlxG.stopMp3();
                    Globals.canSkip = false;
                    Globals.hole    = 1;
                    FlxG.state      = new MenuState();
                }
            }


            base.update();
        }
Пример #6
0
        override public void update()
        {
            FlxG.setHudText(1, "Car Speed: " + car.pathSpeed.ToString() + "\nCar Cornering: " + car.pathCornering.ToString());

            if (FlxG.keys.DOWN)
            {
                car.pathSpeed -= 10;
            }
            if (FlxG.keys.UP)
            {
                car.pathSpeed += 10;
            }
            if (FlxG.keys.LEFT)
            {
                car.pathCornering -= 0.1f;
            }
            if (FlxG.keys.RIGHT)
            {
                car.pathCornering += 0.1f;
            }



            if (car.pathSpeed > 1300)
            {
                FlxG.quake.start(0.05f, 0.5f);
            }


            base.update();
        }
		//This function is passed to FlxG.fade() when we are ready to go to the next game state.
		//When FlxG.fade() finishes, it will call this, which in turn will either load
		//up a game demo/replay, or let the player start playing, depending on user input.
		protected void onFade()
		{
			/*if(attractMode)
				FlxG.loadReplay((FlxG.random()<0.5f)?FlxG.loadString(Attract1):FlxG.loadString(Attract2),new ModePlayState(),new String[]{"ANY"},22, onDemoComplete);
			else*/
				FlxG.switchState(new ModePlayState());
		}
Пример #8
0
        /// <summary>
        /// This function creates a flat colored square image dynamically.
        /// </summary>
        /// <param name="width">The width of the sprite you want to generate.</param>
        /// <param name="height">The height of the sprite you want to generate.</param>
        /// <param name="color">Specifies the color of the generated block.</param>
        /// <param name="unique">Whether the graphic should be a unique instance in the graphics cache. Default is false.</param>
        /// <param name="key">Optional parameter - specify a string key to identify this graphic in the cache. Trumps Unique flag.</param>
        /// <returns></returns>
        public FlxSprite makeGraphic(uint width, uint height, Color color, bool unique = false, string key = null)
        {
            /*
             * if (unique || !string.IsNullOrEmpty(key))
             * {
             * throw new NotSupportedException();
             * }
             */
            _bakedRotation = 0;
            _pixels        = FlxG.createBitmap(width, height, color, unique, key);

            Width       = width;
            FrameWidth  = width;
            Height      = height;
            FrameHeight = height;

            resetHelpers();

            // flx# stuff
            drawSourceRect = new Rectangle(0, 0, (int)width, (int)height);

            texture    = _pixels;
            sourceRect = new FlxRect(0, 0, width, height);

            return(this);
        }
Пример #9
0
        /// <summary>
        /// Plays an existing animation (e.g. "run").
        /// If you call an animation that is already playing it will be ignored.
        /// </summary>
        /// <param name="animName">The string name of the animation you want to play.</param>
        /// <param name="force">Whether to force the animation to restart.</param>
        public void play(String animName, Boolean force = false)
        {
            if (!force && (_curAnim != null) && (animName == _curAnim.Name) && (_curAnim.Looped || !Finished))
            {
                return;
            }
            _curFrame   = 0;
            _curIndex   = 0;
            _frameTimer = 0;

            foreach (FlxAnim animation in _animations)
            {
                if (animation.Name.Equals(animName))
                {
                    _curAnim = animation;

                    if (_curAnim.Delay <= 0)
                    {
                        Finished = true;
                    }
                    else
                    {
                        Finished = false;
                    }

                    _curIndex = _curAnim.Frames[_curFrame];
                    Dirty     = true;
                    return;
                }
            }

            FlxG.log("WARNING: No animation called \"" + animName + "\"");
        }
Пример #10
0
 public override void update()
 {
     base.update();
     if (FlxG.keys.justPressed(Keys.Up))
     {
         if (selectedID == 0)
         {
             selectedID = (int)_items.length - 1;
         }
         else
         {
             selectedID--;
         }
         updateSelected();
     }
     if (FlxG.keys.justPressed(Keys.Down))
     {
         if (selectedID == (int)_items.length - 1)
         {
             selectedID = 0;
         }
         else
         {
             selectedID++;
         }
         updateSelected();
     }
     if (FlxG.keys.justPressed(Keys.Enter))
     {
         FlxG.switchState(_states[selectedID]);
     }
 }
        override public void update()
        {
            base.update();

            if (instruction.visible)
            {
                if (tween.hasEnded)
                {
                    FlxG.play("Lemonade/sfx/cw_sound09", 0.75f, false);
                }
            }

            tween.Update(FlxG.elapsedAsGameTime);
            instruction.y = tween.Position;


            if (((follower.y > int.MaxValue && follower.x == 0) ||
                 (FlxG.keys.justPressed(Keys.X) && follower.y > 100) ||
                 (FlxG.gamepads.isNewButtonPress(Buttons.A) && follower.y > 100) || (FlxControl.ACTIONJUSTPRESSED && follower.y > 100)) &&
                (FlxG.transition.members[0] as FlxSprite).scale < 0.001f)
            {
                FlxG.transition.startFadeOut(0.15f, -90, 150);
                follower.x = 1;
            }
            if (FlxG.transition.complete)
            {
#if __ANDROID__
                FlxG.state = new IntroState();
#endif
#if !__ANDROID__
                FlxG.state = new IntroState();
#endif
                return;
            }
        }
Пример #12
0
        void RandomizeFruitPosition(FlxObject object1 = null, FlxObject object2 = null)
        {
            _fruit.X = FlxG.Random.Next(0, (int)Math.Floor(FlxG.Width / 8f) - 1) * 8f;
            _fruit.Y = FlxG.Random.Next(0, (int)Math.Floor(FlxG.Height / 8f) - 1) * 8f;

            FlxG.Overlap(_fruit, _snakeBody, RandomizeFruitPosition);
        }
Пример #13
0
        public override void create()
        {
            _timer  = 0;
            _fading = false;
            FlxG.flash(Color.White);

            //Gibs emitted upon death
            FlxEmitter gibs = new FlxEmitter(0, -50);

            gibs.setSize((uint)FlxG.width, 0);
            gibs.setXSpeed();
            gibs.setYSpeed(0, 100);
            gibs.setRotation(-360, 360);
            gibs.gravity = 80;
            gibs.makeParticles(ImgGibs, 800, 32, true, 0);
            add(gibs);
            gibs.start(false, 0, 0.005f);

            FlxText text = new FlxText(0, FlxG.height / 2 - 35, FlxG.width, "VICTORY\n\nSCORE: " + FlxG.score);

            /*
             * if(Gdx.app.getType() == ApplicationType.WebGL)
             *      text.setFormat(ImgFont20,20,0xd8eba2,"center");
             * else
             *      text.setFormat(null,16,0xd8eba2,"center");*/
            add(text);
        }
Пример #14
0
        override public void create()
        {
            base.create();

            //FlxG.hideHud();
            FlxG.resetHud();

            _world = new World(new Vector2(0, 980.0f));

            _ground          = BodyFactory.CreateRectangle(_world, 3000, 20, 1.0f, new Vector2(0, 700), null);
            _ground.BodyType = BodyType.Static;

            g1 = new FlxSprite(0, 700);
            g1.loadGraphic("flixel/diagnostic/testpalette", true, false, 1000, 20);
            add(g1);

            for (int i = 0; i < 40; i++)
            {
                FarSprite f = new FarSprite(Convert.ToInt32(FlxU.random(90, 800)), Convert.ToInt32(FlxU.random(-600, 0)), _world);
                f.loadGraphic("flixel/initials/crate_80x60", true, false, FlxU.randomInt(20, 40), FlxU.randomInt(40, 60));
                f._body.AngularVelocity = FlxU.randomInt(0, 5);
                add(f);
            }


            List <Dictionary <string, string> > completeSet = new List <Dictionary <string, string> >();

            string currentLevel = "l" + FlxG.level.ToString();

            XDocument xdoc = XDocument.Load("Content/flixel/ogmo/PhysicsLevel.oel");

            // Load level main stats.
            XElement xelement = XElement.Load("Content/flixel/ogmo/PhysicsLevel.oel");
            IEnumerable <XAttribute> attList =
                from at in xelement.Attributes()
                select at;

            foreach (XAttribute xAttr in attList)
            {
                //Console.WriteLine(xAttr.Name.ToString() + "  " + xAttr.Value.ToString());
                //levelAttrs.Add(xAttr.Name.ToString(), xAttr.Value.ToString());
            }

            foreach (XElement xEle in xdoc.Descendants("level").Descendants("NewLayer0").Elements())
            {
                Console.WriteLine(xEle.Name.ToString() + "  " + xEle.Attribute("x").ToString().Split('=')[1].Replace('\"', ' '));


                FarSprite f = new FarSprite(
                    Convert.ToInt32(xEle.Attribute("x").ToString().Split('=')[1].Replace('\"', ' ')) + 500,
                    Convert.ToInt32(xEle.Attribute("y").ToString().Split('=')[1].Replace('\"', ' ')) + 220,
                    _world);

                f.loadGraphic("flixel/initials/crate_80x60", true, false,
                              Convert.ToInt32(xEle.Attribute("width").ToString().Split('=')[1].Replace('\"', ' ')),
                              Convert.ToInt32(xEle.Attribute("height").ToString().Split('=')[1].Replace('\"', ' ')));

                add(f);
            }
        }
Пример #15
0
        public override void Update(GameTime gameTime)
        {
            if (FlxG.PixelPerfectOverlap(_player, _spikeBottom) || FlxG.PixelPerfectOverlap(_player, _spriteTop) ||
                FlxG.PixelPerfectOverlap(_player, _paddleLeft) || FlxG.PixelPerfectOverlap(_player, _paddleRight))
            {
                _player.Kill();
            }

            if (_player.X < 5)
            {
                _player.X          = 5;
                _player.Velocity.X = -_player.Velocity.X;
                _player.FlipX      = false;
                IncreaseScore();
                _bounceLeft.Animation.Play("flash");
                _paddleRight.Randomize();
            }
            else if (_player.X + _player.Width > FlxG.Width - 5)
            {
                _player.X          = FlxG.Width - _player.Width - 5;
                _player.Velocity.X = -_player.Velocity.X;
                _player.FlipX      = true;
                IncreaseScore();
                _bounceRight.Animation.Play("flash");
                _paddleLeft.Randomize();
            }

            if (FlxG.Keyboard.JustPressed(Keys.E) && (FlxG.Keyboard.AnyPressed(new Keys[] { Keys.LeftShift, Keys.RightShift, Keys.LeftControl, Keys.RightControl, Keys.RightAlt, Keys.LeftAlt })))
            {
                ClearSave();
                FlxG.ResetState();
            }

            base.Update(gameTime);
        }
Пример #16
0
 //This is run when you flip the collision
 private void onCollision()
 {
     isCollisionOn = !isCollisionOn;
     if (isCollisionOn)
     {
         if (isGravityOn)
         {
             floor.Solid   = true;                      //Set the floor to the 'active' collision barrier
             floor.Visible = true;
             wall.Solid    = false;
             wall.Visible  = false;
         }
         else
         {
             floor.Solid   = false;                     //Set the wall to the 'active' collision barrier
             floor.Visible = false;
             wall.Solid    = true;
             wall.Visible  = true;
         }
         topText.text = "Collision: ON";
     }
     else
     {
         //Turn off the wall and floor, completely
         wall.Solid   = floor.Solid = wall.Visible = floor.Visible = false;
         topText.text = "Collision: OFF";
     }
     topText.Alpha = 1;
     FlxG.log("Toggle Collision");
 }
Пример #17
0
        /// <summary>
        /// Instantiate a new game object.
        /// </summary>
        /// <param name="gameSizeX">The width of your game in game pixels, not necessarily final display pixels (see Zoom).</param>
        /// <param name="gameSizeY">The height of your game in game pixels, not necessarily final display pixels (see Zoom).</param>
        /// <param name="initialState">The class name of the state you want to create and switch to first (e.g. MenuState).</param>
        /// <param name="zoom">The default level of zoom for the game's cameras (e.g. 2 = all pixels are now drawn at 2x). Default = 1.</param>
        /// <param name="gameFramerate">How frequently the game should update (default is 60 times per second).</param>
        /// <param name="flashFramerate">Sets the actual display framerate for Flash player (default is 30 times per second).</param>
        /// <param name="useSystemCursor">Whether to use the default OS mouse pointer, or to use custom flixel ones.</param>
        public FlxGame(int gameSizeX,
                       int gameSizeY,
                       FlxState initialState,
                       float zoom           = 1.0f,
                       int gameFramerate    = 60,
                       int flashFramerate   = 0,
                       bool useSystemCursor = false) : base()
        {
            if (flashFramerate != 0)
            {
                throw new NotSupportedException();
            }

            // super high priority init stuff (focus, mouse, etc)
            LostFocus = false;

            /*
             *          _focus = new Sprite();
             *          _focus.visible = false;
             *          _soundTray = new Sprite();
             *          _mouse = new Sprite()
             */

            // flx# - the tight stuff is done in Initialize

            // basic display and update setup stuff
            FlxG.init(this, gameSizeX, gameSizeY, zoom);
            FlxG.Framerate = gameFramerate;
            //FlxG.FlashFramerate = flashFramerate;
            Accumulator     = StepMS;
            Total           = 0;
            State           = null;
            UseSoundHotKeys = true;
            UseSystemCursor = useSystemCursor;

            if (!useSystemCursor)
            {
                //flash.ui.mouse.hide();
            }

            ForceDebugger = false;
            //_debuggerUp = false;

            // replay data

            /*
             * _replay = new FlxReplay();
             * _replayRequested = false;
             * _recordingRequested = false;
             * _replaying = false;
             * _recording = false;
             */

            // then get ready to create the game object for real
            InitialState   = initialState;
            RequestedState = null;
            RequestedReset = true;
            Created        = false;
            //addEventListener(Event.ENTER_FRAME, create);
        }
Пример #18
0
        /// <summary>
        /// If there is a state change requested during the update loop,
        /// this function handles actual destroying the old state and related processes,
        /// and calls creates on the new state and plugs it into the game object.
        /// </summary>
        protected void switchState()
        {
            FlxG.resetCameras();
            FlxG.resetInput();
            FlxG.destroySounds();
            //FlxG.clearBitmapCache();

            // Clear the debugger overlay's Watch window
            //if(_debugger != null)
            //    _debugger.watch.removeAll();

            // Clear any timers left in the timer manager
            //var timerManager:TimerManager = FlxTimer.manager;
            //if(timerManager != null)
            //    timerManager.clear();

            // Destroy the old state (if there is an old state)
            if (State != null)
            {
                State.destroy();
            }

            // Finally assign and create the new state
            State = RequestedState;
            State.create();
        }
Пример #19
0
        override public void create()
        {
            base.create();

            FlxG.hideHud();
            FlxG.resetHud();

            robot = new FlxSprite(60, 60);
            robot.loadGraphic("flixel/surt/race_or_die", true, false, 64, 64);
            robot.addAnimation("static", new int[] { 0 }, 12, true);
            robot.play("static");
            robot.angle  = 0;
            robot.width  = 32;
            robot.height = 32;
            robot.setOffset(12, 12);
            robot.health = 100;
            robot.alpha  = 0.1f;

            add(robot);

            bar = new FlxBar(30, 30, FlxBar.FILL_LEFT_TO_RIGHT, 100, 10, robot, "rad", 0, 100, true);
            add(bar);

            bar2 = new FlxBar(60, 90, FlxBar.FILL_LEFT_TO_RIGHT, 20, 2, null, "health", 0, 100, false);
            bar2.loadCustomEmptyGraphic("flixel/initials/healthBar");
            bar2.emptyBar.offset.X = 2;
            bar2.emptyBar.offset.Y = 3;
            add(bar2);
        }
Пример #20
0
        override public void create()
        {
            FlxG.resetHud();
            FlxG.showHud();

            FlxG.backColor = Color.LightGray;

            base.create();

            string levelData = FlxU.randomString(10);

            FlxG.log("levelData: " + levelData);

            makeCave(0.1f, Color.Black);
            makeCave(0.5f, new Color(0.98f, 1.0f, 0.95f));
            makeCave2(1.0f, Color.Green);

            spaceShip = new FlxSprite(60, 60);
            spaceShip.loadGraphic(FlxG.Content.Load <Texture2D>("flixel/surt/spaceship_32x32"), true, false, 32, 32);
            spaceShip.addAnimation("Static", new int[] { 0 }, 36, true);
            spaceShip.addAnimation("Transform", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }, 36, false);
            spaceShip.play("Static");

            spaceShip.setDrags(1100, 1100);
            add(spaceShip);

            FlxG.follow(spaceShip, 10.0f);
            FlxG.followBounds(0, 0, 50 * 16, 40 * 16);
        }
Пример #21
0
        public override void update()
        {
            if (_complex)
            {
                Alpha = (.3f + .7f * Y / FlxG.height);
            }

            if ((X + Width) >= FlxG.width)
            {
                Velocity.X *= -1;
                X           = FlxG.width - Width;
            }
            else if (X <= 0)
            {
                Velocity.X *= -1;
                X           = 0;
            }

            if ((Y + Height) >= FlxG.height)
            {
                Velocity.Y *= -0.8f;
                Y           = FlxG.height - Height;

                if (FlxG.random() > 0.5f)
                {
                    Velocity.Y -= 3 + FlxG.random() * 4;
                }
            }
            else if (Y <= 0)
            {
                Velocity.Y *= -0.8f;
                Y           = 0;
            }
        }
Пример #22
0
        override public void create()
        {
            FlxG.backColor = Color.DarkBlue;



            base.create();


            FlxG.resetHud();


            string textInfo = "";

            textInfo  = "Choose:\n";
            textInfo += "1. Camera Test State\n";
            textInfo += "2. Cave Tiles Test State\n";


            FlxG.setHudText(1, textInfo);
            FlxG.setHudTextPosition(1, 20, 20);
            FlxG.setHudTextScale(1, 3);
            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, FlxHud.Keyboard_1, FlxG.width - 40, 30);

            FlxG.showHud();
        }
Пример #23
0
        override public void create()
        {
            FlxG.backColor = Color.White;

            base.create();

            FlxTileblock t = new FlxTileblock(8, 8, 256 - 16, 224 - 16);

            t.auto = FlxTileblock.HUDELEMENT;
            t.loadTiles("_sheet_window_06", 16, 16, 0);
            add(t);

            FlxG.playMp3("putt/music/March", 1.0f);

            text = new FlxText(16, 16, 200);
            text.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.Black, FlxJustification.Left, Color.White);
            add(text);
            text.text = "Scorecard:\n";

            int total = 0;

            for (int i = 0; i < 18; i++)
            {
                try
                {
                    Console.WriteLine("Score for hole {0}: {1}", i + 1, Globals.scoreCard[i]);
                    text.text += string.Format("{0}: {1}, ", i + 1, Globals.scoreCard[i]);
                    total     += Globals.scoreCard[i];
                    if (i % 3 == 2)
                    {
                        text.text += "\n";
                    }
                }
                catch
                {
                }
            }

            text.text += string.Format("\nTotal: {0} / Par: 18 \n", total);;



            if (total <= 18 && Globals.hasPlayedHoleAgain == false)
            {
                text.text += "\nBonestorm.rom unlocked.";
            }
            else if (total >= 48)
            {
                text.text += "\nSix time national champion\nCarvello urges\nyou to keep practicing\nand improve your\nputting game.";
            }
            else if (total >= 32)
            {
                text.text += "\nYour putting game is improving\nrapidly.\nKeep it up, kid. ";
            }
            else if (total >= 24)
            {
                text.text += "\nYou're a real sharp shooter.";
            }
        }
Пример #24
0
        override public void create()
        {
            base.create();

            FlxG.showHud();
            FlxG.setHudText(1, "Press [`] to show the debug console.\nYou must build with the Debug Solution Configuration.\n\nIn the console press TAB to bring up the cheat menu.\n\nTry typing in the cheat code \"cheatcode\"");
            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD, FlxHud.Keyboard_Tilda, (FlxG.width * 2) - 100, 10);
            FlxG.setHudGamepadButton(FlxHud.TYPE_KEYBOARD_DIRECTION, FlxHud.Keyboard_Tab, (FlxG.width * 2) - 100, 100);
        }
Пример #25
0
 /// <summary>
 /// Simple Controller vibration
 /// </summary>
 /// <param name="Duration">The length in seconds the vibration should last</param>
 /// <param name="IntensityLeftMotor">The intensity of the Left Motor vibration</param>
 /// <param name="IntensityRightMotor">The intensity of the Right Motor vibration</param>
 /// <param name="ShakeScreen">Should the screen shake in unison with the controller vibration</param>
 public void vibrate(float Duration = 0.5f, float IntensityLeftMotor = 0.15f, float IntensityRightMotor = 0.15f, bool ShakeScreen = false)
 {
     vibeDuration = Duration;
     leftVibe     = IntensityLeftMotor;
     rightVibe    = IntensityRightMotor;
     if (ShakeScreen)
     {
         FlxG.shake(IntensityLeftMotor / 20, Duration);
     }
 }
Пример #26
0
        /// <summary>
        /// Returns a member at random from the group.
        /// </summary>
        /// <param name="startIndex"></param>
        /// <param name="selectLength"></param>
        /// <returns></returns>
        public FlxBasic GetRandom(int startIndex = 0, int selectLength = 0)
        {
            if (selectLength == 0)
            {
                selectLength = Members.Count;
            }

            return(FlxG.GetRandom(
                       this.ToArray(), startIndex, selectLength) as FlxBasic);
        }
Пример #27
0
        override public void overlapped(FlxObject obj)
        {
            base.overlapped(obj);

            string overlappedWith = obj.GetType().ToString();

            if ((overlappedWith == "Lemonade.Army" ||
                 overlappedWith == "Lemonade.Inspector" ||
                 overlappedWith == "Lemonade.Chef" ||
                 overlappedWith == "Lemonade.Worker") && !flickering())
            {
                if (obj.dead == false && control == Controls.player)
                {
                    //if (dead == false) FlxG.play("Lemonade/sfx/deathSFX", 0.8f, false);
                    //flicker(2);
                    //kill();
                }
            }
            else if (overlappedWith == "Lemonade.Liselot")
            {
                if (piggyBacking == false && dead == false && flickering() == false)
                {
                    FlxG.play("Lemonade/sfx/cw_sound34", 0.8f, false);

                    control      = Controls.player;
                    piggyBacking = true;
                    ((Liselot)(obj)).piggyBacking = true;
                    ((Liselot)(obj)).parent       = this;
                    ((Liselot)(obj)).control      = Controls.none;
                }
            }
            else if (overlappedWith == "Lemonade.FilingCabinet")
            {
                originalPosition.X = obj.x + 30;
                originalPosition.Y = obj.y;
            }
            else if (overlappedWith == "Lemonade.LargeCrate")
            {
                //Console.WriteLine("crate overlapp");

                ((LargeCrate)(obj)).canExplode = true;

                //if (dashTimer > dashMaxLimit)
                //{
                //    obj.kill();
                //    obj.x = -1000;
                //    obj.y = -1000;
                //}
            }
            //else if (overlappedWith == "Lemonade.Spike")
            //{
            //    //Console.WriteLine("Spike overlapp");
            //    hurt(1);
            //}
        }
Пример #28
0
        /// <summary>
        /// This function can be used both internally and externally to emit the next particle.
        /// </summary>
        public void emitParticle()
        {
            var particle = recycle(typeof(FlxBasic)) as FlxParticle;

            if (particle == null)
            {
                throw new Exception("RecyclingWTFException");
            }

            particle.Lifespan   = lifespan;
            particle.Elasticity = bounce;
            particle.reset(X - ((int)particle.Width >> 1) + FlxG.random() * Width, Y - ((int)particle.Height >> 1) + FlxG.random() * Height);
            particle.Visible = true;

            // jlorek: revisit

            if (minParticleSpeed.X != maxParticleSpeed.X)
            {
                particle.Velocity.X = minParticleSpeed.X + FlxG.random() * (maxParticleSpeed.X - minParticleSpeed.X);
            }
            else
            {
                particle.Velocity.X = minParticleSpeed.X;
            }

            if (minParticleSpeed.Y != maxParticleSpeed.Y)
            {
                particle.Velocity.Y = minParticleSpeed.Y + FlxG.random() * (maxParticleSpeed.Y - minParticleSpeed.Y);
            }
            else
            {
                particle.Velocity.Y = minParticleSpeed.Y;
            }

            particle.Acceleration.Y = gravity;

            if (minRotation != maxRotation)
            {
                particle.AngularVelocity = minRotation + FlxG.random() * (maxRotation - minRotation);
            }
            else
            {
                particle.AngularVelocity = minRotation;
            }

            if (particle.AngularVelocity != 0)
            {
                particle.Angle = FlxG.random() * 360 - 180;
            }

            particle.Visible = true;
            particle.Drag.X  = particleDrag.X;
            particle.Drag.Y  = particleDrag.Y;
            particle.onEmit();
        }
Пример #29
0
        /// <summary>
        /// Goes through the game state and draws all the game objects and special effects.
        /// </summary>
        protected internal void draw()
        {
            //var mark:uint = getTimer();

            FlxG.lockCameras(); // Nothing happens here...
            State.draw();
            FlxG.drawPlugins();
            FlxG.unlockCameras();             // Draw camera FX

            //if(_debuggerUp)
            //	_debugger.perf.flixelDraw(getTimer()-mark);
        }
Пример #30
0
        public Bunny(float x, float y) : base(x, y)
        {
            loadGraphic(ImgBunny, false, false, 26, 37);
            float speedMultiplier = 50f;

            Velocity.X      = speedMultiplier * (FlxG.random() * 5f) * (FlxG.random() < 0.5f ? 1f : -1f);
            Velocity.Y      = speedMultiplier * ((FlxG.random() * 5f) - 2.5f) * (FlxG.random() < 0.5f ? 1f : -1f);
            Acceleration.Y  = 5;
            Angle           = 15 - FlxG.random() * 30;
            AngularVelocity = 30f * (FlxG.random() * 5f) * (FlxG.random() < 0.5f ? 1f : -1f);
            Elasticity      = 1;
        }