public void Render(Position pos, Dungeon map)
 {
     if (rng.Next (20) == 0) {
                         var end = (GameObject)Object.Instantiate (c);
                         end.transform.position = map.Scaled (pos.Vector3 + new Vector3 (0f, 0.3f, 0f));
                 }
 }
예제 #2
0
 public Map(Dungeon target, Random rng, List<Room> rooms)
 {
     this.rng = rng;
     this.target = target;
     this.brushes = new RoomBrushFactory ();
     this.hallBrush = brushes.createRoomBrush (rng);
     this.torchBrush = new LevelGen.TorchBrush ();
     this.Rooms = rooms;
     UnityEngine.Debug.Log (Rooms);
 }
        public void DrawLevel()
        {
            d = new Dungeon ();

            var p = new Map (d, rng, levels[level]);

            p.buildMap ();

            d.RenderAll ();

            GameObject.FindGameObjectWithTag ("Player").transform.position = d.Scaled(new Vector3(2f, 20f, 2f));
        }
        public void Render(Position pos, Dungeon map)
        {
            GameObject wall;

            // floor
            if (!map.HasContent(pos + new Position (0, -1, 0))) {
            wall = GameObject.CreatePrimitive (PrimitiveType.Quad);
            wall.renderer.material = floorMaterial;
            map.AddChild(wall);
            wall.transform.Rotate(90,0,0);
            wall.transform.position = pos.Vector3 + new Vector3 (0, -0.5f, 0);
            }

            // ceiling
            if (!map.HasContent(pos + new Position (0, 1, 0))) {
            wall = GameObject.CreatePrimitive (PrimitiveType.Quad);
            wall.renderer.material = ceilingMaterial;
            map.AddChild(wall);
            wall.transform.Rotate(-90,0,0);
            wall.transform.position = pos.Vector3 + new Vector3 (0, 0.5f, 0);
            }

            // walls
            if (!map.HasContent(pos + new Position (-1, 0, 0))) {
            wall = GameObject.CreatePrimitive (PrimitiveType.Quad);
            wall.renderer.material = wallMaterial;
            map.AddChild(wall);
            wall.transform.Rotate(0,-90,0);
            wall.transform.position = pos.Vector3 + new Vector3 (-0.5f, 0, 0);
            }
            if (!map.HasContent(pos + new Position (1, 0, 0))) {
            wall = GameObject.CreatePrimitive (PrimitiveType.Quad);
            wall.renderer.material = wallMaterial;
            map.AddChild(wall);
            wall.transform.Rotate(0,90,0);
            wall.transform.position = pos.Vector3 + new Vector3 (0.5f, 0, 0);
            }
            if (!map.HasContent(pos + new Position (0, 0, -1))) {
            wall = GameObject.CreatePrimitive (PrimitiveType.Quad);
            wall.renderer.material = wallMaterial;
            map.AddChild(wall);
            wall.transform.Rotate(0,180,0);
            wall.transform.position = pos.Vector3 + new Vector3 (0, 0, -0.5f);
            }
            if (!map.HasContent(pos + new Position (0, 0, 1))) {
            wall = GameObject.CreatePrimitive (PrimitiveType.Quad);
            wall.renderer.material = wallMaterial;
            map.AddChild(wall);
            wall.transform.Rotate(0,0,0);
            wall.transform.position = pos.Vector3 + new Vector3 (0, 0, 0.5f);
            }
        }
 // Use this for initialization
 void Start()
 {
     d = new Dungeon ();
     var f = new RoomBrushFactory ();
     var rng = new System.Random (seed);
     Brush h = f.createRoomBrush (rng);
     d.Place (new Position(0, 0, 1), h);
     d.Place (new Position(1, 0, 0), h);
     d.Place (new Position(1, 1, 0), h);
     d.Place (new Position(1, 1, 1), h);
     d.Place (new Position(0, 1, 0), h);
     d.Place (new Position(0, 1, 1), h);
     d.RenderAll ();
 }
 public void Render(Position pos, Dungeon map)
 {
     GameObject doorPortal = (GameObject)Object.Instantiate(clonableRoomPortal);
     // walls
     if (!map.HasContent(pos + new Position (-1, 0, 0))) {
         doorPortal.transform.Rotate(0,180,0);
         doorPortal.transform.position = map.Scaled(pos.Vector3 + new Vector3 (-0.5f, 0, 0));
     }
     else if (!map.HasContent(pos + new Position (1, 0, 0))) {
         doorPortal.transform.Rotate(0,0,0);
         doorPortal.transform.position = map.Scaled(pos.Vector3 + new Vector3 (0.5f, 0, 0));
     }
     else if (!map.HasContent(pos + new Position (0, 0, -1))) {
         doorPortal.transform.Rotate(0,90,0);
         doorPortal.transform.position = map.Scaled(pos.Vector3 + new Vector3 (0, 0, -0.5f));
     }
     else if (!map.HasContent(pos + new Position (0, 0, 1))) {
         doorPortal.transform.Rotate(0,270,0);
         doorPortal.transform.position = map.Scaled(pos.Vector3 + new Vector3 (0, 0, 0.5f));
     }
 }
 public void Render(Position pos, Dungeon map)
 {
     torch = (GameObject)Object.Instantiate(clonableTorch);
     // walls
     if (!map.HasContent(pos + new Position (-1, 0, 0))) {
         torch.transform.Rotate(0,180,0);
         torch.transform.position = map.Scaled(pos.Vector3 + new Vector3 (-0.5f, 0, 0));
     }
     else if (!map.HasContent(pos + new Position (1, 0, 0))) {
         torch.transform.Rotate(0,0,0);
         torch.transform.position = map.Scaled(pos.Vector3 + new Vector3 (0.5f, 0, 0));
     }
     else if (!map.HasContent(pos + new Position (0, 0, -1))) {
         torch.transform.Rotate(0,90,0);
         torch.transform.position = map.Scaled(pos.Vector3 + new Vector3 (0, 0, -0.5f));
     }
     else if (!map.HasContent(pos + new Position (0, 0, 1))) {
         torch.transform.Rotate(0,270,0);
         torch.transform.position = map.Scaled(pos.Vector3 + new Vector3 (0, 0, 0.5f));
     }
     else {
         Object.Destroy(torch.gameObject);
     }
 }
 public void Render(Position pos, Dungeon map)
 {
     var end = (GameObject)Object.Instantiate(endTrigger);
     end.transform.position = pos.Vector3;
     map.AddChild (end);
 }