예제 #1
0
    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--;
                }
            }
        }
    }
예제 #2
0
    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--;
                }
            }
        }
    }