コード例 #1
0
 //This function is called when player bullets hit the Enemy.
 //The enemy is told to flicker, points are awarded to the player,
 //and damage is dealt to the Enemy.
 public void hurt(float Damage)
 {
     _sfxHit.play(true);
     flicker(0.2f);
     FlxG.score += 10;
     base.hurt(Damage);
 }
コード例 #2
0
        public void shoot(FlxPoint Location, int Aim)
        {
            _sfxShoot.play(true);
            base.reset(Location.X - Width / 2, Location.Y - Height / 2);
            Solid = true;
            switch ((uint)Aim)
            {
            case Up:
                play("up");
                Velocity.Y = -speed;
                break;

            case Down:
                play("down");
                Velocity.Y = speed;
                break;

            case Left:
                play("left");
                Velocity.X = -speed;
                break;

            case Right:
                play("right");
                Velocity.X = speed;
                break;

            default:
                break;
            }
        }
コード例 #3
0
        public override void kill()
        {
            if (!Alive)
            {
                return;
            }
            _sfxExplode.play(true);
            _sfxExplode2.play(true);
            base.kill();
            Active = false;
            Exists = true;
            Solid  = false;
            flicker(0);
            play("dead");
            FlxG.camera.shake(0.007f, 0.25f);

            /*
             * FlxG.camera.flash(0xffd8eba2,0.65f,new IFlxCamera(){ public void callback(){turnOffSlowMo();}});
             * FlxG.timeScale = 0.35f;
             * makeBot();
             * _gibs.at(this);
             * _gibs.start(true,3);
             * FlxG.score += 1000;
             */
        }
コード例 #4
0
 private void jump()
 {
     if ((int)Velocity.Y == 0)
     {
         Velocity.Y = -_jumpPower;
         _sfxJump.play(true);
     }
 }
コード例 #5
0
 public void shoot(FlxPoint Location, float Angle)
 {
     _sfxShoot.play(true);
     base.reset(Location.X - Width / 2, Location.Y - Height / 2);
     FlxU.rotatePoint(0, (int)speed, 0, 0, Angle, _tagPoint);
     Velocity.X = _tagPoint.X;
     Velocity.Y = _tagPoint.Y;
     Solid      = (true);
     play("idle");
 }
コード例 #6
0
        //Called to kill the enemy.  A cool sound is played,
        //the jets are turned off, bits are exploded, and points are rewarded.

        public override void kill()
        {
            if (!Alive)
            {
                return;
            }
            _sfxExplode.play(true);
            base.kill();
            flicker(0);
            _jets.kill();
            _gibs.at(this);
            _gibs.start(true, 3, 0, 20);
            FlxG.score += 200;
        }
コード例 #7
0
 public override void kill()
 {
     if (!Alive)
     {
         return;
     }
     Velocity.X = 0;
     Velocity.Y = 0;
     if (onScreen())
     {
         _sfxHit.play(true);
     }
     Alive = false;
     Solid = (false);
     play("poof");
 }
コード例 #8
0
 public override void kill()
 {
     if (!Alive)
     {
         return;
     }
     Solid = false;
     _sfxExplode.play(true);
     _sfxExplode2.play(true);
     base.kill();
     flicker(0);
     Exists  = true;
     Visible = false;
     Velocity.make();
     Acceleration.make();
     FlxG.camera.shake(0.005f, 0.35f);
     FlxG.camera.Flash(Color.White, 0.35f);
     if (_gibs != null)
     {
         _gibs.at(this);
         _gibs.start(true, 5, 0, 50);
     }
 }
コード例 #9
0
 public void hurt(float Damage)
 {
     Damage = 0;
     if (flickering)
     {
         return;
     }
     _sfxHurt.play(true);
     flicker(1.3f);
     if (FlxG.score > 1000)
     {
         FlxG.score -= 1000;
     }
     if (Velocity.X > 0)
     {
         Velocity.X = -MaxVelocity.X;
     }
     else
     {
         Velocity.X = MaxVelocity.X;
     }
     base.hurt(Damage);
 }
