private void Notify(string code, EMalwareType type) { foreach (ICodeBarObserver observer in observers) { observer.Send(code, type); print($"Send code: '{code}' to destroy {type}"); } }
protected void OnTriggerExit2D(Collider2D collision) { if (SendCode && collision.gameObject.GetComponent <MalwareDirection>() != null) { EMalwareType type = collision.gameObject.GetComponent <MalwareDirection>().type; SendCode = false; Debug.Log($"Collided with {type}"); switch (type) { case EMalwareType.Discard: CodeMaker.Instance.ClearCode(); return; } Notify(CodeMaker.Instance.Code, type); } }
public void Send(string code, EMalwareType type) { print($"Received code: '{code}' to destroy {type}"); GameObject objFound = null; VirusPool.IteratePool((obj) => { Malware malware = obj.GetComponent <Malware>(); if (malware.Type == type && code == malware.Decode) { objFound = obj; } }); if (objFound != null) { objFound.SetActive(false); print($"Got it! Destroying this annoying virus of type: {type}"); } else { print($"Couldn't find any {type} with code: '{code}'"); } }