コード例 #1
0
 /// <summary>
 /// Depending on the bullet's mode, either deals damage or sends
 /// a team change signal.
 /// </summary>
 /// <param name="target">a target we just hit</param>
 void MessageToTarget(BehaviourMessageBus target)
 {
     if (mode == BulletMode.Damage)
     {
         target.Damage.Invoke(damage);
     }
     else if (mode == BulletMode.Convert)
     {
         MessageBus.Global.Convert.Invoke(target.gameObject);
     }
 }
コード例 #2
0
        public virtual void Awake()
        {
            //resolve MessageBus before we do anything else:
            _messageBus = GetComponent <BehaviourMessageBus>();

            if (_messageBus == null)
            {
                //we couldn't find a message bus -- we'll have to
                //create one
                _messageBus = gameObject.AddComponent <BehaviourMessageBus>();
            }
        }