Наследование: MonoBehaviour
Пример #1
0
 // Start is called before the first frame update
 void Start()
 {
     m_audioSource  = gameObject.GetComponent <AudioSource>();
     m_animator     = gameObject.GetComponent <Animator>();
     m_soundTrigger = GameObject.Find("PlayerHandle").transform.Find("SoundTrigger").GetComponent <SoundTrigger>();
     m_player       = GameObject.Find("PlayerHandle").GetComponent <Player>();
 }
Пример #2
0
        // <summary>Sets the sound which will play when the <c>SoundTrigger</c> is met.</summary>
        // The sound must be registered with the <c>PageWrapper</c>.</summary>
        public void SetSound(int id, SoundTrigger soundTrigger)
        {
            MediaPlayer toPlay = this.appWrapper.GetSound(id);

            // If the media doesn't exist in the wrapper, unregister here and return.
            if (toPlay == null)
            {
                this.soundTriggers.Remove(id);
                return;
            }

            // If is registered with this view, handle.
            if (this.soundTriggers.ContainsKey(id))
            {
                // If the new state is nothing, unregister
                if (soundTrigger == SoundTrigger.None)
                {
                    this.soundTriggers.Remove(id);
                    return;
                }

                // If the new state is the same as the old state, ignore.
                SoundTrigger existing = this.soundTriggers[id];
                if (soundTrigger == existing)
                {
                    return;
                }
            }

            // Register the sound object with this view.
            this.soundTriggers.Add(id, soundTrigger);
        }
Пример #3
0
 internal void AddObjectSound(SoundTrigger trigger, IList <int> objects, IEnumerable <Direction> directions, string seed)
 {
     ObjectSounds.Add(new SoundAction {
         Trigger    = trigger,
         ObjectIds  = objects,
         Directions = (directions == null) ? null : new HashSet <Direction>(directions),
         Seed       = seed,
     });
 }
 void Start()
 {
     CardController = (CardGridController)GameObject.Find("Card_Grid").GetComponent(typeof(CardGridController));
     animator       = GetComponent <Animator>();
     ThisColour     = Color.white;
     CardController.SendCardInfo(this);
     thisMaterial = GetComponent <MeshRenderer>().material;
     emitter      = GetComponent <SoundTrigger>();
 }
 void Start()
 {
     throwStart         = GameObject.FindGameObjectWithTag("ThrowStart");
     start_pos          = throwStart.transform.position;
     transform.position = start_pos;
     spider             = GameObject.Find("SpiderObject");
     spider_pos         = spider.transform.position;
     spidercontrols     = spider.GetComponent <SpiderController>();
     emitter            = GetComponent <SoundTrigger>();
 }
Пример #6
0
        void CheckTrigger(SoundTrigger trigger)
        {
            Logger.WriteLine(3, "Check trigger {0}", trigger);
            var sound = GameDef.GameSounds.SafeLookup(trigger);

            if (sound != null && !Sounds.Contains(sound))
            {
                Sounds.Add(sound);
                VerboseLog("Sound {0} {1}", sound, trigger);
            }
        }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     elapsedTurnsBar_Script = GameObject.Find("Turn_Bar_Elapsed").GetComponent <TurnBarVisuals>();
     for (int i = 0; i < Turns_Total; i++)
     {
         m_eventList[i] = EventType.Null;
     }
     m_eventList[Turns_Total] = EventType.GameOver;  //Example
     //m_eventList[3] = EventType.GoodEvent;
     //m_eventList[5] = EventType.BadEvent;
     spider_Script        = GameObject.Find("SpiderObject").GetComponent <SpiderController>();
     sceneLoaderBehaviour = GameObject.Find("SceneLoader").GetComponent <SceneLoaderBehaviour>();
     emitter = GetComponent <SoundTrigger>();
 }
Пример #8
0
        // <summary>Event handle which goes through every registered sound when the view is hovered and activates respectively.</summary>
        void OnHoverEventSound(object sender, HoverEventArgs e)
        {
            foreach (KeyValuePair <int, SoundTrigger> trigger in this.soundTriggers)
            {
                int          soundId      = trigger.Key;
                SoundTrigger soundTrigger = trigger.Value;

                // If isn't for hover event.
                if (soundTrigger != SoundTrigger.OnHover)
                {
                    continue;
                }
                // Passive Start just incase null.
                appWrapper.GetSound(soundId)?.Start();
            }
        }
Пример #9
0
        // check whether a sound has been triggered
        // NOTE: sound may not happen if some other command takes precedence
        internal void CheckTrigger(SoundTrigger trigger, int obj = 0, Direction direction = Direction.None)
        {
            Logger.WriteLine(3, "Check trigger {0} {1} {2}", trigger, _gamedef.ShowName(obj), direction);
            var sound = _gamedef.GameSounds.SafeLookup(trigger);

            if (sound == null)
            {
                var sact = _gamedef.ObjectSounds.FirstOrDefault(s => s.Trigger == trigger && s.ObjectIds.Contains(obj) &&
                                                                (s.Directions == null || s.Directions.Contains(direction)));
                if (sact != null)
                {
                    sound = sact.Seed;
                }
            }
            if (sound != null)
            {
                AddCommand(CommandName.Sound_, sound);
            }
        }
Пример #10
0
        public void SendTriggerSound(ObjectPart objpart, UUID sound, double gain, double soundradius, Vector3 top_north_east, Vector3 bottom_south_west)
        {
            var req = new SoundTrigger
            {
                OwnerID      = objpart.ObjectGroup.Owner.ID,
                SoundID      = sound,
                ObjectID     = objpart.ID,
                GridPosition = GridPosition,

                ParentID = (objpart.LinkNumber != 1) ?
                           objpart.ObjectGroup.ID :
                           UUID.Zero,
                Position = objpart.GlobalPosition,
                Gain     = gain.Clamp(0, 1)
            };

            if (objpart.ObjectGroup.IsAttachedToPrivate)
            {
                IAgent agent;
                if (Agents.TryGetValue(objpart.ObjectGroup.Owner.ID, out agent) &&
                    (agent.GlobalPosition - req.Position).Length <= soundradius)
                {
                    agent.SendMessageAlways(req, ID);
                }
            }
            else
            {
                foreach (IAgent agent in Agents)
                {
                    if ((agent.GlobalPosition - req.Position).Length <= soundradius)
                    {
                        agent.SendMessageAlways(req, ID);
                    }
                }
            }
        }
Пример #11
0
 void Awake()
 {
     instance = this;
 }
 private void OnClosetSound(SoundTrigger.Type type, float perceivedVolume)
 {
     if (perceivedVolume >= suspicionThreshold)
         Debug.Log("Boyfriend: What was that?");
 }
Пример #13
0
 internal void AddGameSound(SoundTrigger trigger, string seed)
 {
     GameSounds[trigger] = seed;
 }
    private void OnClosetSound(SoundTrigger.Type type, float volume)
    {
        print ("I AM TOO LOAUD! "+volume);
        if(volume < noiseThreshold) return;

        //do something
        eventOcurred = true;
        if(timesAngry==0){
            StartCoroutine(GetAngryShort());
            timesAngry++;
            return;
        }

        GetAngry();
    }
Пример #15
0
 private void Start()
 {
     soundTrigger = GameObject.Find("PlayerHandle").transform.Find("SoundTrigger").GetComponent <SoundTrigger>();
 }