public void TestSetInstanceReferenceOverride() { var interfaceReference = new InterfaceReference(); var gameObject = new GameObject(); var interfaceImpl = gameObject.AddComponent <TestInterfaceImplementation>(); interfaceReference._object = interfaceImpl; Assert.That(interfaceReference.Get <TestInterface> (), Is.SameAs(interfaceImpl)); var gameObject2 = new GameObject(); var otherImpl = gameObject2.AddComponent <TestInterfaceImplementation>(); interfaceReference.Set(otherImpl); Assert.That(interfaceReference.Get <TestInterface> () != null); Assert.That(interfaceReference.Get <TestInterface> (), Is.SameAs(otherImpl)); Assert.That(interfaceReference._object != null); Assert.That(interfaceReference._object == otherImpl); var otherImpl2 = new TestInterfaceImplementationNotBehaviour(); interfaceReference.Set(otherImpl2); Assert.That(interfaceReference.Get <TestInterface> () != null); Assert.That(interfaceReference.Get <TestInterface> () == otherImpl2); Assert.That(interfaceReference._object == null); }
void Update() { if (_isDead) { return; } if (Input.GetKeyUp(killKey)) { totalHealth -= damage; if (totalHealth <= 0) { _isDead = true; charactedDiedChannel.Get().Signal(this.gameObject); } else { var health = new Health() { current = totalHealth, unit = this.gameObject }; characterLoseHealthChannel.Get <ISignalChannel <Health> > ().Signal(health); totalHealth = health.current; } } }
// Use this for initialization void Start() { injector.Inject(this); Debug.Log("SuperValue: " + megaSystem2.GetSuperValue()); Debug.Log("SuperValue: " + megaSystem1.Get().GetSuperValue()); Debug.Log("SuperValue: " + megaSystem4.Get <IMegaSystem>().GetSuperValue()); }
public ISignalChannel <object> GetChannel() { return(_channel.Get <ISignalChannel <object> > ()); }