// it calls by onTouch event in CsGlobal and sets all values public void InitialSetUp() { movePosition = csGlobal.g_mousePosition; // sets end position if (isStanding && _gridBehavior.CanAchive(movePosition) ) // executes when player is standing { setPath(transform.position); SelectionController.SetSelection(path[path.Count - 1].transform.position, true); } else if (_gridBehavior.CanAchive(movePosition) ) // executes when player is moving { setPath(path[index].transform.position); SelectionController.SetSelection(path[path.Count - 1].transform.position, true); } // sets path and reset index void setPath(Vector3 startPosition) { _gridBehavior.SetPosition(startPosition, true); // sets start position _gridBehavior.SetPosition(movePosition, false); // sets end position _gridBehavior.SetDistance(); _gridBehavior.SetPath(); path = _gridBehavior.g_path; index = 0; } }
// Invokes on touch and sets block value public void SelectBlockToMine() { isMining = false; blockPosition = csGlobal.g_mousePosition; Collider2D hitInfo = Physics2D.OverlapPoint(blockPosition); if (_gridBehavior.CanAchive(blockPosition)) { if (hitInfo && hitInfo.CompareTag("Ore")) { block = hitInfo.GetComponent <OreDurability>(); SelectionController.SetSelection(block.transform.position, false); SetInfoActive(true); minedOreName.text = Constants.oresNames[block.oreStats.index]; minedOreHealth.value = block.currentDurability / block.oreStats.durability; } else { block = null; SetInfoActive(false); } } }