/// <summary>
 /// output some text, show/hide a dialogue, and change the color of the region
 /// </summary>
 void doSomething(TriggerRegion region, RigidBody otherBody, TriggerReportFlags flags, CollisionReportInfo info)
 {
     if (flags.HasFlag(TriggerReportFlags.Enter)) {
         Console.WriteLine(otherBody.GetName() + " has entered trigger area \"" + region.Name + "\"");
         // cycle through the balloon colors
         region.CycleToNextColor();
     }
     else {
         Console.WriteLine(otherBody.GetName() + " has left trigger area \"" + region.Name + "\"");
         region.CycleToNextColor();
     }
 }
Esempio n. 2
0
        void CrossFinishLine(TriggerRegion region, RigidBody otherBody, TriggerReportFlags flags, CollisionReportInfo info)
        {
            // get the kart out of the object
            Kart kart = ((CollisionObjectDataHolder) otherBody.UserObject).GetThingAsKart();

            // make sure it's passed the halfway point first
            if (kart != null && lapData[kart.OwnerID].first) {
                lapData[kart.OwnerID].first = false;

                if (lapData[kart.OwnerID].second >= 2) {
                    // we have completed three laps, fire the finish event
                    if (OnFinish != null)
                        OnFinish(kart);

                    // if it's the player, fire its event
                    if (kart == LKernel.GetG<PlayerManager>().MainPlayer.Kart) {
                        if (OnPlayerFinish != null)
                            OnPlayerFinish(kart);
                    }

                    // and if it's the first one to finish, fire that one too
                    if (!anyoneFinishedYet) {
                        anyoneFinishedYet = true;
                        if (OnFirstFinish != null)
                            OnFirstFinish(kart);
                    }
                }
                else {
                    // increment the counter
                    lapData[kart.OwnerID].second++;

                    // don't fire the event when we just cross the line when the race starts
                    if (lapData[kart.OwnerID].second != 1) {
                        // we have completed a lap, fire the lap event
                        if (OnLap != null)
                            OnLap(kart, lapData[kart.OwnerID].second);

                        if (kart == LKernel.GetG<PlayerManager>().MainPlayer.Kart) {
                            if (OnPlayerLap != null)
                                OnPlayerLap(kart, lapData[kart.OwnerID].second);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Need to check somewhere else on the track otherwise we can just drive in circles over the finish line
        /// </summary>
        void Halfway(TriggerRegion region, RigidBody otherBody, TriggerReportFlags flags, CollisionReportInfo info)
        {
            Kart kart = ((CollisionObjectDataHolder) otherBody.UserObject).GetThingAsKart();

            if (kart != null && !lapData[kart.OwnerID].first) {
                lapData[kart.OwnerID].first = true;
            }
        }
        /// <summary>
        /// When a kart enters a trigger region, check that it's one of the AI ones, and if so, tell the kart where to go next
        /// </summary>
        private void OnTriggerEnter(TriggerRegion currentRegion, RigidBody otherBody, TriggerReportFlags flags, CollisionReportInfo info)
        {
            TriggerRegion nextRegion;
            if (nextTriggerRegions.TryGetValue(currentRegion, out nextRegion))
            {
                Kart kart = null;

                if (otherBody.UserObject is CollisionObjectDataHolder)
                {
                    kart = (otherBody.UserObject as CollisionObjectDataHolder).GetThingAsKart();
                }

                if (kart != null && kart.Player.IsComputerControlled)
                {
                    (kart.Player as ComputerPlayer).CalculateNewWaypoint(currentRegion, nextRegion, info);
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Run the enter event
 /// </summary>
 public void InvokeTrigger(RigidBody otherBody, TriggerReportFlags flags, CollisionReportInfo info)
 {
     // at the moment this only triggers when the "main" shape of an actor enters. Do we want to change this?
     if (OnTrigger != null) {
     #if DEBUG
         try {
     #endif
             OnTrigger(this, otherBody, flags, info);
     #if DEBUG
         }
         catch (Exception e) {
             Launch.Log("Exception at TriggerRegion.InvokeTrigger: " + e.Message + "  " + e.Source);
         }
     #endif
     }
 }
Esempio n. 6
0
 public static bool IsLeaveFlag(TriggerReportFlags flag)
 {
     return flag.HasFlag(TriggerReportFlags.Leave);
 }
Esempio n. 7
0
 public static bool IsEnterFlag(TriggerReportFlags flag)
 {
     return flag.HasFlag(TriggerReportFlags.Enter);
 }
Esempio n. 8
0
        void tr_OnTrigger(TriggerRegion region, RigidBody otherBody, TriggerReportFlags flags, CollisionReportInfo info)
        {
            var pos = new Vector3(-305.8f, 45.4037f, -693.169f) / 5f;
            var quat = new Quaternion(0.7143f, 0, -0.6998f, 0);

            quat = quat * new Quaternion(0, 0, 1, 0);

            Matrix4 mat = new Matrix4();
            mat.MakeTransform(pos, Vector3.UNIT_SCALE, quat);

            Kart kart = (otherBody.UserObject as CollisionObjectDataHolder).GetThingAsKart();

            if (kart != null) {
                kart.Body.WorldTransform = mat;
                kart.Body.Activate();
            }
        }