Ejemplo n.º 1
0
        protected void OnHit(EventInfoList infoList, Target target)
        {
            if (this.isDead)
            {
                return;
            }

            foreach (EventInfo info in infoList)
            {
                switch (info.name)
                {
                case "Damage":
                    this.life -= (int)info.value;
                    break;
                }
            }

            if (this.life <= 0)
            {
                this.isDead = true;
                Instantiate
                (
                    this.explosion.gameObject,
                    this.transform.position,
                    this.transform.rotation
                );

                this.gameObject.SetActive(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Triggered when a target is hit
        /// </summary>
        /// <param name="source">The EventInfoList to send</param>
        /// <param name="source">
        /// The target struct used to cache this target when sent
        /// </param>
        public void OnHit(EventInfoList eventInfoList, Target target)
        {
#if UNITY_EDITOR
            // Normal level debug and above
            if (this.debugLevel > DEBUG_LEVELS.Off)
            {
                Debug.Log
                (
                    string.Format
                    (
                        "Targetable ({0}): EventInfoList[{1}]",
                        this.name,
                        eventInfoList.ToString()
                    )
                );
            }
#endif

            // Set the hitTime for all eventInfos in the list.
            eventInfoList = eventInfoList.CopyWithHitTime();

            if (this.onHitDelegates != null)
            {
                this.onHitDelegates(eventInfoList, target);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get a copy of this list with effectInfo.hitTime set to 'now'.
        /// </summary>
        /// <returns>EventInfoList</returns>
        public EventInfoList CopyWithHitTime()
        {
            var       newlist = new EventInfoList();
            EventInfo info;
            IEnumerator <EventInfo> enumerator = base.GetEnumerator();

            while (enumerator.MoveNext())
            {
                info         = enumerator.Current;
                info.hitTime = Time.time;
                newlist.Add(info);
            }

            return(newlist);
        }
Ejemplo n.º 4
0
        protected void OnHit(EventInfoList infoList, Target target)
        {
            // If dead, then all done! Will also interupt the co-routine.
            if (this.currentState == STATES.Dead)
            {
                return;
            }

            if (target.collider != null)
            {
                Debug.Log(this.name + " was hit by 3D collider on " + target.collider.name);
            }

#if (!UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2)  // Unity 4.3+ only...
            if (target.collider2D != null)
            {
                Debug.Log(this.name + " was hit by 2D collider on " + target.collider2D.name);
            }
#endif
            foreach (EventInfo info in infoList)
            {
                switch (info.name)
                {
                case "Damage":
                    this.life -= (int)info.value;
                    break;
                }
            }

            if (this.life <= 0)
            {
                this.SetState(STATES.Dead);

                Instantiate
                (
                    this.explosion.gameObject,
                    this.transform.position,
                    this.transform.rotation
                );

                Destroy(this.gameObject);
            }
        }
Ejemplo n.º 5
0
 public EventInfoList(EventInfoList eventInfoList) : base(eventInfoList)
 {
 }