Inheritance: IWorldItem
Exemple #1
0
 private void gPnlField_MouseClick(object sender, MouseEventArgs e)
 {
     bullet = new Bullet();
     bullet.X = e.X;
     bullet.Y = e.Y;
     bullet.Speed = 5;
 }
Exemple #2
0
 public override void Damaged(float damage, Bullet bullet, bool critical = false)
 {
     if (!damaged) MakeHPBar(new Vector3(0, 2, 0));
     damaged = true;
     this.HP -= damage;
     HPText.text = (int)this.HP + " / " + this.MaxHP;
     HPSlider.value = this.HP;
     if (this.HP <= 0) Die();
 }
Exemple #3
0
 public void UpdateBullet(Bullet bullet)
 {
     NetworkHelper.SetServerId(bullet, ServerId);
     bullet.SetTransform(Transform);
     bullet.WorldTransform = Transform;
     bullet.SetVelocity(Velocity);
     bullet.WorldVelocity = Velocity;
     bullet.Children[0].WorldTransform = Transform;
     bullet.Children[0].WorldVelocity = Velocity;
 }
Exemple #4
0
        public MissleDrop(TankGame game, Vector2 bulletPosition)
            : base(game)
        {
            Bullet basic = new Bullet(game); 

            this.position = bulletPosition;
            this.type = BulletType.MissileDrop;

            damage = 20;
            mass = 1.0f;

            angle = 0;
            speed = Vector2.Zero;
        }
Exemple #5
0
        public ScatterShot(TankGame game, Vector2 bulletPosition)
            : base(game)
        {
            Bullet basic = new Bullet(game);

            this.position = bulletPosition;
            this.type = BulletType.ScatterShot;

            angle = 0;

            scatterAngle = 0;

            damage = 20;
            mass = .75f;

            bulletDirection = new Vector2(1, 0);

            speed = Vector2.Zero;

            scatterShots = new List<Shots>();
        }
Exemple #6
0
 public BulletData(Bullet bullet)
 {
     Transform = bullet.GetTransform();
     Velocity = bullet.GetVelocity();
     ServerId = (int)bullet.ServerId;
 }
Exemple #7
0
        public void Fire()
        {
            Random rand = new Random();
            for (int i = 0; i < 20; i++)
            {
                float velocityX = -1 * (float)Math.Sin((double)ship.Rotation) * 6 + (float)(rand.NextDouble() / 0.99 - 1);
                float velocityY = (float)Math.Cos((double)ship.Rotation) * 6 + (float)(rand.NextDouble() / 0.99 + 1);
                Vector2 velocity = new Vector2(velocityX, velocityY);
                velocity += ship.velocity;

                Bullet bullet = new Bullet(bulletTexture, ship.Position, velocity, 2000);
                bullets.Add(bullet);
            }
        }
Exemple #8
0
        private void showExplosion(Vector2 vector2)
        {
            this.effect.Play();

            for (int i = 0; i < 30; i++)
            {
                float velocityX = (float)(rand.NextDouble() - 0.5) * 4;
                float velocityY = (float)(rand.NextDouble() - 0.5) * 4;
                Vector2 velocity = new Vector2(velocityX, velocityY);
                int rndColor = rand.Next(2);
                Color color = Color.Red;
                if (rndColor == 1)
                {
                    color = Color.Orange;
                }

                Bullet bullet = new Bullet(bulletTexture, vector2, velocity, 500, color);
                bullets.Add(bullet);

                explosions.Add(new Explosion(explosionTexture, vector2));
            }
        }
