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, l.storey * (behaviour.wallHeight + behaviour.storeySeparationHeight), 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(0, 180, 0);  break;

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

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

        case VirtualMap.DirectionType.South:    go.transform.localEulerAngles = new Vector3(0, 90, 0); break;
        }
        go.transform.localEulerAngles += new Vector3(0, 180, 0);                // Orientation fix


        AddToMapGameObject(cell_type, go, cell_type == VirtualCell.CellType.Door, l.storey);
    }
    virtual protected T GetDefault(string defaultName, VirtualMap.DirectionType orientation)
    {
        T default_object = Resources.Load(defaultName, typeof(T)) as T;

        //if (default_object == null)	Debug.LogWarning ("No default for type " + defaultName + " could be found! Make sure to add a variation for it!");
        DaedalusDebugUtils.Assert(default_object != null, "No default of name " + defaultName + " could be found!", this);
        return(default_object);
    }
	//override public bool ForcedOrientation{get{return true;}}

	public float MeasureTileSize(){	
        GameObject prefab = GetPrefab(VirtualCell.CellType.CorridorFloorU); // Get the first one (U)

        MeshFilter meshFilter = prefab.GetComponent<MeshFilter>();
        if (meshFilter != null) return meshFilter.sharedMesh.bounds.size.z;

        DaedalusDebugUtils.Assert(false, "Cannot Measure Tile Size For Prefab " + prefab.name);
        return 0;
    }
Beispiel #4
0
    public float MeasureSize(VirtualCell.CellType type)
    {
        GameObject prefab = GetPrefab(type);

        BoxCollider2D collider = prefab.GetComponent <BoxCollider2D>();

        if (collider != null)
        {
            return(collider.size.x);
        }

        DaedalusDebugUtils.Assert(false, "Cannot Measure Tile Size For Prefab " + prefab.name);
        return(0);
    }
Beispiel #5
0
    private List <GameObject> SelectInternal(PhysicalMap physicalMap, SelectionObjectType type)
    {
        if (physicalMap == null)
        {
            Debug.Log("NO PHYSICAL MAP!");
            return(null);
        }

        DaedalusDebugUtils.Assert(physicalMap.gameObjectLists != null, "Physical map's game object lists are null!");

        List <GameObject> list = physicalMap.GetObjectsOfType(type) as List <GameObject>;

        if (list.Count == 0)
        {
            Debug.Log("NO ITEMS!");
            return(list);
        }

        if (OVERRIDE_MATERIALS)
        {
            Material currentMat = list[0].GetComponentsInChildren <MeshRenderer>()[0].sharedMaterial;

            if (originalMaterials.ContainsKey(type) && originalMaterials[type] != null)
            {
                // Already selected!
                return(list);
            }
            else
            {
                originalMaterials[type] = currentMat;
            }

            Material sharedMat = new Material(currentMat);
            sharedMat.color = Color.blue;
            sharedMat.name  = "Debug Material";
            foreach (GameObject go in list)
            {
                foreach (MeshRenderer r in go.GetComponentsInChildren <MeshRenderer>())
                {
                    r.sharedMaterial = sharedMat;
                }
            }
        }
        return(list);
    }
Beispiel #6
0
    public float MeasureTileSize()
    {
        GameObject prefab = GetPrefab(VirtualCell.CellType.CorridorFloor);

        if (prefab == null)
        {
            prefab = GetPrefab(VirtualCell.CellType.CorridorFloorI);                 // We use the I one if we cannot fetch the floor!
        }
        DaedalusDebugUtils.Assert(prefab != null, "No prefab was chosen for CorridorFloor or CorridorFloorI! We need one of those to measure tile size!");

        MeshFilter meshFilter = prefab.GetComponent <MeshFilter>();

        if (meshFilter != null)
        {
            return(meshFilter.sharedMesh.bounds.size.z);
        }

        DaedalusDebugUtils.Assert(false, "Cannot Measure Tile Size For Prefab " + prefab.name);
        return(0);
    }
    // Fixed orientation!
    override public void CreateObject(VirtualMap map, MetricLocation l, VirtualCell.CellType cell_type, VirtualMap.DirectionType orientation)
    {
        if (cell_type != VirtualCell.CellType.CorridorFloor)
        {
            Debug.Log("Bobor!");
        }

        GameObject prefab = behaviour.GetPrefab(cell_type, orientation);    // NOTE THE ORIENTATION HERE TOO!

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

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

        go.name = cell_type.ToString() + "_" + orientation.ToString();
        go.transform.localEulerAngles += new Vector3(0, 90, 0); // Orientation fix

        AddToMapGameObject(cell_type, go, cell_type == VirtualCell.CellType.Door, l.storey);
    }
    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);

