Beispiel #1
0
 private void OnCure(InfectableBase host)
 {
     //var _spriteRenderer = host.GetComponent<SpriteRenderer>();
     if (_spriteRenderer)
     {
         _spriteRenderer.color = _oldColor;
     }
 }
        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);
        }
        public virtual void Cure()
        {
            if (Host == null)
            {
                return;
            }

            OnCure(Host);
            Host = null;

            //Destroy(this.gameObject);
        }
        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();
            }
        }
Beispiel #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();
                }
            }
        }
Beispiel #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;
     }
 }