Exemple #9
0
        public void shoot(float power)
        {
            if (type != BulletType.BasicBullet)
            {
                if (inventory.getShotCount(type) <= 0)
                    type = inventory.findNextShotType();

                switch (type)
                {
                    case BulletType.HeavyShot:
                        bullet = new HeavyShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                        break;

                    case BulletType.ScatterShot:
                        bullet = new ScatterShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                        break;

                    case BulletType.TeleportShot:
                        bullet = new TeleportShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                        break;

                    case BulletType.MissileDrop:
                        bullet = new MissileDrop(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                        break;
                }
                
                inventory.decrementShot(type);
            }
            else
            {
                bullet = new Bullet(game, new Vector2(turretPosition.X + turretPic.Width/2 , turretPosition.Y - turretPic.Height/8 ));
            }

            bullet.speed = turretDirection * new Vector2(power, -power);
            ((TankGame)Game).soundManager.shoot.Play();
            Game.Components.Add(bullet);
            recoil = true;
            shotPosition = tankPosition.X;

            shotPuff = new Puff(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8), turretDirection, power);
            shotPuff.AutoInitialize(game.GraphicsDevice, game.Content, TankGame.spriteBatch);

            shotPuff.UpdateOrder = 100;
            shotPuff.DrawOrder = 100;
            shotPuff.Visible = true;
        }
Exemple #10
0
        public Tank(TankGame game, Vector2 tankPosition, float turretAngle)
            : base(game)
        { 
            this.game = game;
            this.tankPosition = tankPosition;
            turretPosition = new Vector2(tankPosition.X + 40, tankPosition.Y + 25);
            this.turretAngle = turretAngle;
            health = 200;
            turnTime = 0;
            moveLimit = 0;
            originalTurretDirection = new Vector2(0, 1);
            turretDirection = new Vector2((float)(Math.Cos(-turretAngle) * originalTurretDirection.X - Math.Sin(-turretAngle) * originalTurretDirection.Y),
                (float)(Math.Sin(-turretAngle) * originalTurretDirection.X + Math.Cos(-turretAngle) * originalTurretDirection.Y));
            bullet = new Bullet(game);
            type = BulletType.BasicBullet;
            inventory = new Inventory(game);
            damageClouds = null;
            timer = 0.0f;

            currentTankState = TankState.Normal;
        }
Exemple #11
0
        /// <summary>
        /// プレイヤーがダメージくらう関数
        /// </summary>
        /// <param name="damage">ダメージの値</param>
        /// <param name="critical">急所に当たった!</param>
        public override void Damaged(float damage, Bullet bullet, bool critical = false)
        {
            if(bullet != null)
            {

            }
            HP -= critical ? damage * 2 : damage;
            if (HP <= 0) Die();
        }
Exemple #12
0
 /// <summary>
 /// ダメージを食らう
 /// </summary>
 /// <param name="damage">ダメージ量</param>
 public abstract void Damaged(float damage, Bullet bullet, bool critical = false);
Exemple #13
0
        private void HandleData(INetIncomingMessage msg)
        {
            ServerMessage data = NetworkHelper.ReadMessage<ServerMessage>(msg);
            bool outOfDate = data.LocalSendTime <= _lastTimestamp;
            if (!outOfDate)
            {
                _lastTimestamp = data.LocalSendTime;
            }

            foreach (WallAdded added in data.WallsAdded)
            {
                added.WallCreate(Scene);
            }

            if (!outOfDate)
            {
                Scene.Time = data.SceneTime;

                foreach (TankData tankData in data.TankData)
                {
                    Tank tank;
                    Tanks.TryGetValue(tankData.OwnerId, out tank);

                    if (tank == null)
                    {
                        tank = tank ?? new Tank(Scene);
                        Tanks.Add(tankData.OwnerId, tank);

                        if (tankData.OwnerId == ServerId)
                        {
                            _tankCamera.SetTank(tank);
                        }
                    }

                    tankData.UpdateTank(tank);

                    _sceneUpdated = true;
                }

                foreach (BulletData bulletData in data.BulletData)
                {
                    Bullet bullet = (Bullet)Scene.GetAll().OfType<INetObject>().FirstOrDefault(item => item.ServerId == bulletData.ServerId);
                    if (bullet == null)
                    {
                        bullet = new Bullet(Scene, new Vector2(), new Vector2());
                    }
                    bulletData.UpdateBullet(bullet);
                }
            }

            PortalCommon.UpdateWorldTransform(Scene, true);
        }
Exemple #14
0
 public void Push(Bullet bullet)
 {
     Bullets.Add(bullet);
 }