private void InstantiateHallway(HallwayTemplateMeta segment, MatchResult match) { //Debug.Log ("Hallway Instantiated"); //Find position Vector2 pos2D = grid.Grid [match.Position [0], match.Position [1]].Position; Vector3 pos3D = new Vector3(pos2D.x, 0f, pos2D.y); pos3D += segment.child.transform.position - new Vector3(-1f, 0f, -1f) * DoorDefinition.GlobalSize * 0.5f; //Vector3 offset = new Vector3 (-1f, 0, 1f) * DoorDefinition.GlobalSize * 0.5f; //Instantiate Prefab and position it correctly GameObject segmentCopy = GameObject.Instantiate(segment.child); //segmentCopy.transform.position = pos3D; //Set the parent to the hallway object (ensures the segments can be deleted easily later) //Instantiate the copy as a Chunk chunkInstantiator.ProcessType = ProcessType.GENERATE; chunkInstantiator.InstantiateChunk(segmentCopy, true); segmentCopy.transform.SetParent(hallwayObject.transform); segmentCopy.transform.position = pos3D; segmentCopy.transform.RotateAround(new Vector3(pos2D.x, 0f, pos2D.y), Vector3.up, match.Rotation); //segmentCopy.transform.rotation = Quaternion.Euler (Vector3.up * match.Rotation); //Update the grid, since positions are now occupied segment.MarkPositionAsUsed(grid, match); segment.NotifyCreated(); }
public bool IsConstraintSatisfied(HallwayTemplateMeta meta) { type = ConstraintType.UserDefinedTags; //Never actually set by the GUI bool result = ConstraintResult(meta.tags); switch (hAmount) { case HallwayAmount.WithTag: break; //The result is already the one we want, only true if tags are the same case HallwayAmount.WithoutTag: result = !result; break; case HallwayAmount.Unconstrained: result = true; break; case HallwayAmount.AtMost: //Either the constraint doesn't apply to this segment or when it does //Check whether the amount is within bounds if (result) { meta.RegisterAtMostConstraint(this); } result = !result || (result && matchingHallwaysUsed < absoluteAmount); break; case HallwayAmount.SetPriority: result = true; break; } return(result); }
public void CalculateHallwayPriority(HallwayTemplateMeta meta) { type = ConstraintType.UserDefinedTags; //Never actually set by the GUI bool result = ConstraintResult(meta.tags); if (result && hAmount == HallwayAmount.SetPriority) { meta.ConstraintPriority += hallwayPriority; } }
private bool AppliesToAllConstraints(HallwayTemplateMeta templateMeta) { return(constraints.All(c => c.IsConstraintSatisfied(templateMeta))); }
private bool MaskContainsPosition(HallwayTemplateMeta template, int[] position) { return(template.Positions.Any(tp => tp.Position [0] == position [0] && tp.Position [1] == position [1])); }