示例#1
0
 public bool GetTriggerState(string triggerName, out WorldTriggerState worldTriggerState)
 {
     worldTriggerState = null;
     for (int i = 0; i < Triggers.Count; i++)
     {
         WorldTrigger trigger = Triggers [i];
         if (trigger.BaseState.Name.Equals(triggerName))
         {
             worldTriggerState = trigger.BaseState;
             break;
         }
     }
     return(worldTriggerState != null);
 }
        public override bool OnPlayerEnter()
        {
            if (mDimmingLanterns)
            {
                return(false);
            }

            if (LanternsToDim.Count == 0)
            {
                WorldItem lanternWorldItem = null;
                for (int i = 0; i < State.LanternsToDim.Count; i++)
                {
                    MobileReference mr = State.LanternsToDim[i];
                    if (WIGroups.FindChildItem(mr.GroupPath, mr.FileName, out lanternWorldItem))
                    {
                        LanternsToDim.Add(lanternWorldItem);
                    }
                }
                if (State.LanternsToDim.Count == 0)
                {
                    return(false);
                }
            }

            if (GuardInterventionTrigger == null)
            {
                WorldTriggerState wts = null;
                if (ParentChunk.GetTriggerState(State.GuardInterventionTriggerName, out wts))
                {
                    GuardInterventionTrigger = wts.trigger as TriggerGuardIntervention;
                }
                else
                {
                    return(false);
                }
            }

            mDimmingLanterns = true;
            mStartTime       = WorldClock.AdjustedRealTime;
            StartCoroutine(DimLanternsOverTime());

            return(true);
        }
