Example #1
0
        public new static DropItem fromXML(XmlElement element)
        {
            DropItem item = new DropItem();

            item.copyValues((XmlElement)element.GetElementsByTagName("gameItem")[0]);
            item.setItem(Item.fromXML((XmlElement)element.GetElementsByTagName("item")[0]));
            return(item);
        }
Example #2
0
        public void dropItem(Vector2 dropPosition, Being killedBeing)
        {
            DropItem item = new DropItem();

            item.body                 = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, item.radius, item.radius, item.weight);
            item.body.Position        = new Vector2(dropPosition.X, dropPosition.Y + 25);
            item.body.Rotation        = 100f * (float)(rand.NextDouble() - .5f);
            item.body.AngularVelocity = (float)(rand.NextDouble() - .5f);
            item.body.LinearVelocity  = 50f * new Vector2((float)rand.NextDouble() - .5f, 1);
            #region geometry setup
            item.geom = new Geom();
            item.geom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, item.body, item.radius, item.radius);
            item.geom.FrictionCoefficient = .6f;
            item.geom.CollisionCategories = item.geom.CollidesWith = killedBeing.geom.CollisionCategories;
            #endregion
            item.setItem(DropManager.generateItem(killedBeing));
            item.startdepth = (uint)PhysicsHelper.collisionCategoryToDepth(item.geom.CollisionCategories);
            activeItems.Add(item.guid, item);
            network.sendFullObjectsUpdate();
        }