private void DestroyBuilding(string message)
    {
        buildingStatus = BUILDINGSTATUS.Idle;

        for (int item = 0; item < drillList.Count; item++)
        {
            Destroy(drillList[item]);
        }
        drillList = new List<GameObject>();
    }
    private void DestroyBuilding(string message)
    {
        buildingStatus = BUILDINGSTATUS.Idle;

        for (int item = 0; item < drillList.Count; item++)
        {
            Destroy(drillList[item]);
        }
        drillList = new List <GameObject>();
    }
    private void OnHold()
    {
        if (miningCell != null && miningCellControl != null)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                timer = timerIntervallDrilling;

                buildingStatus = BUILDINGSTATUS.Mining;
            }
        }
    }
    private void Mining()
    {
        if (miningCell != null && miningCellControl != null)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                if (miningCellControl.menge <= 0)
                {
                    DestroyBuilding("Rohstoff erschöpft");
                }

                timer = timerIntervallDrilling;

                int amount = (int)Mathf.Clamp(miningAmount, 0, miningCellControl.menge);

                int notStored = storageWindow.SetStorageUp(miningCellControl.bodenart, amount);

                if (notStored == -1)
                {
                    DestroyBuilding("Rohstoff hat keinen Wert");
                }

                Debug.Log("Rohstoff = " + miningCellControl.bodenart.ToString());
                Debug.Log("Menge = " + amount.ToString());
                Debug.Log("Rest = " + notStored.ToString());

                if (notStored > 0)
                {
                    buildingStatus = BUILDINGSTATUS.OnHold; return;
                }
                miningCellControl.menge -= amount - notStored;
            }
        }
    }
    private void Probing()
    {
        if (drillingDepthCurrent <= probingDepthGoal)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                RaycastHit[] hitEbene = Physics.RaycastAll(gameObject.transform.position, gameObject.transform.position * -1, 5, 1 << 8);//Mathf.Infinity
                GameObject   layer    = null;
                CellControl  cell     = null;
                Vector3      newPos;
                GameObject   newProbe;

                drillingDepthCurrent++;
                timer = timerIntervallProbing;

                for (int intEbene = 0; intEbene < hitEbene.Length; intEbene++)
                {
                    layer = hitEbene[intEbene].transform.parent.gameObject;
                    cell  = layer.GetComponent <CellControl>();

                    if (cell.lage == (20 - drillingDepthCurrent + 1))
                    {
                        break;
                    }
                }

                try
                {
                    newPos   = new Vector3(layer.transform.position.x, layer.transform.position.y, prefabProbeOject.transform.position.z);
                    newProbe = (GameObject)Instantiate(prefabProbeOject, newPos, layer.transform.rotation);

                    drillList.Add(newProbe);
                    newProbe.transform.position = newPos;


                    if (cell.isHidden)
                    {
                        cell.isHidden = false; cell.LoadTexture();
                    }
                    if (cell.lage >= 20 - probingShowAmountMax)
                    {
                        cell.showAmount = true;
                    }

                    if (drillingDepthCurrent > probingDepthGoal)
                    {
                        buildingStatus = BUILDINGSTATUS.Idle;
                        DestroyBuilding("Sondieren fertig");
                    }
                }
                catch
                {
                    DEBUG_GotException = true;
                    timer = 0;
                    drillingDepthCurrent--;
                }
            }
        }
    }
    private void Drilling()
    {
        if (drillingDepthCurrent <= drillingDepthGoal)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                RaycastHit[] hitEbene = Physics.RaycastAll(gameObject.transform.position, gameObject.transform.position * -1, 5, 1 << 8);//Mathf.Infinity
                GameObject   layer    = null;
                CellControl  cell     = null;
                Vector3      newPos;
                GameObject   newDrill;

                drillingDepthCurrent++;
                timer = timerIntervallDrilling;

                for (int intEbene = 0; intEbene < hitEbene.Length; intEbene++)
                {
                    layer = hitEbene[intEbene].transform.parent.gameObject;
                    cell  = layer.GetComponent <CellControl>();

                    if (cell.lage == (20 - drillingDepthCurrent + 1))
                    {
                        break;
                    }
                }

                try
                {
                    newPos   = new Vector3(layer.transform.position.x, layer.transform.position.y, prefabDrillObject.transform.position.z);
                    newDrill = (GameObject)Instantiate(prefabDrillObject, newPos, layer.transform.rotation);
                    newDrill.transform.parent = gameObject.transform.parent.transform;



                    drillList.Add(newDrill);
                    newDrill.transform.position = newPos;

                    if (cell.isHidden)
                    {
                        cell.isHidden = false; cell.LoadTexture();
                    }
                    if (!canDrill(cell))
                    {
                        DestroyBuilding("Gestein zu Hart --> Abbruch");
                    }
                    else if (drillingDepthCurrent > drillingDepthGoal)
                    {
                        buildingStatus    = BUILDINGSTATUS.Mining;
                        miningCell        = layer;
                        miningCellControl = cell;
                    }
                }
                catch
                {
                    DEBUG_GotException = true;
                    timer = 0;
                    drillingDepthCurrent--;
                }
            }
        }
    }
    private void Mining()
    {
        if (miningCell != null && miningCellControl != null)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                if (miningCellControl.menge <= 0) { DestroyBuilding("Rohstoff erschöpft"); }

                timer = timerIntervallDrilling;

                int amount = (int)Mathf.Clamp(miningAmount, 0, miningCellControl.menge);

                int notStored = storageWindow.SetStorageUp(miningCellControl.bodenart, amount);

                if (notStored == -1) DestroyBuilding("Rohstoff hat keinen Wert");

                Debug.Log("Rohstoff = " + miningCellControl.bodenart.ToString());
                Debug.Log("Menge = " + amount.ToString());
                Debug.Log("Rest = " + notStored.ToString());

                if (notStored > 0) { buildingStatus = BUILDINGSTATUS.OnHold; return; }
                miningCellControl.menge -= amount - notStored;


            }
        }
    }
    private void Probing()
    {
        if (drillingDepthCurrent <= probingDepthGoal)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                RaycastHit[] hitEbene = Physics.RaycastAll(gameObject.transform.position, gameObject.transform.position * -1, 5, 1 << 8);//Mathf.Infinity            
                GameObject layer = null;
                CellControl cell = null;
                Vector3 newPos;
                GameObject newProbe;

                drillingDepthCurrent++;
                timer = timerIntervallProbing;

                for (int intEbene = 0; intEbene < hitEbene.Length; intEbene++)
                {
                    layer = hitEbene[intEbene].transform.parent.gameObject;
                    cell = layer.GetComponent<CellControl>();

                    if (cell.lage == (20 - drillingDepthCurrent + 1)) break;
                }

                try
                {

                    newPos = new Vector3(layer.transform.position.x, layer.transform.position.y, prefabProbeOject.transform.position.z);
                    newProbe = (GameObject)Instantiate(prefabProbeOject, newPos, layer.transform.rotation);

                    drillList.Add(newProbe);
                    newProbe.transform.position = newPos;


                    if (cell.isHidden) { cell.isHidden = false; cell.LoadTexture(); }
                    if (cell.lage >= 20 - probingShowAmountMax) { cell.showAmount = true; }

                    if (drillingDepthCurrent > probingDepthGoal)
                    {
                        buildingStatus = BUILDINGSTATUS.Idle;
                        DestroyBuilding("Sondieren fertig");
                    }
                }
                catch
                {
                    DEBUG_GotException = true;
                    timer = 0;
                    drillingDepthCurrent--;

                }
            }
        }
    }
    private void Drilling()
    {
        if (drillingDepthCurrent <= drillingDepthGoal)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                RaycastHit[] hitEbene = Physics.RaycastAll(gameObject.transform.position, gameObject.transform.position * -1, 5, 1 << 8);//Mathf.Infinity            
                GameObject layer = null;
                CellControl cell = null;
                Vector3 newPos;
                GameObject newDrill;

                drillingDepthCurrent++;
                timer = timerIntervallDrilling;

                for (int intEbene = 0; intEbene < hitEbene.Length; intEbene++)
                {
                    layer = hitEbene[intEbene].transform.parent.gameObject;
                    cell = layer.GetComponent<CellControl>();

                    if (cell.lage == (20 - drillingDepthCurrent + 1)) break;
                }

                try
                {
                    newPos = new Vector3(layer.transform.position.x, layer.transform.position.y, prefabDrillObject.transform.position.z);
                    newDrill = (GameObject)Instantiate(prefabDrillObject, newPos, layer.transform.rotation);
                    newDrill.transform.parent = gameObject.transform.parent.transform;



                    drillList.Add(newDrill);
                    newDrill.transform.position = newPos;

                    if (cell.isHidden) { cell.isHidden = false; cell.LoadTexture(); }
                    if (!canDrill(cell)) { DestroyBuilding("Gestein zu Hart --> Abbruch"); }
                    else if (drillingDepthCurrent > drillingDepthGoal)
                    {

                        buildingStatus = BUILDINGSTATUS.Mining;
                        miningCell = layer;
                        miningCellControl = cell;
                    }
                }
                catch
                {
                    DEBUG_GotException = true;
                    timer = 0;
                    drillingDepthCurrent--;

                }
            }
        }
    }
    private void OnHold()
    {
        if (miningCell != null && miningCellControl != null)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                timer = timerIntervallDrilling;

                buildingStatus = BUILDINGSTATUS.Mining;
            }
        }
    }