コード例 #1
0
        public CellMap getCellMap()
        {
            var graph = new CellMap();

            foreach (Cell c in cells.Values)
            {
                graph.addElement(c);
            }
            return(graph);
        }
コード例 #2
0
ファイル: CellMap.cs プロジェクト: Pylair/MeleeCombat
 public void Except(CellMap other)
 {
     cells = cells.Where(x => !other.cells.ContainsKey(x.Key)).ToDictionary(x => x.Key, x => x.Value);
     edges = edges.Where(x => !other.edges.ContainsKey(x.Key)).ToDictionary(x => x.Key, x => x.Value);
     walls = walls.Where(x => !other.walls.ContainsKey(x.Key)).ToDictionary(x => x.Key, x => x.Value);
 }
コード例 #3
0
ファイル: GenerateMap.cs プロジェクト: Pylair/MeleeCombat
		public void placeMapPieces (IEnumerable<Room> rooms){

			GameObject physicalMap = new GameObject();
			physicalMap.name = "Completed Map";
			
			Dictionary<Bounds,int> boundsCount = new Dictionary<Bounds, int>();
			Dictionary<Bounds,BoundsData> maxCount = new Dictionary<Bounds,BoundsData>();
			Dictionary<Bounds,List<Vector3>> directions = new Dictionary<Bounds, List<Vector3>>();
			List<GameObject> markedForDeletion = new List<GameObject>();
			GameObject parent = new GameObject();
			
			var cellDict = new CellMap();
			foreach (Room r in rooms){
				propFill(physicalMap,r);
				foreach (Cell c in r.cells.Values) cellDict.addElement(c);
			
			}
			
				
			

			setComponentDirectory(componentDirectoryFile);
			

			var walls = cellDict.wallList;
			var edges = cellDict.edgeList;
			
			
			
			while (walls.Any()){
				var s = walls.Last();
				walls.Remove(s);

					Vector3 right;
					Vector3 center;
					Bounds bounds;
					
					right = s.groupNormal;
					center = s.groupCenter;
					bounds = s.groupBounds;
					

					var forward = Vector3.forward;
					var up = Vector3.Cross(forward,right);
					var dot = Vector3.Dot(Vector3.forward,right);
					if (Mathf.Approximately(Math.Abs(dot),1)){
						up = Vector3.up;
						forward = Vector3.right;
					}
					
					bounds.size += right * .1f;
					

					var tag = s.tag;
		
					var g = componentDirectory[tag].getComponent(true);
					g.transform.parent = physicalMap.transform;
					Aligner.AlignBoundingBoxFaceToBoundingBoxFace(forward,up,bounds,g);
				}
	
			
				foreach (Edge e in edges){
					var forward = e.slope;
					forward = new Vector3(Math.Abs(forward.x),Math.Abs(forward.y),Math.Abs(forward.z));
					var up = Vector3.up;
					
					if (Mathf.Approximately(Math.Abs(Vector3.Dot(up,forward)),1)){
						up = Vector3.forward;
						
					}
					var right = Vector3.Cross(forward,up);
					var tag = e.tag;
					
					var size = right * .1f + up * .1f + forward;
					var bounds = new Bounds(e.center(),size);

					var g = Instantiate(componentDirectory[tag].defaultComponent);
					g.transform.parent = physicalMap.transform;
					Aligner.AlignBoundingBoxFaceToBoundingBoxFace(forward,up,bounds,g);
				}
		
			
			physicalMap.transform.localEulerAngles += offsetRotation;
			physicalMap.transform.localScale = finalScale;
			physicalMap.transform.localPosition += offsetPosition;
			
		}
コード例 #4
0
ファイル: CellMap.cs プロジェクト: Pylair/MeleeCombat
 public void merge(CellMap other)
 {
     other.cells.ToList().ForEach(x => cells[x.Key] = x.Value);
     other.walls.ToList().ForEach(x => walls[x.Key] = x.Value);
     other.edges.ToList().ForEach(x => edges[x.Key] = x.Value);
 }