示例#3
0
        protected IEnumerator UpdateTransitionOverTime()
        {
            //player sets off an explosion
            FXManager.Get.SpawnExplosionFX(State.ExplosionFXType, transform, State.ExplosionPosition);
            MasterAudio.PlaySound(State.ExplosionSoundType, transform, State.ExplosionSound);
            Player.Local.Audio.Cough();
            //explosion makes them go blind
            CameraFX.Get.SetBlind(true);
            CameraFX.Get.AddDamageOverlay(1f);
            double waitUntil = WorldClock.AdjustedRealTime + State.CharacterDTSDelay;

            while (WorldClock.AdjustedRealTime < waitUntil)
            {
                yield return(null);
            }
            //robert says some DTS
            Frontiers.GUI.NGUIScreenDialog.AddSpeech(State.CharacterDTSText, State.CharacterDTSName, State.CharacterDTSDuration);
            Player.Local.Audio.Cough();
            Player.Local.MovementLocked = true;
            //force the two camps to rebuild
            for (int i = 0; i < State.ForceRebuildLocations.Count; i++)
            {
                WorldItem activeLocation = null;
                if (WIGroups.FindChildItem(State.ForceRebuildLocations[i], out activeLocation))
                {
                    activeLocation.Get <MissionInteriorController>().ForceRebuild();
                }
                else
                {
                    Debug.Log("Couldn't load location " + State.ForceRebuildLocations[i]);
                }
            }
            //wait for a bit while that settles in
            waitUntil = WorldClock.AdjustedRealTime + State.CharacterDTSDuration;
            while (WorldClock.AdjustedRealTime < waitUntil)
            {
                yield return(null);
            }
            //player is moved to temple entrance
            GameWorld.Get.ShowAboveGround(true);
            Player.Local.Surroundings.ExitUnderground();
            waitUntil = WorldClock.AdjustedRealTime + 0.1f;
            while (WorldClock.AdjustedRealTime < waitUntil)
            {
                yield return(null);
            }
            //give gameworld a sec to catch up
            //lock the player's position for a moment
            //kill the guard at the temple door
            WorldTriggerState   triggerState = null;
            List <WorldTrigger> triggers     = GameWorld.Get.PrimaryChunk.Triggers;

            for (int i = 0; i < triggers.Count; i++)
            {
                if (triggers[i].name == "TriggerWarlockCampGuardIntervention")
                {
                    //get the trigger and kill the guard
                    //(due to the cave-in)
                    TriggerGuardIntervention tgi = triggers[i].GetComponent <TriggerGuardIntervention>();
                    tgi.KillGuard();
                    break;
                }
            }
            Player.Local.Position = State.PlayerWakeUpPosition;
            //blindness goes away
            CameraFX.Get.SetBlind(false);
            //as the player wakes up have him look at Robert
            Player.Local.HijackControl();
            double startHijackedTime = WorldClock.AdjustedRealTime;

            HijackedPosition            = gameObject.CreateChild("HijackedPosition");
            HijackedLookTarget          = gameObject.CreateChild("HijackedLookTarget");
            HijackedPosition.position   = State.PlayerWakeUpPosition;
            HijackedLookTarget.position = State.PlayerWakeUpLookTarget;

            while (WorldClock.AdjustedRealTime < startHijackedTime + State.HijackedTimeDuration)
            {
                Player.Local.SetHijackTargets(HijackedPosition, HijackedLookTarget);
                yield return(null);
            }

            Character character = null;

            if (!Characters.Get.SpawnedCharacter("Robert", out character))
            {
                //spawn Robert if we haven't already
                CharacterSpawnRequest spawnRequest = new CharacterSpawnRequest();
                spawnRequest.ActionNodeName            = "RobertPiecesTempleSpawn";
                spawnRequest.FinishOnSpawn             = true;
                spawnRequest.CharacterName             = "Robert";
                spawnRequest.MinimumDistanceFromPlayer = 3f;
                spawnRequest.SpawnBehindPlayer         = false;
                spawnRequest.UseGenericTemplate        = false;
                spawnRequest.CustomConversation        = "Robert-Enc-Act-02-Pieces-05";
                Player.Local.CharacterSpawner.AddSpawnRequest(spawnRequest);
            }

            Player.Local.RestoreControl(true);
            Player.Local.MovementLocked = false;
            GameObject.Destroy(HijackedPosition.gameObject, 0.5f);
            GameObject.Destroy(HijackedLookTarget.gameObject, 0.5f);
            //and we're done!
            yield break;
        }
        protected IEnumerator DimLanternsOverTime()
        {
            Debug.Log("Dimming lanterns!");

            GUI.GUIManager.PostIntrospection(State.IntrospectionBeforeStarting, true);

            double waitUntil = WorldClock.AdjustedRealTime + State.InitialDelay;

            while (WorldClock.AdjustedRealTime < waitUntil)
            {
                yield return(null);
            }

            GuardInterventionTrigger.SuspendGuard();
            //GuardInterventionTrigger.gameObject.SetActive (false);

            for (int i = 0; i < LanternsToDim.Count; i++)
            {
                LanternDimmer ld = LanternsToDim[i].Get <LanternDimmer>();
                ld.StartDimming();
                waitUntil = WorldClock.AdjustedRealTime + 0.5f;
            }

            if (State.UseReactivationTrigger)
            {
                WorldTriggerState reactivationTriggerState = null;
                if (ParentChunk.GetTriggerState(State.ReactivationTriggerName, out reactivationTriggerState))
                {
                    int numTimesTriggeredOnStart = reactivationTriggerState.NumTimesTriggered;
                    while (reactivationTriggerState.NumTimesTriggered == numTimesTriggeredOnStart)
                    {
                        //wait until it's been triggered again
                        waitUntil = WorldClock.AdjustedRealTime + 0.5f;
                        while (WorldClock.AdjustedRealTime < waitUntil)
                        {
                            yield return(null);
                        }
                    }
                }
            }
            else
            {
                while (WorldClock.AdjustedRealTime < mStartTime + State.RTDimDuration)
                {
                    yield return(null);
                }
            }

            for (int i = 0; i < LanternsToDim.Count; i++)
            {
                LanternDimmer ld = LanternsToDim[i].Get <LanternDimmer>();
                ld.StopDimming();
                waitUntil = WorldClock.AdjustedRealTime + 0.5f;
                while (WorldClock.AdjustedRealTime < waitUntil)
                {
                    yield return(null);
                }
            }

            //GuardInterventionTrigger.gameObject.SetActive (true);
            GuardInterventionTrigger.ResumeGuard(false);

            mDimmingLanterns = false;
            yield break;
        }