private void EnterMine(Mineable m) { worldCanvas.SetActive(true); worldCanvas.transform.position = m.transform.position; worldCanvas.transform.LookAt(Camera.main.transform); resourceImage.sprite = m.Resource.Icon; }
private void EnterMine(Mineable m) { if (currentMine == m) { return; } currentMine = m; onEnterMine?.Invoke(currentMine); }
public void ExitMine() { if (currentMine == null) { return; } currentMine = null; StartCoroutine(mineCountdown); }
public void MineCurrent(Mineable m)//GameObject objectThatTheMouseIsOver) { /* Mineable m; * * if (!objectThatTheMouseIsOver.TryGetComponent(out m) || Vector3.Distance(transform.position, objectThatTheMouseIsOver.transform.position) > validDistance) ||{ || ExitMine(); || return; ||} */ //--------Entering a new mine------------ if (currentMine == null) { StopCoroutine(mineCountdown); mineCountdown = DoMineCountdown(m.MiningTime); EnterMine(m); } //--------------------------------------- //Mining progress countdown += Time.deltaTime * miningSpeed; //----------Upon achieving full mining progress--------- if (countdown >= m.MiningTime) { countdown = 0; m.MineResource(); ReceiveResource(m.Resource); if (!m.HasResources) { //Mine is empty. LeaveEmptyMine(); } } //--------------------------------------------------- onMiningProgressChange?.Invoke(countdown / m.MiningTime); }
private void LeaveEmptyMine() { currentMine = null; onExitMine?.Invoke(); }