// 3D
    protected void ConvertCeiling(VirtualMap map, VirtualCell conversion_cell)
    {
        // Checking if we need to add a ceiling
        VirtualCell.CellType cell_type = conversion_cell.Type;
        //Debug.Log(conversion_cell);
        if (conversion_cell.IsFloor())
        {
            VirtualCell.CellType ceiling_type = VirtualCell.CellType.None;

            if (VirtualCell.IsRoomFloor(cell_type))
            {
                if (behaviour.addCeilingToRooms)
                {
                    ceiling_type = VirtualCell.CellType.RoomCeiling;
                }
            }
            else
            {
                if (behaviour.addCeilingToCorridors)
                {
                    ceiling_type = VirtualCell.CellType.CorridorCeiling;
                }
            }

            if (ceiling_type != VirtualCell.CellType.None)
            {
                conversion_cell.AddCellInstance(ceiling_type, conversion_cell.Orientation);
            }
        }
    }
Example #2
0
    // Returns true if this passage cell can be removed from the map (i.e. not shown)
    public bool IsPassageRemovable(CellLocation l)
    {
        VirtualCell cell = this.GetCell(l);

        if (cell.IsWall() || cell.IsEmpty())
        {
            // We count how many valid neighs are floors, and how many are nones
            int validNeigh = 0;
            int floorCount = 0;
            int noneCount  = 0;

            CellLocation n;
            foreach (DirectionType dir in directions)
            {
                n = GetNeighbourCellLocation(l, dir);
                if (!LocationIsOutsideBounds(n))
                {
                    validNeigh++;
                    VirtualCell neigh_cell = GetCell(n);
                    if (neigh_cell.IsFloor())
                    {
                        floorCount++;
                    }
                    else if (neigh_cell.IsNone() || neigh_cell.IsRock())
                    {
                        noneCount++;
                    }
                }
            }
            //Debug.Log(l + " Valid neighs: " + validNeigh + " floorCount: " + floorCount + " noneCount: " + noneCount);
            return(floorCount == 0);
        }
        return(false);
    }
    override public void CreateObject(VirtualMap map, MetricLocation l, VirtualCell.CellType cell_type, VirtualMap.DirectionType orientation)
    {
        GameObject go = null;

        if (alreadyCreated && currentIndex < spawnedSpriteGos.Count)
        {
            go = spawnedSpriteGos[currentIndex];
            currentIndex++;
        }
        else
        {
            go = (GameObject)GameObject.Instantiate(behaviour.spritePrefab, new Vector3(l.x * behaviour.tileSize, 0, l.y * behaviour.tileSize), Quaternion.identity);
            spawnedSpriteGos.Add(go);
        }

        Sprite sprite = behaviour.GetPrefab(cell_type);

        go.GetComponent <SpriteRenderer>().sprite = sprite;

        go.name = cell_type.ToString();
        go.GetComponent <BoxCollider2D>().size = new Vector2(behaviour.tileSize, behaviour.tileSize);
        AddToMapGameObject(cell_type, go);

//		Debug.Log ("Cell at " + l.x+"-"+l.y + " has orientation " + orientation);

        go.transform.localEulerAngles = new Vector3(90, 0, 0);
        switch (orientation)
        {
        case VirtualMap.DirectionType.West:     go.transform.localEulerAngles = new Vector3(90, 0, 0);  break;

        case VirtualMap.DirectionType.North:    go.transform.localEulerAngles = new Vector3(90, 90, 0); break;

        case VirtualMap.DirectionType.East:     go.transform.localEulerAngles = new Vector3(90, 180, 0); break;

        case VirtualMap.DirectionType.South:    go.transform.localEulerAngles = new Vector3(90, 270, 0); break;
        }


        // Move walls up a bit
        if (VirtualCell.IsFloor(cell_type))
        {
            // Already good
        }
        else
        {
            go.transform.localPosition += Vector3.up * 0.01f;
        }

        if (cell_type == VirtualCell.CellType.DoorHorizontalBottom)
        {
            go.transform.localPosition += Vector3.forward * behaviour.tileSize * 0.25f;
        }
    }
Example #4
0
    override public void CreateObject(VirtualMap map, MetricLocation l, VirtualCell.CellType cell_type, VirtualMap.DirectionType orientation)
    {
        Texture2D tile_texture = null;

        tile_texture = behaviour.GetPrefab(cell_type);

        GameObject go = (GameObject)GameObject.Instantiate(behaviour.tilePrefab, new Vector3(l.x * behaviour.tileSize, 0, l.y * behaviour.tileSize), Quaternion.identity);

        var tempMaterial = new Material(go.transform.GetComponent <Renderer>().sharedMaterial);

        tempMaterial.SetTexture("_MainTex", tile_texture);
        tempMaterial.name = cell_type.ToString() + "_Material";
        go.transform.GetComponent <Renderer>().sharedMaterial = tempMaterial;

        if (createdMaterialsList == null)
        {
            createdMaterialsList = new List <Material>();
        }
        createdMaterialsList.Add(tempMaterial);

        go.name = cell_type.ToString();
        AddToMapGameObject(cell_type, go);


        go.transform.localEulerAngles = new Vector3(0, 0, 0);
        switch (orientation)
        {
        case VirtualMap.DirectionType.West:     go.transform.localEulerAngles = new Vector3(0, 0, 0);  break;

        case VirtualMap.DirectionType.North:    go.transform.localEulerAngles = new Vector3(0, 90, 0); break;

        case VirtualMap.DirectionType.East:     go.transform.localEulerAngles = new Vector3(0, 180, 0); break;

        case VirtualMap.DirectionType.South:    go.transform.localEulerAngles = new Vector3(0, 270, 0); break;
        }

        // Move walls up a bit
        if (VirtualCell.IsFloor(cell_type))
        {
            // Already good
        }
        else
        {
            go.transform.localPosition += Vector3.up * 0.01f;
        }
    }
Example #5
0
    override public void CreateObject(VirtualMap map, MetricLocation l, VirtualCell.CellType cell_type, VirtualMap.DirectionType orientation)
    {
        GameObject prefab = behaviour.GetPrefab(cell_type);

        DaedalusDebugUtils.Assert(prefab != null, "No variation was chosen for " + cell_type);

        GameObject go = (GameObject)GameObject.Instantiate(prefab, new Vector3(l.x * behaviour.tileSize, 0, l.y * behaviour.tileSize), Quaternion.identity);

        go.name = cell_type.ToString();

        if (orientation == VirtualMap.DirectionType.None)
        {
            orientation = VirtualMap.DirectionType.North;
        }
        switch (orientation)
        {
        case VirtualMap.DirectionType.West:     go.transform.localEulerAngles = new Vector3(90, 0, 0);  break;

        case VirtualMap.DirectionType.North:    go.transform.localEulerAngles = new Vector3(90, 90, 0); break;

        case VirtualMap.DirectionType.East:     go.transform.localEulerAngles = new Vector3(90, 180, 0); break;

        case VirtualMap.DirectionType.South:    go.transform.localEulerAngles = new Vector3(90, 270, 0); break;
        }

        AddToMapGameObject(cell_type, go, cell_type == VirtualCell.CellType.Door, l.storey);

        // Move walls up a bit
        if (VirtualCell.IsFloor(cell_type))
        {
            // Already good
        }
        else
        {
            go.transform.localPosition += Vector3.up * 0.01f;
        }
    }