コード例 #10
0
        //This is the main flixel update function or loop function.
        //Most of the enemy's logic or behavior is in this function here.

        public override void update()
        {
            //Then, rotate toward that angle.
            //We could rotate instantly toward the player by simply calling:
            //angle = angleTowardPlayer();
            //However, we want some less predictable, more wobbly behavior.
            float da = angleTowardPlayer();

            if (da < Angle)
            {
                AngularAcceleration = -AngularDrag;
            }
            else if (da > Angle)
            {
                AngularAcceleration = AngularDrag;
            }
            else
            {
                AngularAcceleration = 0;
            }

            //Figure out if we want the jets on or not.
            _timer += FlxG.elapsed;
            if (_timer > 8)
            {
                _timer = 0;
            }
            bool jetsOn = _timer < 6;

            //Set the bot's movement speed and direction
            //based on angle and whether the jets are on.
            _thrust = FlxU.computeVelocity(_thrust, (jetsOn?90:0), Drag.X, 60);
            FlxU.rotatePoint(0, (int)_thrust, 0, 0, Angle, Velocity);

            //Shooting - three shots every few seconds
            if (onScreen())
            {
                bool  shoot = false;
                float os    = _shotClock;
                _shotClock += FlxG.elapsed;
                if ((os < 4.0) && (_shotClock >= 4.0))
                {
                    _shotClock = 0;
                    shoot      = true;
                }
                else if ((os < 3.5) && (_shotClock >= 3.5))
                {
                    shoot = true;
                }
                else if ((os < 3.0) && (_shotClock >= 3.0))
                {
                    shoot = true;
                }

                //If we rolled over one of those time thresholds,
                //shoot a bullet out along the angle we're currently facing.
                if (shoot)
                {
                    //First, recycle a bullet from the bullet pile.
                    //If there are none, recycle will automatically create one for us.
                    EnemyBullet b = (EnemyBullet)_bullets.recycle(typeof(EnemyBullet));
                    //Then, shoot it from our midpoint out along our angle.
                    b.shoot(getMidpoint(_tagPoint), Angle);
                }
            }

            //Then call FlxSprite's update() function, to automate
            // our motion and animation and stuff.
            base.update();

            //Finally, update the jet particles shooting out the back of the ship.
            if (jetsOn)
            {
                if (!_jets.on)
                {
                    //If they're supposed to be on and they're not,
                    //turn em on and play a little sound.
                    _jets.start(false, 0.5f, 0.01f);
                    if (onScreen())
                    {
                        _sfxJet.play(true);
                    }
                }
                //Then, position the jets at the center of the Enemy,
                //and point the jets the opposite way from where we're moving.
                _jets.at(this);
                _jets.setXSpeed(-Velocity.X - 30, -Velocity.X + 30);
                _jets.setYSpeed(-Velocity.Y - 30, -Velocity.Y + 30);
            }
            else                //If jets are supposed to be off, just turn em off.
            {
                _jets.on = false;
            }
            //Finally, update the jet emitter and all its member sprites.
            _jets.update();
        }
コード例 #11
0
        public override void update()
        {
            /*
             * if(_pad.Visible)
             *      _pad.update();
             */

            //save off the current score and update the game state
            int oldScore = FlxG.score;

            base.update();

            //collisions with environment
            FlxG.collide(_blocks, _objects);
            FlxG.overlap(_hazards, _player, overlapped);
            FlxG.overlap(_bullets, _hazards, overlapped);

            //check to see if the player scored any points this frame
            bool scoreChanged = oldScore != FlxG.score;

            //Jammed message
            if ((FlxG.keys.justPressed(Keys.C) /*|| _pad.buttonB.status == FlxButton.Pressed*/) && _player.flickering)
            {
                _jamTimer       = 1;
                _gunjam.Visible = true;
            }
            if (_jamTimer > 0)
            {
                if (!_player.flickering)
                {
                    _jamTimer = 0;
                }
                _jamTimer -= FlxG.elapsed;
                if (_jamTimer < 0)
                {
                    _gunjam.Visible = false;
                }
            }

            if (!_fading)
            {
                //Score + countdown stuffs
                if (scoreChanged)
                {
                    _scoreTimer = 2;
                }
                _scoreTimer -= FlxG.elapsed;
                if (_scoreTimer < 0)
                {
                    if (FlxG.score > 0)
                    {
                        if (FlxG.score > 100)
                        {
                            FlxG.score -= 100;
                        }
                        else
                        {
                            FlxG.score = 0;
                            _player.kill();
                        }
                        _scoreTimer  = 1;
                        scoreChanged = true;

                        //Play loud beeps if your score is low
                        float volume = 0.35f;
                        if (FlxG.score < 600)
                        {
                            volume = 1.0f;
                        }
                        _sfxCount.Volume = volume;
                        _sfxCount.play(true);
                    }
                }

                //Fade out to victory screen stuffs
                if (_spawners.CountLiving() <= 0)
                {
                    _fading = true;
                    FlxG.fade(Color.Black, 3, onVictory);
                }
            }

            //actually update score text if it changed
            if (scoreChanged)
            {
                if (!_player.Alive)
                {
                    FlxG.score = 0;
                }
                _score.text = "" + FlxG.score;
            }
        }
