Exemplo n.º 1
0
 public MapBuilder(Game1 useForLoadingContent, int screenWidth, int screenHeight, GraphicsDeviceManager graphics, int tileSize, Player thisPlayer, SpriteBatch spriteBatch, Dictionary<long, Player> players)
 {
     this.useForLoadingContent = useForLoadingContent;
     this.screenWidth = screenWidth;
     this.screenHeight = screenHeight;
     this.graphics = graphics;
     this.tileSize = tileSize;
     this.thisPlayer = thisPlayer;
     this.spriteBatch = spriteBatch;
     this.players = players;
 }
Exemplo n.º 2
0
 public Npc(AnimatedTexture animatedTexture, AnimatedTexture deathTexture, Dictionary<long, Player> players, Player thisPlayer, 
     Vector2 position, int life, int damage, int bounty)
 {
     this.animatedTexture = animatedTexture;
     this.deathTexture = deathTexture;
     this.players = players;
     this.thisPlayer = thisPlayer;
     this.Position = position;
     this.Life = life;
     this.damage = damage;
     this.Bounty = bounty;
 }
Exemplo n.º 3
0
        public StartScreen(SpriteBatch spriteBatch, PlayerCard humanCard, PlayerCard alienCard, Player thisPlayer, 
            MapBuilder mapBuilder, Texture2D checkedTexture, Texture2D unCheckedTexture, SpriteFont font)
        {
            this.spriteBatch = spriteBatch;
            this.humanCard = humanCard;
            this.alienCard = alienCard;
            this.thisPlayer = thisPlayer;
            this.mapBuilder = mapBuilder;
            this.checkedTexture = checkedTexture;
            this.unCheckedTexture = unCheckedTexture;

            //clientCheckBox = new CheckBox(unCheckedTexture, checkedTexture, "Client", new Rectangle(20, 300, 50, 50), spriteBatch, font);
            //clientCheckBox.IsChecked = true;
            serverCheckBox = new CheckBox(unCheckedTexture, checkedTexture, "Server", new Rectangle(20, 360, 50, 50), spriteBatch, font);
        }
