Example #1
0
    public void tunnelFrom(CaveBody body, Vector3 dir)
    {
        CaveManager.tunnels.Add(this);

        GameObject digObj = CaveManager.getNewDigger();

        digObj.transform.localScale = new Vector3(1, 1, 1);
        digger = digObj.GetComponent <Digger>();
        digger.init(this);
        digger.colID              = body.centerColumnID;
        digger.tier               = body.tier + 1;
        digger.layer              = body.centerDepth + 2;
        destDepth                 = body.centerDepth + tunnelDepth;
        digger.neighbourCount     = 0;
        digger.transform.position = Vector3.zero;
        digger.setScale(tunnelSize);
        digger.gradient = 2;
        direction       = dir;


        digger.right     = Vector3.Cross(direction, -MapManager.manager.getPositionOf(0, body.centerColumnID)).normalized;
        digger.travelDir = direction.normalized;
        //Debug.Log("creating new digger with dir = " + digger.travelDir + " right = " + digger.right);
        digger.nextDest = 3 * MapManager.manager.getPositionOf(0, body.centerColumnID) - 2 * MapManager.manager.getPositionOf(1, body.centerColumnID);

        digger.gameObject.SetActive(true);

        digger.travelToNext();
    }
Example #2
0
    public abstract void informArrived();//the digger tells the controlling cave component it has arrived at its next destination

    public void createCaveBody()
    {
        digger.layer -= 2;
        CaveBody body = new CaveBody(digger);

        body.tier = digger.tier;
        //Debug.Log("digger finished digging entrance - entrance length: " + Vector3.Distance(MapManager.manager.getPositionOf(0, columnID), digger.transform.position));
    }
Example #3
0
    int destDepth;//the depth the cave entrance ends at


    internal void tunnelFrom(CaveBody body)
    {
        source = body;
        int     n     = rand.Next(0, 2);
        int     count = 0;
        Vector3 dir   = Vector3.zero;

        foreach (int nei in MapManager.manager.neighboursMap[body.centerColumnID])
        {
            if (count == n)
            {
                dir = MapManager.manager.getPositionOf(0, nei) - MapManager.manager.getPositionOf(0, body.centerColumnID);
                break;
            }
            count++;
        }

        tunnelFrom(body, dir);
    }