Exemplo n.º 1
0
 private void OnCure(InfectableBase host)
 {
     //var _spriteRenderer = host.GetComponent<SpriteRenderer>();
     if (_spriteRenderer)
     {
         _spriteRenderer.color = _oldColor;
     }
 }
Exemplo n.º 2
0
        public virtual void Infect(InfectableBase host)
        {
            if (Host != null)
            {
                Debug.LogWarning("Infection Instances can only infect one host during its life cycle!");
                return;
            }

            Host = host;
            OnInfect(Host);
        }
Exemplo n.º 3
0
        public virtual void Cure()
        {
            if (Host == null)
            {
                return;
            }

            OnCure(Host);
            Host = null;

            //Destroy(this.gameObject);
        }
Exemplo n.º 4
0
        void OnCollisionEnter2D(Collision2D col)
        {
            var            go  = col.collider.attachedRigidbody ? col.collider.attachedRigidbody.gameObject : col.collider.gameObject;
            InfectableBase inf = go.GetComponent <InfectableBase>();

            Debug.Log("Curing....");
            if (inf != null)
            {
                Debug.Log("Curing!");
                inf.CureAll();
            }
        }
Exemplo n.º 5
0
        public void TryInfect(GameObject target)
        {
            InfectableBase inf = target.GetComponent <InfectableBase>();

            //Debug.Log("Infecting..");
            if (inf != null)
            {
                if (inf.Infect(this, new InfectionEventArgs(InfectionPrefab, TransmissionMedium)))
                {
                    Debug.Log("Infect Success!");
                    OnInfectSuccess();
                }
            }
        }
Exemplo n.º 6
0
 private void OnInfect(InfectableBase host)
 {
     if (!_spriteRenderer)
     {
         _spriteRenderer = host.GetComponent <SpriteRenderer>();
         if (!_spriteRenderer)
         {
             _spriteRenderer = host.GetComponentInChildren <SpriteRenderer>();
         }
     }
     if (_spriteRenderer)
     {
         _oldColor             = _spriteRenderer.color;
         _spriteRenderer.color = NewColor;
     }
 }