Exemplo n.º 4
0
        protected override void LoadContent()
        {
            BGM = Content.Load<Song>("Super Mario World Overworld");
            MediaPlayer.Play(BGM);
            MediaPlayer.IsRepeating = true;
            tornadoSE = Content.Load<SoundEffect>("TornadoSE");
            gunShotSE = Content.Load<SoundEffect>("GunShotSE");
            pumpkinCollideSE = Content.Load<SoundEffect>("pumpkinCollideSE");
            chickenCollideSE = Content.Load<SoundEffect>("chickenCollideSE");
            popSE = Content.Load<SoundEffect>("popSE");
            HomerSE = Content.Load<SoundEffect>("HomerSE");
            PeterSE = Content.Load<SoundEffect>("PeterSE");
            bossDieExplosionSE = Content.Load<SoundEffect>("bossDieExplosion");

            spriteBatch = new SpriteBatch(GraphicsDevice);

            whiteTexture2D = Content.Load<Texture2D>("whitePic");   //used to draw collision rectangle
            greenTexture2D = Content.Load<Texture2D>("greenPic");   //used to draw collision rectangle

            winMessage1 = Content.Load<Texture2D>("WinMessage1");
            winMessage2 = Content.Load<Texture2D>("WinMessage2");
            winMessage3 = Content.Load<Texture2D>("WinMessage3");
            loseMessage = Content.Load<Texture2D>("LoseMessage");

            #region Menu && Screens
            Gamestate = GameState.MAIN;

            Main = new GameObject(Content.Load<Texture2D>("MainMenu"), graphics);
            Main.Scale = 1.0f;
            Main.position = new Vector2(640, 360);
            Main.visible = false;

            Control = new GameObject(Content.Load<Texture2D>("Controls"), graphics);
            Control.Scale = 1.0f;
            Control.position = new Vector2(640, 360);
            Control.visible = false;

            End = new GameObject(Content.Load<Texture2D>("End Screen"), graphics);
            End.Scale = 1.0f;
            End.position = new Vector2(640, 360);
            End.visible = false;

            Upgrade = new GameObject(Content.Load<Texture2D>("UpgradeScreen"), graphics);
            Upgrade.Scale = 0.75f;
            Upgrade.position = new Vector2(640, 350);
            Upgrade.visible = false;
            #endregion
            #region Scrolling
            scrolling1 = new Scrolling(Content.Load<Texture2D>("Springfield1"), new Rectangle(0, 0, 1000, 720));
            scrolling2 = new Scrolling(Content.Load<Texture2D>("Springfield2"), new Rectangle(1000, 0, 1000, 720));
            scrolling3 = new Scrolling(Content.Load<Texture2D>("Springfield3"), new Rectangle(2000, 0, 1000, 720));
            #endregion
            #region Players
            Homer1 = new Player(Content.Load<Texture2D>("Homer"), Content.Load<Texture2D>("Bullet"), Content.Load<SpriteFont>("SpriteFont1"), graphics);
            Homer1.bulletScale = 0.75f;
            Peter1 = new Player2(Content.Load<Texture2D>("PeterSpriteSheetFull"), Content.Load<Texture2D>("Bullet"), Content.Load<SpriteFont>("SpriteFont1"), graphics);
            Peter1.bulletScale = 0.75f;
            #endregion
            #region Enemies
            totalNumOfPumpkins = 10;
            pumpkin = new GameObject[totalNumOfPumpkins];
            for (int i = 0; i < totalNumOfPumpkins; i++)
            {
                pumpkin[i] = new GameObject(Content.Load<Texture2D>("Pumpkin"), graphics);
                pumpkin[i].Scale = 0.35f;
                pumpkin[i].position = new Vector2(nextValue = r.Next(800, 2950), nextValue = r.Next(425, 700));
                pumpkin[i].visible = true;
                pumpkin[i].speed = 2f;
            }

            totalNumOfWhiteChickens = 10;
            whiteChicken = new WhiteChicken[totalNumOfWhiteChickens];
            for (int i = 0; i < totalNumOfWhiteChickens; i++)
            {
                whiteChicken[i] = new WhiteChicken(Content.Load<Texture2D>("WhiteChicken"), Content.Load<Texture2D>("HealthBar2"), graphics);
                whiteChicken[i].Scale = 1f;
                whiteChicken[i].position.X = (r.Next(800, 2950));
                whiteChicken[i].position.Y = (r.Next(275, 550));
                whiteChicken[i].spriteVisible = true;
                //whiteChicken[i].speed = 2f;   //by default speed is 2f in WhiteChicken.cs
            }

            ExplodeSprite = new GameObject(Content.Load<Texture2D>("Explode"), graphics);
            ExplodeSprite.visible = false;
            ExplodeSprite.Scale = 0.75f;
            ExplodeSprite.position = new Vector2();

            totalNumOfEggCrackStages = 3;
            BossEgg = new GameObject[totalNumOfEggCrackStages];
            for (int i = 0; i < totalNumOfEggCrackStages; i++)
            {
                BossEgg[i] = new GameObject(Content.Load<Texture2D>("Egg" + i), graphics);
                BossEgg[i].Scale = 1.5f;
                BossEgg[i].position = new Vector2(2850, 550);
                BossEgg[i].visible = false;
                BossEgg[i].speed = 2f;
            }
            EggCrackStage = 0; //will start at stage 0 and cause BossEgg[0].visible = true;

            loopInt = 0;
            Boss = new GiantChicken(Content.Load<Texture2D>("GiantChicken"), Content.Load<Texture2D>("Tornado"), Content.Load<Texture2D>("HealthBar2"), graphics);
            Boss.position.X = 2850;
            Boss.position.Y = 400;
            Boss.spriteVisible = false;

            #endregion
        }