コード例 #12
0
ファイル: FlxG.cs プロジェクト: jlorek/flxSharp
        /// <summary>
        /// Creates a new sound object.
        /// </summary>
        /// <param name="soundEffect">The embedded sound resource you want to play. To stream, use the optional URL parameter instead.</param>
        /// <param name="volume">How loud to play it (0 to 1).</param>
        /// <param name="looped">Whether to loop this sound.</param>
        /// <param name="autoDestroy">Whether to destroy this sound when it finishes playing. Leave this value set to "false" if you want to re-use this <code>FlxSound</code> instance.</param>
        /// <param name="autoPlay">Whether to play the sound.</param>
        /// <param name="url">Load a sound from an external web resource instead. Only used if EmbeddedSound = null.</param>
        /// <returns>A <code>FlxSound</code> object.</returns>
        public static FlxSound loadSound(SoundEffect soundEffect, float volume = 1.0f, bool looped = false, bool autoDestroy = false, bool autoPlay = false, string url = null)
        {
            if (!string.IsNullOrEmpty(url))
            {
                throw new NotSupportedException();
            }

            var sound = new FlxSound();
            sound.loadEmbedded(soundEffect, looped, autoDestroy);
            sound.Volume = volume;

            if (autoPlay)
            {
                sound.play();
            }

            return sound;
        }
コード例 #13
0
 public void playSound(string Sound)
 {
     sound.loadEmbedded("putt/sfx/" + Sound, false);
     sound.play();
 }
コード例 #14
0
        override public void create()
        {
            base.create();

            rollIndicators = new FlxGroup();

            framesElapsed = 0;

            selected = 0;
            suggestionForClubNoted   = false;
            suggestionForForceNoted  = false;
            suggestionForClubStatus  = 0;
            suggestionForForceStatus = 0;
            selectedClub             = 0;
            playAgainSelected        = 0;

            Globals.ballInHole = false;


            //"Sand Wedge" }

            clubs = new List <string> {
                "Putter", "1 Wood", "3 Wood", "5 Wood",
                "1 Iron", "2 Iron", "3 Iron", "4 Iron", "5 Iron", "6 Iron", "7 Iron", "8 Iron", "9 Iron"
            };

            //, "Chip Shot", "Pitch", "Fade", "Draw", "Lay-up", "Knock Down", "Flop"
            force = new List <string> {
                "Feather Touch", "Firm Putt", "Power Drive"
            };

            playAgain = new List <string> {
                "Yes", "No", "Skip Hole +9"
            };

            game = new FlxSprite(0, 0);
            game.loadGraphic("putt/bg", true, false, 256, 224);
            game.boundingBoxOverride = false;

            add(game);



            ball = new Ball(FlxG.width / 2 - 8, FlxG.height - 24);


            hole = new Hole(FlxG.width / 2, FlxG.height / 2);

            // load the level.
            loadOgmo();


            add(hole);
            add(ball);


            lee = new Lee(FlxG.width / 6, FlxG.height - 170);
            add(lee);

            aim   = new Aim(1, FlxG.height / 2);
            aim.y = hole.y - aim.width;
            add(aim);

            power = new FlxBar(FlxG.width - 110, FlxG.height - 30, FlxBar.FILL_LEFT_TO_RIGHT, 80, 8, null, "", 0, 50, true);
            add(power);
            power.visible         = false;
            power.useCustomColors = true;


            sound = new FlxSound();
            sound.loadEmbedded(Globals.ContentFolder + "/sfx/welcome", false);

            if (Globals.hole == 1)
            {
                sound.play();
            }

            actionButton         = new ActionButton(FlxG.width - 40, FlxG.height - 40);
            actionButton.visible = false;
            add(actionButton);


            if (FlxG.debug && Globals.platform == "Touch")
            {
                FlxG.mouse.show();
            }
            if (Globals.platform == "Touch")
            {
                actionButton.visible = true;
            }


            add(rollIndicators);

            carPark         = new CarPark(0, 0);
            carPark.visible = false;
            add(carPark);

            text = new FlxText(22, 16, 200);
            text.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.Yellow, FlxJustification.Left, Color.Black);

            add(text);

            subtitle = new FlxText(22, 2, FlxG.width);
            subtitle.setFormat(FlxG.Content.Load <SpriteFont>("flixel/initials/SMALL_PIXEL"), 1, Color.White, FlxJustification.Left, Color.Black);

            add(subtitle);

            activator = new Carrot((int)text.x - 11, (int)text.y);
            //activator.createGraphic(8, 8, Color.Violet);
            activator.visible = false;
            add(activator);

            log("Welcome to " + Globals.GameNameSplit);


            if (Globals.pirate && Globals.hole >= 4)
            {
                                #if !__IOS__
                FlxU.openURL("http://initialsgames.com/");


                FlxG.Game.Exit();
                                #endif
            }
        }
