|
|
@@ -13,7 +13,8 @@ namespace Ships
|
|
|
FlyingEnemy = 2,
|
|
|
BrokenItemMod = 3,
|
|
|
BrokenChest = 4,
|
|
|
- OldChest = 5
|
|
|
+ OldChest = 5,
|
|
|
+ BrokenLaser = 6
|
|
|
}
|
|
|
|
|
|
public class ShipGenerator
|
|
|
@@ -31,15 +32,44 @@ namespace Ships
|
|
|
public static readonly FieldInfo networkStuffField = typeof(Chunk).GetField("networkStuff", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
public static readonly FieldInfo tempField = typeof(Chunk).GetField("temp", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
|
+ public static void GenarateTown(SpawnerScript s, int[] param)
|
|
|
+ {
|
|
|
+ GameScript.isTown = true;
|
|
|
+ if (GameScript.districtLevel % 2 != 0)
|
|
|
+ {
|
|
|
+ GameScript.districtLevel++;
|
|
|
+ }
|
|
|
+
|
|
|
+ s.backLights.SetActive(true);
|
|
|
+ s.mainLight.SetActive(false);
|
|
|
+ s.backLights.GetComponent<Renderer>().material = materialaBackLight;
|
|
|
+ //s.mainLight.GetComponentInChildren<Light>().color = new Color(0.05f, 0.05f, 0.05f, 0.1f);
|
|
|
+
|
|
|
+ s.bg[0].GetComponent<Renderer>().material = materialaParalexStars;
|
|
|
+ s.bg[1].GetComponent<Renderer>().material = materialaParalexNone;
|
|
|
+ s.bg[2].GetComponent<Renderer>().material = materialaParalexNone;
|
|
|
+ s.bg[3].GetComponent<Renderer>().material = materialaParalexNone;
|
|
|
+
|
|
|
+ var chunks = (GameObject[])chunksField.GetValue(s);
|
|
|
+ var num = 0;
|
|
|
+
|
|
|
+ chunks[num] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("z/Ships/ShuttleMain"), new Vector3((float)(218 + 0 * 128 + 4 * 8), 0f, 5f), Quaternion.Euler(0f, 180f, 180f));
|
|
|
+ num++;
|
|
|
+
|
|
|
+ if (Network.isServer)
|
|
|
+ {
|
|
|
+ chunks[num] = new GameObject("chunk");
|
|
|
+ var chunk = chunks[num].AddComponent<Chunk>();
|
|
|
+ PopulateTown(chunk);
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void Genarate(SpawnerScript s, int[] param)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
GameScript.isTown = false;
|
|
|
- if (GameScript.districtLevel % 2 != 0)
|
|
|
- {
|
|
|
- GameScript.districtLevel++;
|
|
|
- }
|
|
|
|
|
|
spawnLocations.Clear();
|
|
|
|
|
|
@@ -61,10 +91,12 @@ namespace Ships
|
|
|
chunks[num] = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("z/Ships/ShipAMain"), new Vector3((float)(218 + 0.75 * 128), 0f, 5f), Quaternion.Euler(0f, 180f, 180f));
|
|
|
num++;
|
|
|
|
|
|
- spawnLocations.Add(new int[] { 7, 7, 2 });
|
|
|
- spawnLocations.Add(new int[] { 10, 7, 2 });
|
|
|
- spawnLocations.Add(new int[] { 16, 7, 2 });
|
|
|
- spawnLocations.Add(new int[] { 17, 4, 2 });
|
|
|
+ spawnLocations.Add(new int[] { 7, 7, (int)ShipGeneratorObjectPoolType.FlyingEnemy });
|
|
|
+ spawnLocations.Add(new int[] { 10, 7, (int)ShipGeneratorObjectPoolType.FlyingEnemy });
|
|
|
+ spawnLocations.Add(new int[] { 16, 7, (int)ShipGeneratorObjectPoolType.FlyingEnemy });
|
|
|
+ spawnLocations.Add(new int[] { 17, 4, (int)ShipGeneratorObjectPoolType.FlyingEnemy });
|
|
|
+
|
|
|
+ spawnLocations.Add(new int[] { 32, 0, (int)ShipGeneratorObjectPoolType.BrokenLaser });
|
|
|
|
|
|
Add4(4, 0);
|
|
|
Add4(4, 5);
|
|
|
@@ -90,6 +122,8 @@ namespace Ships
|
|
|
spawnLocations.Add(new int[] { 16 + 32, 7, (int)ShipGeneratorObjectPoolType.FlyingEnemy });
|
|
|
spawnLocations.Add(new int[] { 17 + 32, 4, (int)ShipGeneratorObjectPoolType.FlyingEnemy });
|
|
|
|
|
|
+ spawnLocations.Add(new int[] { 32 + 32, 0, (int)ShipGeneratorObjectPoolType.BrokenLaser });
|
|
|
+
|
|
|
Add4(4 + 32, 0);
|
|
|
Add4(4 + 32, 5);
|
|
|
Add4Floor(4 + 32, -5);
|
|
|
@@ -113,7 +147,7 @@ namespace Ships
|
|
|
{
|
|
|
chunks[num] = new GameObject("chunk");
|
|
|
var chunk = chunks[num].AddComponent<Chunk>();
|
|
|
- PopulateTown(chunk);
|
|
|
+ PopulateWorld(chunk);
|
|
|
num++;
|
|
|
}
|
|
|
}
|
|
|
@@ -208,12 +242,41 @@ namespace Ships
|
|
|
|
|
|
private static List<int[]> spawnLocations = new List<int[]>();
|
|
|
private static System.Random random = new System.Random();
|
|
|
-
|
|
|
public static void PopulateTown(Chunk chunk)
|
|
|
{
|
|
|
var networkStuff = new GameObject[400];
|
|
|
networkStuffField.SetValue(chunk, networkStuff);
|
|
|
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ int temp = (int)tempField.GetValue(chunk);
|
|
|
+
|
|
|
+ networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("npcStorage"), new Vector3(248f + 4 * 0, -6.118f, 0.3f), Quaternion.identity, 0);
|
|
|
+ temp++;
|
|
|
+ networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("npc2103"), new Vector3(248f + 4 * 1, -6.118f, 0.3f), Quaternion.identity, 0);
|
|
|
+ temp++;
|
|
|
+ networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("npc/npcQuest"), new Vector3(248f + 4 * 3, -6.118f, 0.3f), Quaternion.identity, 0);
|
|
|
+ temp++;
|
|
|
+ }
|
|
|
+ catch (Exception e) { Core.logger.LogError(e); }
|
|
|
+
|
|
|
+ GameScript.endPortal[0] = (GameObject)Network.Instantiate((GameObject)Resources.Load("portal"), new Vector3(248f + 4 * 5, -6.118f, 0f), Quaternion.identity, 0);
|
|
|
+ GameScript.endPortalUA[0] = GameScript.endPortal[0].transform.GetChild(0).gameObject;
|
|
|
+ GameScript.endPortal[0].GetComponent<NetworkView>().RPC("Activate", RPCMode.All, new object[0]);
|
|
|
+ GameScript.endPortalUA[0].GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { Core.lastBiome, 0, 0 });
|
|
|
+
|
|
|
+ GameScript.endPortal[3] = (GameObject)Network.Instantiate((GameObject)Resources.Load("portal"), new Vector3(248f - 4 * 2, -6.118f, 0f), Quaternion.identity, 0);
|
|
|
+ GameScript.endPortalUA[3] = GameScript.endPortal[3].transform.GetChild(0).gameObject;
|
|
|
+ GameScript.endPortal[3].GetComponent<NetworkView>().RPC("Activate", RPCMode.All, new object[0]);
|
|
|
+ GameScript.endPortalUA[3].GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { 98, 0, 3 });
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void PopulateWorld(Chunk chunk)
|
|
|
+ {
|
|
|
+ var networkStuff = new GameObject[400];
|
|
|
+ networkStuffField.SetValue(chunk, networkStuff);
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
|
|
|
@@ -266,6 +329,9 @@ namespace Ships
|
|
|
case ShipGeneratorObjectPoolType.OldChest:
|
|
|
networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("obj/Ships/OldChest"), new Vector3(248f + 4 * e[0], -8f + 0.118f * 4 + 4 * e[1], 0.2f), Quaternion.identity, 0);
|
|
|
break;
|
|
|
+ case ShipGeneratorObjectPoolType.BrokenLaser:
|
|
|
+ networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("haz/Ships/LazerHazard"), new Vector3(248f + 4 * (e[0] + 0.5f), 4 * (e[1]), 0.2f), Quaternion.identity, 0);
|
|
|
+ break;
|
|
|
}
|
|
|
if (networkStuff[temp] != null)
|
|
|
temp++;
|
|
|
@@ -273,10 +339,10 @@ namespace Ships
|
|
|
}
|
|
|
catch (Exception e) { Core.logger.LogError(e); }
|
|
|
|
|
|
- GameScript.endPortal[3] = (GameObject)Network.Instantiate((GameObject)Resources.Load("portal"), new Vector3(248f + 4 * 38 + 128, -6.118f, 0f), Quaternion.identity, 0);
|
|
|
- GameScript.endPortalUA[3] = GameScript.endPortal[3].transform.GetChild(0).gameObject;
|
|
|
- GameScript.endPortal[3].GetComponent<NetworkView>().RPC("Activate", RPCMode.All, new object[0]);
|
|
|
- GameScript.endPortalUA[3].GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { 0, 0, 0 });
|
|
|
+ GameScript.endPortal[0] = (GameObject)Network.Instantiate((GameObject)Resources.Load("portal"), new Vector3(248f + 4 * 38 + 128, -6.118f, 0f), Quaternion.identity, 0);
|
|
|
+ GameScript.endPortalUA[0] = GameScript.endPortal[0].transform.GetChild(0).gameObject;
|
|
|
+ GameScript.endPortal[0].GetComponent<NetworkView>().RPC("Activate", RPCMode.All, new object[0]);
|
|
|
+ GameScript.endPortalUA[0].GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { Core.shipPlanet.GetID(), 0, 0 });
|
|
|
}
|
|
|
}
|
|
|
}
|