This is the main type for your game
Наследование: Microsoft.Xna.Framework.Game
Пример #1
0
 public ShotgunShell(PlatformerGame level, Vector2 position)
 {
     this.game = level;
     Position  = position;
     IsAlive   = false;
     LoadContent();
 }
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main()
 {
     using (var game = new PlatformerGame())
     {
         game.Run();
     }
 }
Пример #3
0
 public HandgunBullet(PlatformerGame level, Vector2 position)
 {
     this.game = level;
     Position  = position;
     IsAlive   = false;
     LoadContent();
 }
Пример #4
0
 public ShotgunShell(PlatformerGame level, Vector2 position)
 {
     this.game = level;
     Position = position;
     IsAlive = false;
     LoadContent();
 }
Пример #5
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (PlatformerGame game = new PlatformerGame())
     {
         game.Run();
     }
 }
Пример #6
0
        public void LoadContent()
        {
            int rand = PlatformerGame.RandomBetween(0, 100);

            if (rand >= 0 && rand <= 25)
            {
                idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/donut"), 0.1f, false);
            }
            else if (rand > 25 && rand <= 50)
            {
                idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/duff"), 0.1f, false, 71);
            }
            else if (rand > 50 && rand <= 75)
            {
                idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/chunli"), 0.1f, false, 40);
            }
            else if (rand > 75)
            {
                idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/winning"), 0.1f, false, 200);
            }
            sprite.PlayAnimation(idleAnimation);

            // Calculate bounds within texture size.
            int width  = (int)(idleAnimation.FrameWidth * 1.5);
            int left   = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.7);
            int top    = idleAnimation.FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
        }
Пример #7
0
 public BowserFire(PlatformerGame level, Vector2 position)
 {
     this.game = level;
     Position  = position;
     IsAlive   = false;
     LoadContent();
 }
Пример #8
0
 public BowserFire(PlatformerGame level, Vector2 position)
 {
     this.game = level;
     Position = position;
     IsAlive = false;
     LoadContent();
 }
Пример #9
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (PlatformerGame game = new PlatformerGame())
     {
         game.Run();
     }
 }
Пример #10
0
 public HandgunBullet(PlatformerGame level, Vector2 position)
 {
     this.game = level;
     Position = position;
     IsAlive = false;
     LoadContent();
 }
Пример #11
0
        internal static void RunGame()
        {
            platformer = new PlatformerGame();
            platformer.Run();
#if !__IOS__ && !__TVOS__
            platformer.Dispose();
#endif
        }
Пример #12
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // Fun begins..
            MonoGameGame = new PlatformerGame();
            MonoGameGame.Run();

            return(true);
        }
Пример #13
0
        /// <summary>
        /// Constructs a new Spike
        /// </summary>
        public Knife(PlatformerGame level, Vector2 position, Player player)
        {
            this.game = level;
            this.position = position;
            this._player = player;

            LoadContent();
        }
Пример #14
0
        internal static void RunGame()
        {
            game = new PlatformerGame();
            game.Run();
#if !__IOS__ && !__TVOS__
            game.Dispose();
#endif
        }
 public GrenadeExplosion(PlatformerGame game, Vector2 position, Player player)
 {
     this.game = game;
     this._player = player;
     Position = position;
     IsAlive = false;
     LoadContent();
 }
Пример #16
0
 public GrenadeExplosion(PlatformerGame game, Vector2 position, Player player)
 {
     this.game    = game;
     this._player = player;
     Position     = position;
     IsAlive      = false;
     LoadContent();
 }
Пример #17
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     PlatformerGame.Activity = this;
     PlatformerGame g = new PlatformerGame();
     SetContentView(g.Window);
     g.Run();
 }
Пример #18
0
        public Grenade(PlatformerGame level, Vector2 position, Player player)
        {
            this.game     = level;
            this.position = position;
            this._player  = player;

            LoadContent();
        }
Пример #19
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // Fun begins..
            game = new PlatformerGame ();
            game.Run ();

            return true;
        }
Пример #20
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            PlatformerGame.Activity = this;
            PlatformerGame g = new PlatformerGame();

            SetContentView(g.Window);
            g.Run();
        }
