Example #1
0
        private void Awake()
        {
            _sight = GetComponent <IObserver>().sight;
            _sight.canDetectPredicates = new List <Predicate <SightTargetInfo> >();
            _sight.canDetectPredicates.Add(CanDetectTarget);
//            _sight.canDetectPredicates.Add(CanDetectTargetFalse);
        }
Example #2
0
        // creates an instance of every class that inherits from ISight contained in this assembly and adds it to the Sights list
        private static void RegisterSights()
        {
            Sights.Clear();

            IEnumerable <Type> types = Assembly.GetExecutingAssembly().GetTypes().Where(t => !t.IsAbstract && !t.IsInterface && typeof(ISight).IsAssignableFrom(t));

            foreach (Type type in types)
            {
                Game.LogTrivial($"Creating ISight instance of type '{type.Name}'...");
                ISight s = (ISight)Activator.CreateInstance(type);
                Sights.Add(s);
            }
        }
Example #3
0
        private static void Update()
        {
            for (int i = 0; i < Sights.Count; i++)
            {
                ISight s = Sights[i];

                if (s.IsActive)
                {
                    s.OnActiveUpdate();

                    if (s.MustBeDeactivated)
                    {
                        s.IsActive = false;
                    }
                }
                else
                {
                    if (s.MustBeActivated)
                    {
                        s.IsActive = true;
                    }
                }
            }
        }
Example #4
0
 public SightTargetInfo(ISightTarget target, ISight sight)
 {
     this.target = target;
     this.sight  = sight;
 }