Пример #1
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;
 }
Пример #2
0
 public Bomb(AnimatedTexture staticTexture, AnimatedTexture explosionTexture, int width, int height, int damage, Vector2 position, 
     Vector2 velocity, int areaOfEffect, int counter, int explotionDuration, bool isTimeBomb, Vector2 explodePos)
 {
     this.staticTexture = staticTexture;
     this.explosionTexture = explosionTexture;
     this.width = width;
     this.height = height;
     this.damage = damage;
     this.Position = position;
     this.Velocity = velocity;
     this.areaOfEffect = areaOfEffect;
     this.counter = counter;
     this.explotionDuration = explotionDuration;
     this.isTimeBomb = isTimeBomb;
     this.explodePos = explodePos;
 }
Пример #3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            screenWidth = graphics.GraphicsDevice.PresentationParameters.BackBufferWidth;
            screenHeight = graphics.GraphicsDevice.PresentationParameters.BackBufferHeight;

            thisPlayer.ScreenCenter = new Vector2(screenWidth / 2, screenHeight / 2);
            thisPlayer.Position = new Vector2(1000, 700);
            thisPlayer.Life = 2000;
            thisPlayer.IsThisPlayer = true;

            mapBuilder = new MapBuilder(this, screenWidth, screenHeight, graphics, tileSize, thisPlayer, spriteBatch, players);

            shadowmapResolver = new ShadowmapResolver(GraphicsDevice, quadRender, ShadowmapSize.Size256, ShadowmapSize.Size1024);
            shadowmapResolver.LoadContent(Content);
            lightArea1 = new LightArea(GraphicsDevice, ShadowmapSize.Size1024);
            lightArea2 = new LightArea(GraphicsDevice, ShadowmapSize.Size512);

            lightPosition = thisPlayer.ScreenCenter;
            lightPosition2 = new Vector2(screenWidth / 2 - 80, screenHeight / 2);
            screenShadows = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            crossTexture = Content.Load<Texture2D>("cross");
            font = Content.Load<SpriteFont>("myFont");

            whiteBackground = Content.Load<Texture2D>("Cards/whitebackground");

            startScreen = new StartScreen(spriteBatch, new PlayerCard { Texture = Content.Load<Texture2D>("Cards/human"), BoundingBox = new Rectangle(20, 20, 200, 200), AnimatedTexture = new AnimatedTexture(Content.Load<Texture2D>("PlayerSprites/dudespritesheet"), 4, 4, true, 20, spriteBatch, 50, 50, new Vector2(25, 25), null) },
                new PlayerCard { Texture = Content.Load<Texture2D>("Cards/alien"), BoundingBox = new Rectangle(300, 20, 200, 200), AnimatedTexture = new AnimatedTexture(Content.Load<Texture2D>("PlayerSprites/alienspritesheet"), 4, 4, true, 20, spriteBatch, 70, 70, new Vector2(25, 25), null) },
                thisPlayer, mapBuilder, Content.Load<Texture2D>("Cards/checked"), Content.Load<Texture2D>("Cards/unchecked"), font);

            LoadWeaponDefinitions();

            artificialWallTexture = new AnimatedTexture(Content.Load<Texture2D>("MapItems/artificialwall"), 8, 1, false, 1, spriteBatch, 40, 40, new Vector2(20, 20), null);

            bloodTexture = new AnimatedTexture(Content.Load<Texture2D>("WeaponSprites/blood"), 13, 1, false, 26, spriteBatch, 50, 50, new Vector2(25, 25), null);
        }
Пример #4
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;
                    }

                }
            }
        }