示例#1
0
 public override void onEnterTrigger(Trigger trigger, GameBase obj)
 {
     if (obj["client"].isObject() && obj["client.welcomed"].AsBool())
         {
         message.MessageClient(obj["client"], "MsgItemPickup", "\\c1There\'s a platform in-front of you...Jump on.");
         obj["client.welcomed"] = "true";
         }
 }
        public override void onEnterTrigger(Trigger trigger, GameBase obj)
        {
            //if (!console.isMemberOfClass(obj, "Player"))
            //    return;

            if (obj["isTeleporting"].AsBool())
                return;
            // Get the location of our target position
            Trigger exit = trigger["exit"];

            bool valid = verifyObject(obj, trigger, exit);
            if (!valid)
                return;

            teleFrag(obj, exit);
            // Create our entrance effects on all clients.

            SimObject entranceeffect = trigger["entranceEffect"];
            if (entranceeffect.isObject())
                {
                foreach (GameConnection client in ClientGroup)
                    {
                    if (console.isObject(client))
                        console.commandToClient(client, "PlayTeleportEffect", new[] {trigger["position"], entranceeffect.getId().AsString()});
                    }
                }

            teleportPlayer(obj, exit);
            // Create our exit effects on all clients.

            SimObject exitEffect = trigger["exitEffect"];
            if (exitEffect.isObject())
                {
                foreach (GameConnection client in ClientGroup)
                    {
                    if (console.isObject(client))
                        console.commandToClient(client, "PlayTeleportEffect", new[] {trigger["position"], exitEffect.getId().AsString()});
                    }
                }

            // Record what time we last teleported so we can determine if enough
            // time has elapsed to teleport again
            int tolt = console.getSimTime();
            trigger["timeOfLastTeleport"] = tolt.AsString();

            // If this is a bidirectional teleporter, log it's exit too.
            if (exit["exit"] == trigger["name"])
                exit["timeOfLastTeleport"] = tolt.AsString();

            // Tell the client to play the 2D sound for the player that teleported.
            if (((SimObject) this["teleportSound"]).isObject() && ((GameConnection) obj["client"]).isObject())
                {
                ((GameConnection) obj["client"]).play2D(this["teleportSound"]);
                //GameConnection.play2D(obj, thisobj["teleportSound"]);
                }
        }
 public override void onLeaveTrigger(Trigger trigger, GameBase obj)
 {
     obj["isTeleporting"] = false.AsString();
 }
        public virtual void teleFrag(GameBase player, Trigger exit)
        {
            // When a telefrag happens, there are two cases we have to consider.
            // The first case occurs when the player's bounding box is much larger than the exit location, 
            // it is possible to have players colide even though a player is not within the bounds 
            // of the trigger Because of this we first check a radius the size of a player's bounding 
            // box around the exit location.

            // Get the bounding box of the player

            Point3F boundingBoxSize = new Point3F(((PlayerData) player.getDataBlock())["boundingBox"]);
            float radius = boundingBoxSize.x;
            float boxSizeY = boundingBoxSize.y;
            float boxSizeZ = boundingBoxSize.z;

            // Use the largest dimention as the radius to check
            if (boxSizeY > radius)
                radius = boxSizeY;
            if (boxSizeZ > radius)
                radius = boxSizeZ;

            Point3F position = exit.getTransform().GetPosition(); // new TransformF(con.getTransform(exit));
            uint mask = (uint) SceneObjectTypesAsUint.PlayerObjectType;

            // Check all objects within the found radius of the exit location, and telefrag
            // any players that meet the conditions.

            Dictionary<uint, float> r = console.initContainerRadiusSearch(position, radius, mask);
            foreach (ShapeBase objectNearExit in
                r.Keys.Where(objectNearExit => ((ShapeBase) objectNearExit).isMemberOfClass("Player")).Where(objectNearExit => objectNearExit.AsString() != player))
                objectNearExit.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag");
            // The second case occurs when the bounds of the trigger are much larger
            // than the bounding box of the player. (So multiple players can exist within the
            // same trigger). For this case we check all objects contained within the trigger
            // and telefrag all players.

            int objectsInExit = exit.getNumObjects();
            // Loop through all objects in the teleporter exit
            // And kill any players
            for (int i = 0; i < objectsInExit; i++)
                {
                ShapeBase objectInTeleporter = console.Call(exit, "getObject", new[] {i.AsString()});
                if (objectInTeleporter.isMemberOfClass("Player"))
                    continue;
                // Avoid killing the player that is teleporting in the case of two
                // Teleporters near eachother.
                if (objectInTeleporter == player)
                    continue;

                objectInTeleporter.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag");
                }
        }