Exemplo n.º 5
0
        public void GetFire(Dictionary<Int64, Player> players, List<Weapon> weaponDefinitions, Player thisPlayer, PlayerBase bloodNpc, AnimatedTexture bloodTexture, List<Bomb> bombs)
        {
            long who = msg.ReadInt64();
            Int64 playerId = msg.ReadInt64();
            byte weaponId = msg.ReadByte();
            byte angle = msg.ReadByte();
            int x = msg.ReadInt32();
            int y = msg.ReadInt32();
            Weapon weaponDefinition = weaponDefinitions[weaponId];
            Weapon weapon = players[who].primaryWeapons.SingleOrDefault(w => w.Name == weaponDefinition.Name) ?? players[who].secondaryWeapons.SingleOrDefault(w => w.Name == weaponDefinition.Name);

            if (weapon == null)
            {
                weapon = weaponDefinition.Clone();
                players[who].AddWeapon(weapon);
            }
            players[who].SelectWeapon(weapon);

            if (weapon.IsPrimary)
            {
                if (players[who].SelectedPrimaryWeapon.UserTexture.IsDone)
                    players[who].SelectedPrimaryWeapon.UserTexture.Start();

                if (players[who].SelectedPrimaryWeapon.EffectTexture.IsDone)
                    players[who].SelectedPrimaryWeapon.EffectTexture.Start();

                thisPlayer.TakeDamage(players[who].SelectedPrimaryWeapon.Damage,
                    new Vector2((float)-Math.Sin(((double)angle) / 40), (float)Math.Cos(((double)angle) / 40)),
                    players[who].SelectedPrimaryWeapon.Push);

                thisPlayer.Life -= weapon.Damage;
                thisPlayer.Position = thisPlayer.Position - new Vector2((float)-Math.Sin(((double)angle) / 40), (float)Math.Cos(((double)angle) / 40)) * 50;
                bloodNpc = thisPlayer;
                bloodTexture.Start();
            }
            else
            {
                Vector2 vel = new Vector2(x, y) - thisPlayer.ScreenCenter;
                vel.Normalize();

                vel *= 10;
                if (weapon.Name == "grenade")
                {
                    bombs.Add(new Bomb(players[who].SelectedSecondaryWeapon.UserTexture, players[who].SelectedSecondaryWeapon.EffectTexture,
                                        30, 35, 10, new Vector2(players[who].Position.X + thisPlayer.ScreenCenter.X, players[who].Position.Y + thisPlayer.ScreenCenter.Y),
                                        vel, 500, 500, 100, true, new Vector2(x, y) + players[who].Position));
                }
                else
                {
                    if (players[who].SelectedSecondaryWeapon.Bomb == null)
                    {
                        Bomb bomb = new Bomb(players[who].SelectedSecondaryWeapon.UserTexture, players[who].SelectedSecondaryWeapon.EffectTexture,
                            30, 35, 10, new Vector2(players[who].Position.X + thisPlayer.ScreenCenter.X, players[who].Position.Y + thisPlayer.ScreenCenter.Y),
                            Vector2.Zero, 50, 500, 500, false, Vector2.Zero);
                        players[who].SelectedSecondaryWeapon.Bomb = bomb;
                        bombs.Add(bomb);
                    }
                    else
                    {
                        players[who].SelectedSecondaryWeapon.Bomb.Explode();
                        players[who].SelectedSecondaryWeapon.Bomb = null;
                    }

                }
            }
        }
Exemplo n.º 6
0
 public void SendShoting(Player thisPlayer, Int64 shotPlayerId, List<Weapon> weaponDefinitions, Weapon weapon, int x, int y)
 {
     NetOutgoingMessage om = client.CreateMessage();
     om.Write((byte)MessageRouts.Fire);
     om.Write((Int64)shotPlayerId);
     om.Write((byte)weaponDefinitions.IndexOf(weaponDefinitions.SingleOrDefault(w => w.Name == weapon.Name)));
     om.Write((byte)((-Math.Atan2(thisPlayer.Direction.X, thisPlayer.Direction.Y) * 40)));
     om.Write((int)x);
     om.Write((int)y);
     client.SendMessage(om, NetDeliveryMethod.Unreliable);
 }
Exemplo n.º 7
0
 public void SendPosition(Player player)
 {
     NetOutgoingMessage om = client.CreateMessage();
     om.Write((byte)0);
     om.Write((int)player.Position.X);
     om.Write((int)player.Position.Y);
     om.Write((int)(-Math.Atan2(player.Direction.X, player.Direction.Y) * 1000));
     om.Write(!player.SelectedPrimaryWeapon.UserTexture.IsDone);
     om.Write(player.IsHuman);
     client.SendMessage(om, NetDeliveryMethod.Unreliable);
 }
Exemplo n.º 8
0
        public void GetPosition(Dictionary<Int64, Player> players, List<Weapon> weaponDefinitions, Game1 forLoadingContent, SpriteBatch spriteBatch)
        {
            long who = msg.ReadInt64();
            int x = msg.ReadInt32();
            int y = msg.ReadInt32();
            int angle = msg.ReadInt32();
            bool isShooting = msg.ReadBoolean();
            bool isHuman = msg.ReadBoolean();
            if (players.ContainsKey(who))
            {
                players[who].Position = new Vector2(x, y);
                players[who].Direction = new Vector2(-(float)Math.Sin(((float)angle) / 1000), (float)Math.Cos(((float)angle) / 1000));
            }
            else
            {
                players[who] = new Player { PlayerType = isHuman ? Player.PlayerTypes.human : Player.PlayerTypes.alien,
                                            AnimatedTexture = new AnimatedTexture(isHuman ? forLoadingContent.Content.Load<Texture2D>("PlayerSprites/dudespritesheet") : forLoadingContent.Content.Load<Texture2D>("PlayerSprites/alienspritesheet"), 4, 4, true, 20, spriteBatch, 50, 50, new Vector2(25, 25), null),
                                            Id = who
                };
                Weapon weaponDefinition = weaponDefinitions.SingleOrDefault(w => w.Name == "gun");

                players[who].AddWeapon(weaponDefinition.Clone());
            }
        }