Esempio n. 1
0
 public void ItemschedulePop(coItem item)
 {
     // This method deletes the object after a default duration. Dynamic
     // items such as thrown or drop weapons are usually popped to avoid
     // world clutter.
     item.schedule((ItemPopTime - 1000).AsString(), "startFade", "1000", "0", "true");
     item.schedule(ItemPopTime.AsString(), "delete");
 }
Esempio n. 2
0
        public void ItemRespawn(coItem item)
        {
            // This method is used to respawn static ammo and weapon items
            // and is usually called when the item is picked up.
            // Instant fade...
            item.startFade(0, 0, true);
            item.setHidden(true);

            item.schedule(ItemRespawnTime.AsString(), "setHidden", "false");
            item.schedule((ItemRespawnTime + 100).AsString(), "startFade", "1000", "0", "false");
        }
Esempio n. 3
0
        public void ShapeBaseShapeBaseThrowObject(coShapeBase thisobj, coItem obj)
        {
            // Throw the given object in the direction the shape is looking.
            // The force value is hardcoded according to the current default
            // object mass and mission gravity (20m/s^2).

            float throwforce = (( coSimDataBlock)thisobj.getDataBlock())["throwForce"].AsFloat();

            if (throwforce == 0)
            {
                throwforce = 20;
            }

            // Start with the shape's eye vector...

            Point3F eye = thisobj.getEyeVector();
            Point3F vec = eye.vectorScale(throwforce);

            // Add a vertical component to give the object a better arc
            double verticalForce = throwforce / 2.0;
            float  dot           = Point3F.vectorDot(new Point3F("0 0 1"), eye);

            if (dot < 0)
            {
                dot = dot * -1;
            }

            vec = vec + Point3F.vectorScale(new Point3F(string.Format("0 0 {0}", verticalForce)), 1 - dot);
            vec = vec + thisobj.getVelocity();

            // Set the object's position and initial velocity
            TransformF pos = new TransformF(Util.getBoxCenter(thisobj.getWorldBox()));

            obj.setTransform(pos);

            obj.applyImpulse(pos.MPosition, vec);

            // Since the object is thrown from the center of the shape,
            // the object needs to avoid colliding with it's thrower.

            obj.setCollisionTimeout(thisobj);


            if ((obj.getClassName() != "AITurretShape") && (obj.getClassName() != "ProximityMine"))
            {
                obj.schedule(ItemPopTime.AsString(), "delete");
            }
        }