// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null && hit.collider.GetComponent <EquationBlock>() != null) { if (selection != null) { selection.Deselect(); } selection = hit.collider.GetComponent <ISelectable>(); selection.Select(); } } if (Input.GetMouseButtonDown(1)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null && hit.collider.GetComponent <AnswerBlock>() != null && CurrentSelection().GetGameObject().GetComponent <EquationBlock>() != null) { GameObject SelectedequationBlock = CurrentSelection().GetGameObject(); if (selection != null) { selection.Deselect(); } selection = hit.collider.GetComponent <ISelectable>(); selection.Select(); BlockMatcher equationMatchManager = new BlockMatcher(SelectedequationBlock, CurrentSelection().GetGameObject()); } } }
void Awake() { block = GetComponent <Block>(); slider = GetComponent <BlockSlider>(); clearer = GetComponent <BlockClearer>(); faller = GetComponent <BlockFaller>(); matcher = GetComponent <BlockMatcher>(); spriteRenderer = GetComponent <SpriteRenderer>(); block.OnBlockChanged += HandleBlockChanged; }