예제 #1
0
        void Awake()
        {
            GameObject source;

            if (this.altSource)
            {
                source = this.altSource;
            }
            else
            {
                source = this.gameObject;
            }

            var ctrl = source.GetComponent <EventFireController>();

            if (ctrl != null)
            {
                this.fireCtrl = ctrl;
                this.fireCtrl.AddOnFireDelegate(this.OnFire);
            }
            else
            {
                var eventTrigger = source.GetComponent <EventTrigger>();
                if (eventTrigger != null)
                {
                    this.eventTrigger = eventTrigger;
                    this.eventTrigger.AddOnFireDelegate(this.OnFire);
                }
            }

            if (this.fireCtrl == null && this.eventTrigger == null)
            {
                throw new MissingComponentException("Must have either an EventFireController or EventTrigger.");
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PoolUtil.Target"/> struct.
        /// </summary>
        /// <param name='transform'>
        /// Transform that has a Targetable component
        /// </param>
        /// <param name='targetTracker'>
        /// Target tracker that detected this Target
        /// </param>
        public Target(Transform transform, TargetTracker targetTracker)
        {
            // Subtle but important difference with this constructure overload is
            //	it allows targetable to be 'null' which is used to avoid missing
            //	component exceptions in Area.
            this.gameObject = transform.gameObject;
            this.transform  = transform;

            this.targetable = transform.GetComponent <Targetable>();

            this.targetTracker = targetTracker;

            // The targetTracker arg could also be a derived type. If it is. populate more.
            // Also handle colliders to make the struct easier to use when trying to figure
            //	 out what collider triggered the OnHit event.
            this.eventTrigger = null;
            this.collider     = null;
            this.collider2D   = null;
            this.eventTrigger = targetTracker as EventTrigger;
            if (this.eventTrigger != null)
            {
                this.collider   = this.eventTrigger.coll;
                this.collider2D = this.eventTrigger.coll2D;
            }

            this.fireController = null;
        }
예제 #3
0
        protected void Awake()
        {
            // Constraint componant not required by this class because of the use of the
            //   base class. So, instead, test for null and notify the user if not found.
            if (this.unityConstraint == null)
            {
                this.unityConstraint = this.GetComponent <ConstraintBaseClass>();
                if (this.unityConstraint == null)
                {
                    throw new MissingComponentException
                          (
                              string.Format("No UnityConstraint was found on GameObject '{0}'", this.name)
                          );
                }
            }

            // Trigger property logic if a FireController is found or on this GameObject
            if (this._targetSource == null)
            {
                EventFireController ctrl = this.GetComponent <EventFireController>();
                if (ctrl != null)
                {
                    this.targetSource = ctrl;
                }
            }
            else
            {
                this.targetSource = this._targetSource;
            }
        }
예제 #4
0
        // Init by copy
        public Target(Target otherTarget)
        {
            this.gameObject = otherTarget.gameObject;
            this.transform  = otherTarget.transform;
            this.targetable = otherTarget.targetable;

            this.targetTracker  = otherTarget.targetTracker;
            this.fireController = otherTarget.fireController;
            this.eventTrigger   = otherTarget.eventTrigger;

            this.collider   = otherTarget.collider;
            this.collider2D = otherTarget.collider2D;
        }
예제 #5
0
        protected List <Target> iterTargets = new List <Target>(); // Loop cache


        #region CHANGED AWAKE TO MIMIC OLD VERSION OF THIS COMPONENT
        protected void Awake()
        {
            Debug.LogWarning(string.Format(
                                 "WaitForAlignementModifier on GameObject {0} has been deprecated. Replace the " +
                                 "component with AngleLimitModifier (with the filterType set to 'Wait to Fire " +
                                 "Event'). You can do this without losing your other settings by switching the " +
                                 "Inspector tab to 'Debug' and changing the script field.",
                                 this.name
                                 ));

            this.fireCtrl = this.GetComponent <EventFireController>();

            // Force because this old component could only do this
            this.filterType = FILTER_TYPE.WaitToFireEvent;
        }
예제 #6
0
        protected List <Target> iterTargets = new List <Target>(); // Loop cache

        protected void Awake()
        {
            this.fireCtrl = this.GetComponent <EventFireController>();

            // If a fireController was found it is cheaper to use its cached reference to get the
            //	 TargetTracker
            if (this.fireCtrl != null)
            {
                this.tracker = this.fireCtrl.targetTracker;
            }
            else
            {
                this.tracker = this.GetComponent <TargetTracker>();
            }

            // Just in case
            if (this.fireCtrl == null && this.tracker == null)
            {
                throw new MissingComponentException
                      (
                          "Must have at least a TargetTracker or EventFireController"
                      );
            }

            // If only 1 is set, force the filterType
            if (this.fireCtrl == null || this.tracker == null)
            {
                if (this.fireCtrl != null)
                {
                    this.filterType = FILTER_TYPE.WaitToFireEvent;
                }
                else
                {
                    this.filterType = FILTER_TYPE.IgnoreTargetTracking;
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PoolUtil.Target"/> struct.
        /// This is the most efficient constructor because it just stores references to
        /// caches that the Targetable already holds.
        /// </summary>
        /// <param name='targetable'>
        /// Targetable.
        /// </param>
        /// <param name='targetTracker'>
        /// Target tracker that detected the targetable.
        /// </param>
        public Target(Targetable targetable, TargetTracker targetTracker)
        {
            this.gameObject = targetable.go;
            this.transform  = targetable.transform;

            this.targetable = targetable;

            this.targetTracker = targetTracker;

            // The targetTracker arg could also be serived type. If it is. populate more.
            // Also handle colliders to make the struct easier to use when trying to figure
            //	 out what collider triggered the OnHit event.
            this.eventTrigger = null;
            this.collider     = null;
            this.collider2D   = null;
            this.eventTrigger = targetTracker as EventTrigger;
            if (this.eventTrigger != null)
            {
                this.collider   = this.eventTrigger.coll;
                this.collider2D = this.eventTrigger.coll2D;
            }

            this.fireController = null;
        }
예제 #8
0
 protected void Awake()
 {
     this.tracker  = this.GetComponent <TargetTracker>();
     this.fireCtrl = this.GetComponent <EventFireController>();
 }
예제 #9
0
        protected List <Target> iterTargets = new List <Target>(); // Loop cache

        protected void Awake()
        {
            this.fireCtrl = this.GetComponent <EventFireController>();
        }