Пример #1
0
        public new void Update()
        {
            if (isCompleted || isPaused || isAborted)
            {
                return;
            }

            if (GetPlayerBase().GetInventory().GetTotalCrystals() >= resourceCount)
            {
                Complete();
                return;
            }

            if (this.selectedCrystal == null)
            {
                selectedCrystal = GameMain.GetInstance().GetGameWorld().GetUnoccupiedNearbyCrystal(gameObject);
                if (selectedCrystal == null)
                {
                    Abort();
                    return;
                }
            }

            Vector3 dest = VectorUtil.nearestPointOnGameObject(gameObject.transform.position, selectedCrystal.gameObject);
            float   distanceToResource = (Vector2.Distance(VectorUtil.to2D(gameObject.transform.position), VectorUtil.to2D(dest)));

            if (distanceToResource > MIN_MINE_DISTANCE)
            {
                gameObject.GetComponent <WorkerDroneAI>().beginMoveTo(VectorUtil.nearestPointOnGameObject(gameObject.transform.position, selectedCrystal.gameObject), OnReachedTree);
            }
        }
Пример #2
0
        public override void Resume()
        {
            if (isPaused)
            {
                if (this.selectedCrystal == null)
                {
                    selectedCrystal = GameMain.GetInstance().GetGameWorld().GetUnoccupiedNearbyCrystal(gameObject);
                    if (selectedCrystal == null)
                    {
                        Abort();
                        return;
                    }
                }

                if (selectedCrystal != null)
                {
                    Vector3 dest = VectorUtil.nearestPointOnGameObject(gameObject.transform.position, selectedCrystal.gameObject);
                    float   distanceToResource = (Vector2.Distance(VectorUtil.to2D(gameObject.transform.position), VectorUtil.to2D(dest)));
                    if (distanceToResource > MIN_MINE_DISTANCE)
                    {
                        gameObject.GetComponent <WorkerDroneAI>()
                        .beginMoveTo(
                            VectorUtil.nearestPointOnGameObject(gameObject.transform.position, selectedCrystal.gameObject), OnReachedTree);
                    }
                    else
                    {
                        gameObject.transform.LookAt(selectedCrystal.transform);
                        mineTree();
                    }
                }
            }

            base.Resume();
        }