示例#1
0
    private IEnumerator EnableAsync(Game.Step step)
    {
        if (step == Game.Step.Door1)
        {
            yield return(new WaitForSeconds(kEnableDelay));
        }

        mHover.Reset();

        switch (step)
        {
        case Game.Step.Door1:
            mAmbientSound.Play(fFieldSounds); break;

        case Game.Step.Door2:
            mAmbientSound.Play(fKitchenSounds); break;

        case Game.Step.Door3:
            break;     // TODO: play a sound to cue the door to the hall
        }
    }
示例#2
0
        /// <summary>
        /// Function that handles tasks that trigger when a key is pressed.
        /// </summary>
        /// <param name="e">Data passed by the event handler that calls the function.</param>
        /// <returns></returns>
        public bool KeyPressed(MOIS.KeyEvent e)
        {
            switch (e.key)
            {
            case MOIS.KeyCode.KC_LEFT:
            case MOIS.KeyCode.KC_A:
                position--;
                if (position < -1)
                {
                    position = -1;
                }
                break;

            case MOIS.KeyCode.KC_RIGHT:
            case MOIS.KeyCode.KC_D:
                position++;
                if (position > 1)
                {
                    position = 1;
                }
                break;

            case MOIS.KeyCode.KC_SPACE:
                switch (position)
                {
                case -1:
                    running = false;
                    break;

                case 0:
                    if (soundEntity != null)
                    {
                        if (soundEntity.IsPlaying())
                        {
                            soundEntity.Stop();
                        }
                        else
                        {
                            soundEntity.Play();
                        }
                        break;
                    }

                    soundEntity = smgr.CreateSoundEntity("Assets/Sounds/DrumMono.ogg", mgr.GetSceneNode("Drum"), "Drum", false, false);
                    soundEntity.SetReferenceDistance(.5f);
                    soundEntity.SetMaxDistance(5);
                    soundEntity.Play();
                    break;

                case 1:
                    if (ambientSound != null)
                    {
                        if (ambientSound.IsPlaying())
                        {
                            ambientSound.Stop();
                        }
                        else
                        {
                            ambientSound.Play();
                        }
                        break;
                    }
                    ambientSound = smgr.CreateAmbientSound("Assets/Sounds/Tune.ogg", "Tune", false, false);
                    ambientSound.Play();
                    break;
                }
                break;

            case MOIS.KeyCode.KC_ESCAPE:
                running = false;
                break;
            }

            return(true);
        }
示例#3
0
 // -- commands --
 public void TurnOn()
 {
     fTime.gameObject.SetActive(true);
     mRenderer.material = fScreenOn;
     mAmbientSound.Play();
 }
示例#4
0
        private void InitStates()
        {
            _stateIdle = new State("Idle")
            {
                KeyRadio = async() =>
                {
                    await SetState(_stateRadio);
                },

                KeyAlarm = () =>
                {
                    _alarmEnabled = !_alarmEnabled;
                },

                ClockTick = async(time) =>
                {
                    if (time.Hours == _config.Alarm.Hours && time.Minutes == _config.Alarm.Minutes)
                    {
                        if (!_alarmSkip)
                        {
                            _alarmSkip = true;
                            await SetState(_stateAmbient);
                        }
                    }
                    else
                    {
                        _alarmSkip = false;
                    }
                }
            };

            _stateAmbient = new State("Ambient")
            {
                StateEnter = async() =>
                {
                    _ambientEnd = _timeService.Now + _config.AmbientDuration;
                    await _ambientSound.Play();
                },

                StateLeave = async() =>
                {
                    await _ambientSound.Stop();
                },

                KeyAlarm = async() =>
                {
                    await SetState(_stateIdle);
                },

                KeyRadio = async() =>
                {
                    await SetState(_stateRadio);
                },

                ClockTick = async(time) =>
                {
                    if (time >= _ambientEnd)
                    {
                        await SetState(_stateRadio);
                    }
                }
            };

            _stateRadio = new State("Radio")
            {
                StateEnter = async() =>
                {
                    await _internetRadio.Play();
                },

                StateLeave = async() =>
                {
                    await _internetRadio.Stop();
                },

                KeyRadio = async() =>
                {
                    await SetState(_stateIdle);
                },

                KeyAlarm = async() =>
                {
                    await SetState(_stateIdle);
                },

                KeySnooze = async() =>
                {
                    await SetState(_stateSnooze);
                }
            };

            _stateSnooze = new State("Snooze")
            {
                StateEnter = async() =>
                {
                    //_snoozeAlarm = DateTime.Now.TimeOfDay + _config.SnoozeDuration;
                    _snoozeEnd = _timeService.Now + _config.SnoozeDuration;
                },

                KeyRadio = async() =>
                {
                    await SetState(_stateRadio);
                },

                KeyAlarm = async() =>
                {
                    await SetState(_stateIdle);
                },

                ClockTick = async(time) =>
                {
                    if (time >= _snoozeEnd)
                    {
                        await SetState(_stateRadio);
                    }
                }
            };

            SetState(_stateIdle);
        }