Beispiel #1
0
        public Bullet(int who, Vector2 pos, float rot, float dmg, DamageType type)
            : base(null, pos, false)
        {
            isSent = false;
            switch (type)
            {
            case DamageType.Normal:
                Textures.Add(Loader.LoadGameTexture("WorldObjects/Bullets/NormalBullet"));
                Damage = new Other.Damage(dmg);
                Clr    = Color.White;
                break;

            case DamageType.Poison:
                Textures.Add(Loader.LoadGameTexture("WorldObjects/Bullets/PoisonBullet"));
                Damage = new Other.Damage(dmg, 4, 1, type);
                Clr    = Color.Green;
                break;

            case DamageType.Water:
                Textures.Add(Loader.LoadGameTexture("WorldObjects/Bullets/WaterBullet"));
                Damage = new Other.Damage(dmg, 2, 5, type);
                Clr    = Color.Blue;
                break;
            }
            this.who  = who;
            _size     = new Point(Textures[0].Width, Textures[0].Height / 3);
            Direction = Config.AngleToVector(rot);
            Rotation  = rot;
            Position  = pos;
        }
Beispiel #2
0
 /// <summary>
 /// update player
 /// </summary>
 /// <param name="direction">directional vector</param>
 public void Update(Vector2 direction, Vector2 mousePos, int left, GameTime gameTime)
 {
     if (Dead)
     {
         SemiDead = false;
     }
     if (!SemiDead)
     {
         if (direction.Length() > 0)
         {
             MyBody.ApplyLinearImpulse(direction * 3000);
         }
         else
         {
             MyBody.LinearVelocity = Vector2.Zero;
         }
         Rotation = Config.VectorToAngle(mousePos);
         if (Dead && _hasBody)
         {
             MyBody.CollidesWith = Category.Cat3;
         }
         if (!Dead && left % BulletDelay == 1 && left > 0)
         {
             if (AmmoCount > 0)
             {
                 BulletEvent.Invoke(new Bullet(id, Position + (Config.AngleToVector(Rotation)), Rotation, Damage, Ammo.DType));                         //TODO: speed dependent
                 AmmoCount--;
             }
         }
     }
     else
     {
         MyBody.LinearVelocity = Vector2.Zero;
     }
     UpdateLifeStatus(gameTime);
     UpdateFrame(gameTime, direction);
 }