Example #1
0
        public override bool MoveShot(VelocityObject shot)
        {
            shot.Velocity.Y += gravity;
            bool    shouldRemove = false;
            bool    placeDirt    = false;
            Vector2 oldCenter    = shot.Center;

            shot.Box.Move(shot.Position.X + shot.Velocity.X, shot.Position.Y + shot.Velocity.Y, (col) => {
                if (col.Other.HasTags(Collider.Tile))
                {
                    shouldRemove = true;
                    placeDirt    = true;
                    return(new Humper.Responses.TouchResponse(col));
                }
                if (col.Other.HasTags(Collider.Player))
                {
                    if (Holder.ID != (int)col.Other.Data)
                    {
                        world.Players[(int)col.Other.Data].Damage(damageAmount, DamageReason.Enemy, "a gun shot you", Holder.ID);
                        shouldRemove = true;
                    }
                }
                return(new Humper.Responses.IgnoreResponse(col));
            });
            if (shouldRemove && placeDirt)
            {
                world.AddTile((int)(shot.Center.X / 16), (int)(shot.Center.Y / 16), Tile.Dirt);
            }
            return(shouldRemove);
        }
Example #2
0
    public void AddToRenderList(VelocityObject obj)
    {
        if (_renderObjects == null)
            _renderObjects = new List<VelocityObject>();

        _renderObjects.Add(obj);
    }
Example #3
0
 public void RemoveFromRenderList(VelocityObject obj)
 {
     if (_renderObjects != null)
     {
         if (_renderObjects.Contains(obj))
             _renderObjects.Remove(obj);
     }
 }
Example #4
0
    public void AddToRenderList(VelocityObject obj)
    {
        if (_renderObjects == null)
        {
            _renderObjects = new List <VelocityObject>();
        }

        _renderObjects.Add(obj);
    }
Example #5
0
 public void RemoveFromRenderList(VelocityObject obj)
 {
     if (_renderObjects != null)
     {
         if (_renderObjects.Contains(obj))
         {
             _renderObjects.Remove(obj);
         }
     }
 }
Example #6
0
        // returns if shot should be removed
        public virtual bool MoveShot(VelocityObject shot)
        {
            bool shouldRemove = false;

            shot.Box.Move(shot.Position.X + shot.Velocity.X, shot.Position.Y + shot.Velocity.Y, (col) => {
                if (col.Other.HasTags(Collider.Tile))
                {
                    shouldRemove = true;
                }
                if (col.Other.HasTags(Collider.Player))
                {
                    if (Holder.ID != (int)col.Other.Data)
                    {
                        world.Players[(int)col.Other.Data].Damage(damageAmount, DamageReason.Enemy, "a gun shot you", Holder.ID);
                        shouldRemove = true;
                    }
                }
                return(new Humper.Responses.IgnoreResponse(col));
            });
            return(shouldRemove);
        }
Example #7
0
 public void Update(GameTime gameTime)
 {
     foreach (var shotK in shots.ToArray())
     {
         VelocityObject shot = shotK.Item2;
         if (MoveShot(shot))
         {
             world.CollisionWorld.Remove(shot.Box);
             shots.Remove(shotK);
         }
     }
     while (shots.Count > 0)
     {
         if (gameTime.TotalGameTime.TotalMilliseconds - shots[0].Item1 > 5000)
         {
             world.CollisionWorld.Remove(shots[0].Item2.Box);
             shots.RemoveAt(0);
         }
         else
         {
             break;
         }
     }
 }