Beispiel #1
0
 public Melee(Unit owner, World world)
     : base(owner, world)
 {
     Body.Position = owner.Position + new Vector2(-owner.Facing * 2.7f, -0.8f);
     _startingPosition = Body.Position;
     Body.ApplyLinearImpulse(new Vector2(-owner.Facing * Speed, 0));
 }
Beispiel #2
0
 public RainMissiles(Unit owner, World world)
     : base(owner, world)
 {
     X = owner.Position.X;
     Body.Position = owner.Position;
     Body.ApplyLinearImpulse(new Vector2(Game1.Random.Next(-30, 30), Game1.Random.Next(-30, -25)));
     Body.IgnoreGravity = false;
 }
Beispiel #3
0
 public DravensAxes(Unit owner, World world)
     : base(owner, world)
 {
     Body.Position = owner.Position + new Vector2(-owner.Facing*2.7f, -0.8f);
     _startingPosition = Body.Position;
     Body.ApplyLinearImpulse(new Vector2(-owner.Facing*Speed, 0));
     Body.ApplyTorque(-11000f);
 }
Beispiel #4
0
        public static void Draw(SpriteBatch spriteBatch, Unit unit)
        {
            const int maxHP = 1000;
            var currentHP = unit.Attribute[UnitAttribute.Health];
            var texture = GameplayScreen.Pixel;

            var hundredBlocks = (int)currentHP / BlockSize;
            var remainder = currentHP % BlockSize;;

            for (var i = 0; i < hundredBlocks; i++) {
                spriteBatch.Draw(texture, new Rectangle((i * 21), Height, 20, 20), Color.Green);
            }

            spriteBatch.Draw(texture,
                             new Rectangle((hundredBlocks * 21), Height, (int)((remainder / 100f) * 20f), 20), Color.DarkGreen);
            spriteBatch.DrawString(GameplayScreen.Font, String.Format("{0}/{1}", currentHP, maxHP),
                                   new Vector2(10, Height - 5), Color.White);
        }
Beispiel #5
0
        protected Projectile(Unit owner, World world)
            : base(world)
        {
            Owner = owner;
            FacingRight = Owner.Facing == 1;
            Body.IgnoreGravity = true;
            Body.OnCollision += OnCollision;

            if (owner.Team == GameTeam.Player) {
                // Cat 2 = Enemies
                Body.CollidesWith = Category.Cat1 | Category.Cat4;
                Body.CollisionCategories = Category.Cat3;
            }
            else {
                // Cat 3 = Player
                Body.CollidesWith = Category.Cat1 | Category.Cat2;
                Body.CollisionCategories = Category.Cat5;
            }
        }
Beispiel #6
0
        public void Apply(Unit unit)
        {
            if (Expired)
                return;

            switch (OpType) {
                case OperationType.Multiply:
                    unit.Attribute[Attribute] *= Amount;
                    break;
                case OperationType.Add:
                    if (Amount < 0 && Attribute == UnitAttribute.Health) {
                        unit.Hurt(Amount * -1);
                    }
                    else {
                        unit.Attribute[Attribute] += Amount;
                    }

                    break;
                case OperationType.Set:
                    unit.Attribute[Attribute] = Amount;
                    break;
            }
        }
Beispiel #7
0
 public void Expire(Unit unit)
 {
     unit.RecalculateAttribute(Attribute);
 }
Beispiel #8
0
 public void Draw(Unit unit, SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(Texture, unit.DisplayPosition, Color.White);
     spriteBatch.DrawString(GameplayScreen.Font, Duration.ToString(), unit.DisplayPosition - new Vector2(0, 100), Color.Green);
 }
Beispiel #9
0
 public void Update(Unit unit, GameTime gameTime)
 {
     Duration -= gameTime.ElapsedGameTime.Milliseconds;
     TimeSinceLastTick += gameTime.ElapsedGameTime.Milliseconds;
     if (Repeating) {
         if (TimeSinceLastTick >= 1000f) {
             Apply(unit);
             TimeSinceLastTick = 0;
         }
     }
 }