Пример #21
0
        public void OnKilled(Player killedBy)
        {
            onKilledReset();
            PlatformerGame.attacker_id = PlatformerGame.Players.IndexOf(killedBy);
            killedBy.KillCount        += 1;
            sprite.PlayAnimation(dieAnimation);

            //play UT sounds
            PlatformerGame.PlayUTSounds(killedBy.KillCount);
        }
Пример #22
0
        public override void FinishedLaunching(UIApplication app)
        {
            // Fun begins..
            using (PlatformerGame game = new PlatformerGame())
            {
                game.Run();
            }

            //MediaLibrary lib = new MediaLibrary();
            //object result = lib.Playlists;
        }
Пример #23
0
        /// <summary>
        /// Constructors a new player.
        /// </summary>
        public Player(PlatformerGame level, Vector2 position, int id)
        {
            this.level    = level;
            this.playerId = id;

            LoadContent();

            respawnPosition = position;

            Reset(position);
        }
Пример #24
0
        public override void FinishedLaunching(UIApplication app)
        {
            // Fun begins..
            using (PlatformerGame game = new PlatformerGame())
            {
                game.Run();
            }

            //MediaLibrary lib = new MediaLibrary();
            //object result = lib.Playlists;
        }
Пример #25
0
        /// <summary>
        /// Constructs a new level.
        /// </summary>
        /// <param name="serviceProvider">
        /// The service provider that will be used to construct a ContentManager.
        /// </param>
        /// <param name="fileStream">
        /// A stream containing the tile data.
        /// </param>
        public Level(IServiceProvider serviceProvider, Stream fileStream, int levelIndex, string[] backgroundSet, PlatformerGame game)
        {
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            this.game = game;

            timeRemaining = TimeSpan.FromMinutes(2.0);
            exit[0]       = InvalidPosition;
            exit[1]       = InvalidPosition;

            LoadTiles(fileStream);

            // Load background layer textures. For now, all levels must
            // use the same backgrounds and only use the left-most part of them.
            layers = new Layer[3];
            float scrollRate = 0.2f;

            for (int i = 0; i < layers.Length; ++i)
            {
                layers[i]   = new Layer(Content, backgroundSet[i], scrollRate);
                scrollRate += 0.3f;
            }

            /*
             * for (int i = 0; i < layers.Length; ++i)
             * {
             *  // Choose a random segment if each background layer for level variety.
             *  int segmentIndex = levelIndex;
             *  layers[i] = Content.Load<Texture2D>("Backgrounds/Layer" + i + "_" + segmentIndex);
             * }
             * */

            // Load sounds.
            fallingSound = Content.Load <SoundEffect>("Sounds/fallSound");
            clearSound   = Content.Load <SoundEffect>("Sounds/smb_stage_clear");
            bridgeSound  = content.Load <SoundEffect>("Sounds/bridgeSound");

            camera = new Camera2d(this, 0.0f);

            // allocate for corpses
            corpseIndex[0] = 0;
            corpseIndex[1] = 0;
            for (int i = 0; i < MAX_CORPSES; i++)
            {
                corpses[0, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/blue_corpse");
                corpses[1, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/yellow_corpse");
            }
        }
Пример #26
0
        public HandGun(PlatformerGame game, Vector2 position, Player player)
        {
            this.game = game;
            Position  = position;
            _player   = player;

            // Initialize bullets
            _bullets = new List <HandgunBullet>();
            for (int i = 0; i < MAX_HANDGUN_BULLETS; i++)
            {
                _bullets.Add(new HandgunBullet(game, position));
            }

            LoadContent();
        }
Пример #27
0
        public Shotgun(PlatformerGame level, Vector2 position, Player player)
        {
            this.game = level;
            Position  = position;
            _player   = player;

            // Initialize bullets
            _shells = new List <ShotgunShell>();
            for (int i = 0; i < MAX_SHELLS; i++)
            {
                _shells.Add(new ShotgunShell(level, position));
            }

            LoadContent();
        }
Пример #28
0
        public Shotgun(PlatformerGame level, Vector2 position, Player player)
        {
            this.game = level;
            Position = position;
            _player = player;

            // Initialize bullets
            _shells = new List<ShotgunShell>();
            for (int i = 0; i < MAX_SHELLS; i++)
            {
                _shells.Add(new ShotgunShell(level, position));
            }

            LoadContent();
        }
Пример #29
0
 static void Main(string[] args)
 {
     try
     {
         using (PlatformerGame game = new PlatformerGame())
         {
             game.Run();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         Console.ReadLine();
     }
 }
Пример #30
0
        public HandGun(PlatformerGame game, Vector2 position, Player player)
        {
            this.game = game;
            Position = position;
            _player = player;

            // Initialize bullets
            _bullets = new List<HandgunBullet>();
            for (int i = 0; i < MAX_HANDGUN_BULLETS; i++)
            {
                _bullets.Add(new HandgunBullet(game, position));
            }

            LoadContent();
        }
Пример #31
0
 static void Main(string[] args)
 {
     try
     {
         using (PlatformerGame game = new PlatformerGame())
         {
             game.Run();
         }
     }
     catch(Exception ex)
     {
         Console.WriteLine(ex.ToString());
         Console.ReadLine();
     }
 }
Пример #32
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                debugmode = true;
            }
            else if (!System.Diagnostics.Debugger.IsAttached)
            {
                debugmode = false;
            }

            using (PlatformerGame game = new PlatformerGame())
            {
                game.Run();
            }
        }
Пример #33
0
 public MainPage()
 {
     InitializeComponent();
     PlatformerGame game = new PlatformerGame();
     game.Attach(LayoutRoot);
 }
Пример #34
0
 /// <summary>
 /// Constructs a new ParticleSystem.
 /// </summary>
 /// <param name="game">The host for this particle system. The game keeps the
 /// content manager and sprite batch for us.</param>
 /// <param name="howManyEffects">the maximum number of particle effects that
 /// are expected on screen at once.</param>
 /// <remarks>it is tempting to set the value of howManyEffects very high.
 /// However, this value should be set to the minimum possible, because
 /// it has a large impact on the amount of memory required, and slows down the
 /// Update and Draw functions.</remarks>
 protected ParticleSystem(PlatformerGame game, int howManyEffects)
     : base(game.ScreenManager.Game)
 {
     this.game           = game;
     this.howManyEffects = howManyEffects;
 }
Пример #35
0
 public override void FinishedLaunching(MonoMac.Foundation.NSObject notification)
 {
     game = new PlatformerGame();
     game.Run();
 }
 public RetroBloodSprayWide(PlatformerGame game, int howManyEffects)
     : base(game, howManyEffects)
 {
 }
 public ExplosionParticleSystem(PlatformerGame game, int howManyEffects)
     : base(game, howManyEffects)
 {
 }
Пример #38
0
 /// <summary>
 /// Constructs a new ParticleSystem.
 /// </summary>
 /// <param name="game">The host for this particle system. The game keeps the 
 /// content manager and sprite batch for us.</param>
 /// <param name="howManyEffects">the maximum number of particle effects that
 /// are expected on screen at once.</param>
 /// <remarks>it is tempting to set the value of howManyEffects very high.
 /// However, this value should be set to the minimum possible, because
 /// it has a large impact on the amount of memory required, and slows down the
 /// Update and Draw functions.</remarks>
 protected ParticleSystem(PlatformerGame game, int howManyEffects)
     : base(game.ScreenManager.Game)
 {
     this.game = game;
     this.howManyEffects = howManyEffects;
 }
 public RetroBloodSprayParticleSystem(PlatformerGame game, int howManyEffects)
     : base(game,howManyEffects)
 {
 }
Пример #40
0
 public override void FinishedLaunching(MonoMac.Foundation.NSObject notification)
 {
     using (PlatformerGame game = new PlatformerGame()) {
         game.Run ();
     }
 }
 public SmokePlumeParticleSystem(PlatformerGame game, int howManyEffects)
     : base(game,howManyEffects)
 {
 }
Пример #42
0
        /// <summary>
        /// Constructs a new level.
        /// </summary>
        /// <param name="serviceProvider">
        /// The service provider that will be used to construct a ContentManager.
        /// </param>
        /// <param name="fileStream">
        /// A stream containing the tile data.
        /// </param>
        public Level(IServiceProvider serviceProvider, Stream fileStream, int levelIndex, string[] backgroundSet, PlatformerGame game)
        {
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            this.game = game;

            timeRemaining = TimeSpan.FromMinutes(2.0);
            exit[0] = InvalidPosition;
            exit[1] = InvalidPosition;

            LoadTiles(fileStream);

            // Load background layer textures. For now, all levels must
            // use the same backgrounds and only use the left-most part of them.
            layers = new Layer[3];
            float scrollRate = 0.2f;
            for (int i = 0; i < layers.Length; ++i)
            {
                layers[i] = new Layer(Content, backgroundSet[i], scrollRate);
                scrollRate += 0.3f;
            }
            /*
            for (int i = 0; i < layers.Length; ++i)
            {
                // Choose a random segment if each background layer for level variety.
                int segmentIndex = levelIndex;
                layers[i] = Content.Load<Texture2D>("Backgrounds/Layer" + i + "_" + segmentIndex);
            }
             * */

            // Load sounds.
            fallingSound = Content.Load<SoundEffect>("Sounds/fallSound");
            clearSound = Content.Load<SoundEffect>("Sounds/smb_stage_clear");
            bridgeSound = content.Load<SoundEffect>("Sounds/bridgeSound");

            camera = new Camera2d(this, 0.0f);

            // allocate for corpses
            corpseIndex[0] = 0;
            corpseIndex[1] = 0;
            for (int i = 0; i < MAX_CORPSES; i++)
            {
                corpses[0, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/blue_corpse");
                corpses[1, i] = new Corpse(this, Vector2.Zero, "Sprites/Player/yellow_corpse");
            }
        }
Пример #43
0
        /// <summary>
        /// Constructors a new player.
        /// </summary>
        public Player(PlatformerGame level, Vector2 position, int id)
        {
            this.level = level;
            this.playerId = id;

            LoadContent();

            respawnPosition = position;

            Reset(position);
        }
Пример #44
0
        public override void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (playDeathAnimation)
            {
                velocity.X  = 0.0f;
                velocity.Y += 0.4f;

                // Move in the current direction.
                // Apply velocity.
                position += velocity * elapsed;
                position  = new Vector2((float)Math.Round(position.X), (float)Math.Round(position.Y));
            }
            else if (IsAlive)
            {
                if (IsAlive && IsOnGround)
                {
                    if (Math.Abs(velocity.X) - 0.02f > 0)
                    {
                        sprite.PlayAnimation(runAnimation);
                    }
                    else
                    {
                        sprite.PlayAnimation(idleAnimation);
                    }
                }

                //random jumping
                waitTime += elapsed;
                if (waitTime >= MaxWaitTime)
                {
                    int rand = PlatformerGame.RandomBetween(1, 100);
                    if (rand < 75)
                    {
                        this.State = EntityState.RUNNING;
                    }
                    else
                    {
                        this.State = EntityState.JUMPING;
                    }
                    if (rand > 50)
                    {
                        FireAttack();
                        sprite.PlayAnimation(fireAnimation);
                    }
                    waitTime = 0.0f;
                }

                // pursue the attacker
                Player player    = PlatformerGame.Players[PlatformerGame.attacker_id];
                float  deltaDist = this.position.X - player.Position.X;

                if (deltaDist < 0)
                {
                    direction = FaceDirection.Right;
                }
                else
                {
                    direction = FaceDirection.Left;
                }

                // Maintain a min distance from player
                if (Math.Abs(deltaDist) > PlatformerGame.RandomBetween(MinDistFromPlayer, MaxDistFromPlayer))
                {
                    velocity.X += (int)direction * MoveSpeed * elapsed;
                }
                else
                {
                    velocity.X += -(int)direction * MoveSpeed * elapsed;
                }

                velocity.X = MathHelper.Clamp(velocity.X, -MaxMoveSpeed, MaxMoveSpeed);
                velocity.Y = MathHelper.Clamp(velocity.Y + GravityAcceleration * elapsed, -MaxFallSpeed, MaxFallSpeed);
                velocity.Y = DoJump(velocity.Y, gameTime);

                // Move in the current direction.
                // Apply velocity.
                position += velocity * elapsed;
                position  = new Vector2((float)Math.Round(position.X), (float)Math.Round(position.Y));

                //Update the fire attack
                foreach (BowserFire fire in _bullets)
                {
                    fire.Update(gameTime);
                }

                HandleCollisions();

                //Sprite effects
                if (pulseRed)
                {
                    pulseRedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
                    if (pulseRedTime > MAX_PULSE_TIME)
                    {
                        pulseRed     = false;
                        pulseRedTime = 0.0f;
                    }
                }
            }
        }