public void SpawnAreaObject() { GameObject areaObj = currentAreaObj; NetworkServer.Spawn(areaObj); for (int i = 0; i < currentArea.corridors.Count; i++) { AreaCorridor corridor = currentArea.corridors[i]; for (int j = 0; j < corridor.segments.Count; j++) { AreaSegment seg = corridor.segments[j]; Vector3 segmentLocation = new Vector3(seg.x * segmentWidth, -1 * seg.y * segmentHeight, 0); NetworkServer.Spawn(seg.netId.gameObject); RpcSetupAreaSegment(areaObj.GetComponent <NetworkIdentity>(), seg.netId, corridor.index, seg.index, segmentLocation); for (int k = 0; k < 4; k++) { if (seg.walls[k] != null) { AreaSegmentInstallation installation = seg.installations[k]; if (installation != null) { NetworkServer.Spawn(installation.netId.gameObject); RpcSetupAreaInstallation(seg.netId, installation.netId, corridor.index, seg.index, k); } } } } } }
public AreaSegment(AreaCorridor cor) { corridor = cor; index = cor.segments.Count; for (int i = 0; i < 4; i++) { walls[i] = new AreaSegmentWall(i, this); installations[i] = null; } }
[ClientRpc] private void RpcSpawnInstallation(int corridorId, int segmentId, int dir, string type, string name, NetworkIdentity id) { AreaCorridor corridor = currentArea.corridors[corridorId]; AreaSegment segment = corridor.segments[segmentId]; segment.installations[dir] = new AreaSegmentInstallation(dir, segment); segment.installations[dir].type = type; segment.installations[dir].name = name; segment.installations[dir].netId = id; }
public AreaCorridor spawnCorridor(int x, int y, int len) { AreaCorridor cor = new AreaCorridor(); cor.coordinates = new Coordinates(x, y); cor.area = this; for (int i = 0; i < len; i++) { AreaSegment segment = new AreaSegment(cor); if (i != 0) { segment.walls[2] = null; } if (i != len - 1) { segment.walls[0] = null; } cor.segments.Add(segment); } cor.index = corridors.Count; corridors.Add(cor); return(cor); }
public int GetAreaLength() { int output = 0; if (corridors.Count > 0) { int min = corridors[0].x; int max = corridors[0].x + corridors[0].segments.Count; for (int i = 0; i < corridors.Count; i++) { AreaCorridor corridor = corridors[i]; if (corridor.x < min) { min = corridor.x; } if (corridor.x + corridor.segments.Count > max) { max = corridor.x + corridor.segments.Count; } } output = max - min; } return(output); }
public AreaCorridor MergeCorridors(AreaCorridor a, AreaCorridor b) { return(a); }
public GameObject GenerateAreaObject() { Area area = currentArea; GameObject areaObj = GameObject.Instantiate <GameObject>(areaObject); if (area.isStarship) { areaObj.transform.Find("Sky").gameObject.GetComponent <SpriteRenderer>().sprite = spaceSkySprites[area.starship.currentSector.skySpriteIndex]; } for (int i = 0; i < area.corridors.Count; i++) { AreaCorridor corridor = area.corridors[i]; for (int j = 0; j < corridor.segments.Count; j++) { AreaSegment seg = corridor.segments[j]; Vector3 segmentLocation = new Vector3(seg.x * segmentWidth, -1 * seg.y * segmentHeight, 0); GameObject areaSegment = GameObject.Instantiate <GameObject>(segmentObject); seg.netId = areaSegment.GetComponent <NetworkIdentity>(); areaSegment.transform.SetParent(areaObj.transform); areaSegment.transform.localPosition = segmentLocation; for (int k = 0; k < 4; k++) { GameObject installationObj; GameObject wallObj = areaSegment.transform.Find("Wall" + k.ToString()).gameObject; if (seg.walls[k] == null) { GameObject.Destroy(wallObj); } else { area.tileset.setWallSprite(wallObj, seg.walls[k]); AreaSegmentInstallation installation = seg.installations[k]; if (installation != null) { installationObj = GameObject.Instantiate(installationPrefabs[k]); installation.netId = installationObj.GetComponent <NetworkIdentity>(); installationObj.transform.SetParent(wallObj.transform); installationObj.transform.localPosition = new Vector3(0, 0, -1); switch (installation.type) { case "door": installationObj.AddComponent <DoorInstallation>(); installationObj.GetComponent <DoorInstallation>().attachedWall = wallObj; installationObj.GetComponent <DoorInstallation>().installationName = installation.name; installationObj.GetComponent <SpriteRenderer>().sprite = area.tileset.doorSprites[k]; installationObj.GetComponent <DoorInstallation>().directionId = k; break; case "interactive": installationObj.AddComponent <InteractiveInstallation>(); installationObj.GetComponent <InteractiveInstallation>().attachedWall = wallObj; installationObj.GetComponent <InteractiveInstallation>().installationName = installation.name; installationObj.GetComponent <InteractiveInstallation>().interfaceOverlayName = installation.overlayName; installationObj.GetComponent <SpriteRenderer>().sprite = area.tileset.getInstallationSprite(installation.name, k); break; } } } } } } return(areaObj); }