Esempio n. 1
0
 public ViewCone(ViewCone coneToCopy)
 {
     this.FoVAngle         = coneToCopy.FoVAngle;
     this.Range            = coneToCopy.Range;
     this.HorizontalOffset = coneToCopy.HorizontalOffset;
     this.SceneColor       = coneToCopy.SceneColor;
     this.awarenessLevel   = coneToCopy.awarenessLevel;
 }
Esempio n. 2
0
 public Sensor AddViewCone(ViewCone viewCone)
 {
     if (!ViewCones.Contains(viewCone))
     {
         ViewCones.Add(viewCone);
     }
     return(this);
 }
Esempio n. 3
0
        public void RemoveViewCone(int index)
        {
            if (index >= 0 && index < ViewCones.Count)
            {
                ViewCone coneToRemove = ViewCones[index];
                ViewCones.RemoveAt(index);

                if (coneToRemove.Range == maxViewConeDistance)
                {
                    recalculateMaxViewConeDistance();
                }
            }
        }
Esempio n. 4
0
        private void changeViewConeCount(int newValue)
        {
            int oldVal = ViewCones.Count;

            if (newValue > oldVal)
            {
                ViewCone coneToCopy = null;
                if (oldVal != 0 && ViewCones.Count == oldVal)
                {
                    coneToCopy = ViewCones[ViewCones.Count - 1];
                }

                for (int i = oldVal; i < newValue; i++)
                {
                    if (coneToCopy != null)
                    {
                        ViewCones.Add(new ViewCone(coneToCopy));
                    }
                    else
                    {
                        ViewCones.Add(new ViewCone());
                    }
                }
            }
            else if (newValue < oldVal)
            {
                if (newValue == 0)
                {
                    ViewCones.Clear();
                }
                else
                {
                    for (int i = 0; i < oldVal - newValue; i++)
                    {
                        RemoveViewCone(ViewCones.Count - 1);
                    }
                }
            }
        }
Esempio n. 5
0
        void OnSceneGUI()
        {
            SensorObject sensorObj = (SensorObject)target;

            if (sensorObj == null || !sensorObj.enabled)
            {
                return;
            }

            if (sensorObj.sensor == null)
            {
                sensorObj.sensor = new Sensor();
            }

            if (!sensorObj.sensor.DrawCones)
            {
                return;
            }

            if (sensorObj.sensor.ViewCones == null)
            {
                return;
            }

            for (int i = 0; i < sensorObj.sensor.ViewCones.Count; i++)
            {
                ViewCone vc = sensorObj.sensor.ViewCones[i];
                if (vc.DrawCone)
                {
                    Handles.color = vc.SceneColor;
                    Handles.DrawSolidArc(sensorObj.transform.position, sensorObj.transform.up,
                                         Quaternion.Euler(0, -vc.FoVAngle * 0.5f + vc.HorizontalOffset, 0) * sensorObj.transform.forward,
                                         vc.FoVAngle, vc.Range);
                }
            }
        }