Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        private void EnterMine(Mineable m)
        {
            if (currentMine == m)
            {
                return;
            }

            currentMine = m;

            onEnterMine?.Invoke(currentMine);
        }
Esempio n. 3
0
        public void ExitMine()
        {
            if (currentMine == null)
            {
                return;
            }

            currentMine = null;

            StartCoroutine(mineCountdown);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        private void LeaveEmptyMine()
        {
            currentMine = null;

            onExitMine?.Invoke();
        }