コード例 #15
0
        public override void update()
        {
            //game restart timer
            if (!Alive)
            {
                _restart += FlxG.elapsed;
                if (_restart > 2)
                {
                    FlxG.resetState();
                }
                return;
            }

            //make a little noise if you just touched the floor
            if (justTouched(Floor) && (Velocity.Y > 50))
            {
                _sfxLand.play(true);
            }

            //MOVEMENT
            Acceleration.X = 0;
            if (FlxG.keys.pressed(Keys.Left) /*|| _pad.buttonLeft.status == FlxButton.Pressed*/)
            {
                Facing          = Left;
                Acceleration.X -= Drag.X;
            }
            else if (FlxG.keys.pressed(Keys.Right) /*|| _pad.buttonRight.status == FlxButton.Pressed*/)
            {
                Facing          = Right;
                Acceleration.X += Drag.X;
            }
            if (FlxG.keys.justPressed(Keys.X))
            {
                jump();
            }

            //AIMING
            if (FlxG.keys.pressed(Keys.Up) /*|| _pad.buttonUp.status == FlxButton.Pressed*/)
            {
                _aim = Up;
            }
            else if ((FlxG.keys.pressed(Keys.Down) /*|| _pad.buttonDown.status == FlxButton.Pressed*/) && Velocity.Y != 0)
            {
                _aim = Down;
            }
            else
            {
                _aim = Facing;
            }

            //ANIMATION
            if (Velocity.Y != 0)
            {
                if (_aim == Up)
                {
                    play("jump_up");
                }
                else if (_aim == Down)
                {
                    play("jump_down");
                }
                else
                {
                    play("jump");
                }
            }
            else if (Velocity.X == 0)
            {
                if (_aim == Up)
                {
                    play("idle_up");
                }
                else
                {
                    play("idle");
                }
            }
            else
            {
                if (_aim == Up)
                {
                    play("run_up");
                }
                else
                {
                    play("run");
                }
            }

            //SHOOTING
            if (FlxG.keys.pressed(Keys.C) /*|| _pad.buttonB.status == FlxButton.Pressed*/)
            {
                if (!_justShoot)
                {
                    if (flickering)
                    {
                        _sfxJam.play(true);
                    }
                    else
                    {
                        getMidpoint(_tagPoint);
                        ((Bullet)_bullets.recycle(typeof(Bullet))).shoot(_tagPoint, (int)_aim);
                        if (_aim == Down)
                        {
                            Velocity.Y -= 36;
                        }
                    }
                    _justShoot = true;
                }
            }
            else
            {
                _justShoot = false;
            }
        }