Example #1
0
 public void Update()
 {
     foreach (Collider enemy in zombiesWhoHeard)
     {
         // use either Send Message or GetComponent and tell this enemy he heard something
         if (enemy != null)
         {
             GenericAgent zombie        = enemy.gameObject.GetComponent <GenericAgent>();
             var          heading       = transform.position;
             float        localDistance = Vector3.Distance(transform.position, zombie.transform.position);
             if (zombie.distanceToClosestSound > localDistance)
             {
                 zombie.SetDistanceToClosestSound(localDistance);
                 zombie.SetDestination(new Vector3(heading.x, -1, heading.z));
             }
         }
     }
     if (timer >= 0)
     {
         timer -= UnityEngine.Time.deltaTime; // TODO decrement temporally
     }
     else
     {
         stopSound();
     }
 }
        public void ShouldLoadSettings()
        {
            var settings        = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent           = new GenericAgent <TestModel>(serviceProvider, Options.Create(settings));

            Assert.Same(settings.Services.First().Value, agent.ServiceSettings);
        }
        public void ShouldLoadSettings()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new GenericAgent<TestModel>(serviceProvider, Options.Create(settings));

            Assert.Same(settings.Services.First().Value, agent.ServiceSettings);
        }
Example #4
0
 public void stopSound()
 {
     foreach (Collider enemy in zombiesWhoHeard)
     {
         if (enemy != null)
         {
             int          r      = UnityEngine.Random.Range(4, 10);
             double       theta  = UnityEngine.Random.Range(0, 360) * Math.PI / 180.0;
             float        a      = (float)Math.Cos(theta) * r;
             float        b      = (float)Math.Sin(theta) * r;
             GenericAgent zombie = enemy.gameObject.GetComponent <GenericAgent>();
             zombie.SetDestination(new Vector3(transform.position.x + a, transform.position.y, transform.position.z + b));
             zombie.SetDistanceToClosestSound(Mathf.Infinity);
         }
     }
     Destroy(gameObject);
 }
Example #5
0
 public void OnTriggerStay(Collider other)      //TODO create object collider
 {
     if (other.gameObject.CompareTag(targetTag))
     {
         float         distance   = Vector3.Distance(transform.position, other.attachedRigidbody.position);
         GenericWeapon usedWeapon = Attack(distance, other.attachedRigidbody);
         GenericAgent  otherAgent = other.gameObject.GetComponent <GenericAgent>();
         if ((usedWeapon != null) && (otherAgent != null))
         {
             if (usedWeapon.Contagion > 0)
             {
                 otherAgent.humanityRate -= usedWeapon.Contagion;
             }
             otherAgent.healthPoints -= usedWeapon.Damages;
         }
     }
 }
 public ValuesController(IDemoAgent serviceAgent, GenericAgent <Address> addressAgent)
 {
     _serviceAgent = serviceAgent;
     _addressAgent = addressAgent;
 }
 public ValuesController(IDemoAgent serviceAgent, GenericAgent<Address> addressAgent)
 {
     _serviceAgent = serviceAgent;
     _addressAgent = addressAgent;
 }