Ejemplo n.º 1
0
                public void NewInformation(VisionEventArgs e)
                {
                    if (!reactToNewInfo)
                    {
                        return;
                    }

                    if (e.Inconsistency == InconsistencyType.Missing)
                    {
                        KnownUnseen(e.Voxeme);
                    }
                    else
                    {
                        UnknownSeen(e.Voxeme);
                    }
                }
Ejemplo n.º 2
0
                // updating memory happens in LateUpdate after all visual perception happened in Update (See SyntheticVision)
                void Update()
                {
                    ShowMemory = _interactionPrefs.showVisualMemory;
                    if (!ShowMemory)
                    {
                        MemoryCanvas.SetActive(false);
                    }
                    else
                    {
                        MemoryCanvas.SetActive(true);
                    }

                    foreach (GameObject obj in _world.availableObjs)
                    {
                        Voxeme voxeme = obj.GetComponent <Voxeme>();
                        //				Debug.Log(voxeme + " is visible?");
                        List <GameObject> clones = null;
                        if (_vision.IsVisible(voxeme))
                        {
                            //					Debug.Log(voxeme + " is");
                            if (!_memorized.ContainsKey(voxeme))
                            {
                                clones = GetVisualClone(obj.gameObject);
                                _memorized.Add(voxeme, clones);

                                if (!_perceivingInitialConfiguration)
                                {
                                    // don't do this when you initially populate knownObjects
                                    // but otherwise
                                    // surprise!
                                    // todo _surpriseArgs can be plural
                                    _surpriseArgs = new VisionEventArgs(voxeme, InconsistencyType.Present);
                                    foreach (var clone in clones)
                                    {
                                        StartCoroutine(clone.GetComponent <BoundBox>().Flash(10));
                                    }

                                    Debug.Log(string.Format("{0} Surprise!", voxeme));
                                    _reactionTimer.Enabled = true;
                                }
                            }
                            else
                            {
                                clones = _memorized[voxeme];
                            }
                        }
                        // block is not visible
                        else
                        {
                            //					Debug.Log(voxeme + " is not ");
                            // but I know about it
                            if (_memorized.ContainsKey(voxeme))
                            {
                                clones = _memorized[voxeme];
                                // but I see it's not where it supposed to be!
                                if (clones.All(clone => _vision.IsVisible(clone)))
                                {
                                    // surprise!
                                    _surpriseArgs = new VisionEventArgs(voxeme, InconsistencyType.Missing);
                                    foreach (var clone in clones)
                                    {
                                        StartCoroutine(clone.GetComponent <BoundBox>().Flash(10));
                                        Destroy(clone, 3);
                                    }

                                    _memorized.Remove(voxeme);
                                    Debug.Log(string.Format("{0} Surprise!", voxeme));
                                    _reactionTimer.Enabled = true;
                                }
                            }
                        }

                        if (clones == null || clones.Count == 0)
                        {
                            continue;
                        }

                        foreach (var clone in clones)
                        {
                            if (_objectSelector.disabledObjects.Contains(voxeme.gameObject))
                            {
                                clone.transform.parent = null;
                                clone.SetActive(true);
                            }
                            else if (clone.transform.parent != null)
                            {
                                clone.transform.SetParent(voxeme.gameObject.transform);
                            }

                            BoundBox highlighter = clone.GetComponent <BoundBox>();
                            if (_vision.IsVisible(voxeme))
                            {
                                highlighter.lineColor = new Color(0.0f, 1.0f, 0.0f, 0.2f);
                            }
                            else
                            {
                                highlighter.lineColor = new Color(1.0f, 0.0f, 0.0f, 0.8f);
                            }
                        }
                    }

                    if (_memorized.Count > 0 && _perceivingInitialConfiguration)
                    {
                        // effectively this goes false after the first frame
                        _perceivingInitialConfiguration = false;
                    }

                    if (_surprise)
                    {
                        NewInformation(_surpriseArgs);
                        _surprise = false;
                    }
                }