Example #1
0
        private void Update()
        {
            if (Utility.Elapsed(timeOfLastLook, lookFrequency))
            {
                timeOfLastLook = Time.time;

                var ray = new Ray(transform.position, transform.forward);

                if (Physics.Raycast(ray, out var hit))
                {
                    var targetMemory = hit.transform.GetMemory();
                    var targetSeen   = false;

                    // Memory-holding targets may store whether they have been seen previously.
                    if (targetMemory != null && targetMemory.TryGetValue("TargetSeen", out var value))
                    {
                        targetSeen = (bool)value;
                    }

                    var @event = new Dictionary <string, object>
                    {
                        { "Target", hit.transform.gameObject },
                        { "TargetName", hit.transform.name },
                        { "TargetSeen", targetSeen },
                    };

                    var character = GetCharacterState();

                    var args = new QueryArgs("SeeObject", "Player", @event, character, Memory);
                    this.PostNotification(Notify.Action <QueryArgs>(), args);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Actions to take in response to stimulus.
        /// </summary>
        public void Response(Query query)
        {
            query.Get <Color>("SubtitleColor", StateSource.Character, out var color);
            var args = new SubtitleArgs(query.Who, response, color);

            this.PostNotification(Notify.Action <SubtitleArgs>(), args);
        }
Example #3
0
 private void OnDisable()
 {
     this.RemoveObserver(OnDialogue, Notify.Action <SubtitleArgs>());
 }
Example #4
0
 private void OnEnable()
 {
     this.AddObserver(OnDialogue, Notify.Action <SubtitleArgs>());
 }
Example #5
0
 private void OnDisable()
 {
     this.RemoveObserver(OnQueryEvent, Notify.Action <QueryArgs>());
 }
Example #6
0
 private void OnEnable()
 {
     this.AddObserver(OnQueryEvent, Notify.Action <QueryArgs>());
 }