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);
    }
Ejemplo n.º 2
0
    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;
            }
        }
    }
Ejemplo n.º 3
0
    // 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());
    }
Ejemplo n.º 4
0
 public ISignalChannel <object> GetChannel()
 {
     return(_channel.Get <ISignalChannel <object> > ());
 }