private IEnumerator DoVisit(Dictionary <string, string> nameToDialogue, House houseType)
        {
            // Choose the dialogue based on the current combatant
            var combatant = BattleModel.SelectedCombatant;

            if (!nameToDialogue.ContainsKey(combatant.Name))
            {
                throw new ArgumentException("Could not find " + houseType + " visit dialogue for " + combatant.Name);
            }
            var dialogueName = nameToDialogue[combatant.Name];
            var path         = Path.Combine("Chapter 2", dialogueName);

            // Wait for the player to go through the dialogue
            var    dialogueComplete = false;
            Action action           = null;

            action = () => {
                dialogueComplete = true;
                StrangeUtils.RemoveOnceListener(DialogueCompleteSignal, action);
            };
            DialogueCompleteSignal.AddOnce(action);
            StartDialogueSignal.Dispatch(path);
            yield return(new WaitUntil(() => dialogueComplete));

            // Wait for the house light to go off and whatnot.
            var    houseDisabled         = false;
            Action houseDisabledCallback = null;

            houseDisabledCallback = () => {
                houseDisabled = true;
                StrangeUtils.RemoveOnceListener(HouseLightTransitionCompleteSignal, houseDisabledCallback);
            };
            HouseLightTransitionCompleteSignal.AddListener(houseDisabledCallback);
            MarkHouseVisitedSignal.Dispatch(houseType);
            yield return(new WaitUntil(() => houseDisabled));

            Debug.LogFormat("House Visit {0} complete. All done?: {1}", houseType, EastmerePlaza.HouseVisitsComplete);

            // Enable the clinic if the other houses have been visited
            if (EastmerePlaza.HouseVisitsComplete)
            {
                // Wait for the clinic animation to run
                Action clinicEnabledCallback = null;
                var    clinicEnabled         = false;
                clinicEnabledCallback = () => {
                    Debug.Log("Clinic enabled.");
                    clinicEnabled = true;
                    StrangeUtils.RemoveOnceListener(HouseLightTransitionCompleteSignal, clinicEnabledCallback);
                };
                HouseLightTransitionCompleteSignal.AddListener(clinicEnabledCallback);

                Debug.Log("Enabling the clinic.");
                HouseLightEnableSignal.Dispatch(House.Clinic);

                yield return(new WaitUntil(() => clinicEnabled));
            }
        }
Exemplo n.º 2
0
        protected override void Awake()
        {
            base.Awake();

            _sprite     = GetComponent <tk2dSprite>();
            _controller = GetComponent <CombatantController>();
            _animator   = GetComponent <CombatantAnimator>();

            StrangeUtils.Bubble(_animator.DeathSignal, DeathSignal);
            StrangeUtils.Bubble(_animator.AttackCompleteSignal, AttackCompleteSignal);
            StrangeUtils.Bubble(_animator.DodgeCompleteSignal, DodgeCompleteSignal);
        }
        private IEnumerator DoClinicVisit()
        {
            // Wait for the player to go through the dialogue
            var    dialogueComplete = false;
            Action action           = null;

            action = () => {
                dialogueComplete = true;
                StrangeUtils.RemoveOnceListener(DialogueCompleteSignal, action);
            };
            ScenePopCompleteSignal.AddOnce(action);
            PushSceneSignal.Dispatch("chapter_2_clinic_visit");

            // Preload Maelle in the background.
            var path         = "Prefabs/Combatants/Maelle";
            var maellePrefab = Resources.Load(path) as GameObject;

            while (!dialogueComplete)
            {
                yield return(new WaitForEndOfFrame());
            }

            var maelle = GameObject.Instantiate(maellePrefab);

            var units = View.transform.Find("Battle View/Map/Units");

            maelle.transform.SetParent(units);

            var position             = new Vector2(35, 19);
            var secondPositionOption = new Vector2(37, 19);

            var map = BattleModel.Map;

            if (map.IsBlocked(position))
            {
                position = secondPositionOption;
            }

            var dimensions    = BattleModel.Dimensions;
            var worldPosition = dimensions.GetWorldPositionForGridPosition(position);

            maelle.transform.position = worldPosition;

            SpawnCombatantSignal.Dispatch(maelle);

            var battle             = BattleModel.Battle;
            var reinforcementsTurn = battle.TurnNumber + ReinforcementTurnsAfterMaelle;

            BattleModel.Battle.ScheduleTurnEvent(reinforcementsTurn, MaelleReinforcementsKey);
        }