예제 #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);
        }
    }
예제 #2
0
        private async void EventInfoList_TestGetEventInfoList()
        {
            var eventInfoList = await EventInfoList.GetEventInfoList();

            Assert.NotNull(eventInfoList);
            Assert.True(eventInfoList.IsReadOnly);
            Assert.Equal(3, eventInfoList.Count);
        }
예제 #3
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);
        }
    }
예제 #4
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);
        }