//		Debug.Log (cell_type);
        GameObject go = (GameObject)GameObject.Instantiate(prefab, new Vector3(l.x * behaviour.tileSize, l.storey * (behaviour.wallHeight + behaviour.storeySeparationHeight), l.y * behaviour.tileSize), Quaternion.identity);

        go.name = cell_type.ToString();

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

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

        case VirtualMap.DirectionType.East:     break;

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

        // Checking orientation and position for ceiling
        if (cell_type == VirtualCell.CellType.CorridorCeiling || cell_type == VirtualCell.CellType.RoomCeiling)
        {
            Vector3 tmpPos = go.transform.position;
            tmpPos.y += behaviour.wallHeight;
            go.transform.position = tmpPos;

            Vector3 tmpRot = go.transform.localEulerAngles;
            tmpRot.x = 180;
            go.transform.localEulerAngles = tmpRot;
        }

        bool isDynamicCell = GetIsDynamicCell(cell_type);

        AddToMapGameObject(cell_type, go, isDynamicCell, l.storey);
    }
Beispiel #9
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;
        }
    }
Beispiel #10
0
    public List <GameObject> SelectObjectsByZone(int zone_number)
    {
        PhysicalMap physicalMap = generator.physicalMap;

        if (physicalMap == null)
        {
            Debug.Log("NO PHYSICAL MAP!");
            return(null);
        }

        DaedalusDebugUtils.Assert(physicalMap.zones != null, "Physical map's zone lists are null!");
        DaedalusDebugUtils.Assert(zone_number >= 0, "Zone number must be >= 0!");
        DaedalusDebugUtils.Assert(zone_number <= physicalMap.zones.Count - 1, "Zone number too high!");

        List <GameObject> list = physicalMap.GetObjectsOfZone(zone_number) as List <GameObject>;

        if (list.Count == 0)
        {
            Debug.Log("NO ITEMS!");
            return(list);
        }

        return(list);
    }
Beispiel #11
0
    void OnSceneGUI()
    {
        if (showDebugCoordinates || showDebugConnections)
        {
            PhysicalMap  physicalMap = this.targetInstance.GetPhysicalMap();
            VirtualMap[] virtualMaps = this.targetInstance.GetVirtualMaps();
            if (this.targetInstance.HasGeneratedDungeon())
            {
                if (physicalMap != null && virtualMaps.Length > 0)
                {
                    GUIStyle guiStyle = new GUIStyle();

                    if (showDebugCoordinates)
                    {
                        for (int i = 0; i < virtualMaps.Length; i++)
                        {
                            foreach (VirtualCell c in virtualMaps[i].GetAllCells())
                            {
                                Vector3 p = physicalMap.GetRealWorldPosition(c.location, i);
                                if (c.location.x % 2 == 1 && c.location.y % 2 == 1)
                                {
                                    guiStyle.normal.textColor = Color.yellow;
                                    int actual_x = (c.location.x - 1) / 2;
                                    int actual_y = (c.location.y - 1) / 2;
                                    Handles.Label(p, c.location.x + "," + c.location.y + "\n(" + actual_x + "," + actual_y + ")", guiStyle);
                                }
                                else
                                {
                                    guiStyle.normal.textColor = Color.white;
                                    Handles.Label(p, c.location.x + "," + c.location.y, guiStyle);
                                }
                            }
                        }
                    }

                    if (showDebugConnections)
                    {
                        for (int i = 0; i < virtualMaps.Length; i++)
                        {
                            VirtualMap          virtualMap          = virtualMaps[i];
                            List <CellLocation> unvisited_locations = new List <CellLocation>(virtualMap.WalkableLocations);
                            //Debug.Log("Starting from " + start_location);
                            int max_distance = virtualMap.GetMaximumDistance();

                            int stop_iter = 0;
                            while (unvisited_locations.Count > 0)
                            {
                                CellLocation start_location = unvisited_locations[0]; // We start from a walkable cell (doesn't matter which one)
                                VirtualCell  start_cell     = virtualMap.GetCell(start_location);

                                DrawConnections(start_cell, unvisited_locations, physicalMap, virtualMap, max_distance);

                                stop_iter++;
                                if (stop_iter == 100)
                                {
                                    DaedalusDebugUtils.Assert(false, "Looping in show debug connectsion!");
                                    break; // ERROR HERE!
                                }
                            }
                        }
                    }

                    // TEST path check
                    //VirtualMap test_virtualMap = virtualMaps[0];
                    //List<CellLocation> test_unvisited_locations = new List<CellLocation>(test_virtualMap.WalkableLocations);
                    //test_virtualMap.ExistsPathBetweenLocations(test_unvisited_locations[0], test_unvisited_locations[test_unvisited_locations.Count - 1]);
                }
            }
        }
    }
Beispiel #12
0
    override protected Sprite GetDefault(string defaultName, VirtualMap.DirectionType orientation = VirtualMap.DirectionType.None)
    {
//		Debug.Log (defaultName);
        DaedalusDebugUtils.Assert(loadedSpritesDict.ContainsKey(defaultName), "Cannot find default texture asset " + defaultName);
        return(loadedSpritesDict[defaultName]);
    }