private void RpcDoneDigging() { //Debug.Log("done digging server = " + isServer); BuildLog.writeLog("done digging server = " + isServer); MapManager.manager.doneDigging = true; }
public void finishMapLocally() { mapDoneLocally = true; SmoothVoxels(); CaveManager.manager.placeCavePortalsArtefacts(); setUpShredManager(); GetComponent <MapAssetManager>().genAssets(); BuildLog.writeLog("Map finished locally - sent cmd pass message that map was completed"); Debug.Log("Map finished locally on (server = " + isServer + ")"); }
public void CmdPassMessage(string name, string message) { if (namedEvents.ContainsKey(name))//even server side events are stored locally { BuildLog.writeLog("passing message " + message + " on server event: " + name); //Debug.Log("passing message " + message + " on server event: " + name); namedEvents[name].passMessage(message); } else { Debug.LogError("no such named event as: " + name); BuildLog.writeLog("no such named event as: " + name); } }
void FixedUpdate() { Vector3 forward = getFoward(); if (!forward.Equals(Vector3.zero) && !transform.position.Equals(Vector3.zero)) { transform.rotation = Quaternion.LookRotation(forward, -grav.getDownDir()); } doMovement(); doRotations(); if (transform.position.magnitude > MapManager.mapSize * 3.5f && MapManager.manager != null && MapManager.manager.mapDoneLocally) //if you fall out come back in { //transform.position = new Vector3(0, -10, 0); player.spawnOnMap(); rb.velocity = Vector3.zero; } if (grav == null) { grav = GetComponent <Gravity>(); } if (health == null) { health = GetComponent <NetHealth>(); } // TODO this shouldn't be here if (grav != null && !grav.inSphere && health != null && health.getHealth() > 0 && MapManager.manager != null && MapManager.manager.mapDoneLocally && TeamManager.singleton != null && !TeamManager.localPlayer.spawned) { //should be in sphere but isnt if (GameEventManager.clockTime > 250) { //enough time has passed that the origonal spawning must have failed Debug.LogError("having to respawn players manually after 250 seconds from game start"); BuildLog.writeLog("having to respawn players manually after 250 seconds from game start"); grav.inSphere = true; TeamManager.singleton.CmdSpawnAllPlayers(); } } }
/// <summary> /// Repeatedly counts the number of voxels currently spawned and once all voxels are spawned calls voxelsLoaded /// </summary> /// <returns></returns> IEnumerator CountSpawnedVoxels() { yield return(new WaitForSecondsRealtime(5));//accounts for spawn wait bool loaded = false; int maxTries = 60; float waitTime = 2f; int count = 0; while (!loaded && count < maxTries) { yield return(new WaitForSeconds(waitTime)); loaded = MapManager.manager.spawnedVoxels.Count == 768 * Math.Pow(2, MapManager.splits) && (MapManager.manager.doneDigging || isServer); count++; } if (loaded) { Debug.Log("(server=" + isServer + ") voxels spawned correctly ; waited : " + (count * waitTime) + " seconds "); BuildLog.writeLog("(server=" + isServer + ") voxels spawned correctly ; waited : " + (count * waitTime) + " seconds "); if (isServer) { StartCoroutine(MapManager.manager.allSurfaceVoxelsLoadedServerSide()); } else { StartCoroutine(MapManager.manager.allVoxelsLoadedClientSide()); } MapManager.SmoothVoxels(); } else { BuildLog.writeLog("waited " + (maxTries * waitTime) + " seconds and not all voxels have been spawned - only found " + MapManager.manager.spawnedVoxels.Count + " unique column id's; should be: " + 768 * Math.Pow(2, MapManager.splits) + " manager done digging?: " + MapManager.manager.doneDigging + " condition1: " + (MapManager.manager.spawnedVoxels.Count == 768 * Math.Pow(2, MapManager.splits)) + " condition2: " + ((MapManager.manager.doneDigging || isServer)) + "\n "); Debug.LogError("waited " + (maxTries * waitTime) + " seconds and not all voxels have been spawned - only found " + MapManager.manager.spawnedVoxels.Count + " unique column id's; should be: " + 768 * Math.Pow(2, MapManager.splits) + " manager done digging?: " + MapManager.manager.doneDigging); } }
public void passMessage(string name, string message) { if (namedEvents.ContainsKey(name))//even server side events are stored locally { GameEvent ev = namedEvents[name]; if (ev.serverOnly) { //Debug.Log("locally passing message " + message + " to server only event: " + name); BuildLog.writeLog("locally passing message " + message + " to server only event: " + name); CmdPassMessage(name, message); } else { namedEvents[name].passMessage(message); } } else { Debug.LogError("no such named event as: " + name); } }
public override bool hook() { if (Time.time > 400) { Debug.Log("giving up waiting for all maps to complete - ending waiting and beginning spawn/ shredding process"); BuildLog.writeLog("giving up waiting for all maps to complete - ending waiting and beginning spawn/ shredding process"); return(true); } if (noPlayers > 0) { if (completedMaps == noPlayers) { Debug.Log("all maps completed!"); return(true); } else { if (completedMaps > noPlayers) { Debug.LogError("error with map completed reporting - claims " + completedMaps + " completed maps"); } return(false); } } else { Debug.LogError("checking wait on map hook - no players = 0"); noPlayers = TeamManager.playerCount; triesLeft--; if (triesLeft < 0) { Debug.LogError("waited to find players - did not find any"); return(true); } return(false); } }
private void loadNeighboursMap() { BuildLog.writeLog("loading neighbours map \n"); bool found = false; string readText = ""; try { readText = File.ReadAllText("Assets/Resources/Voxels/split" + splits + ".neiMap"); if (readText != null && readText.Length > 0) { found = true; BuildLog.writeLog("found map in usual dir"); } } catch { } if (!found) { BuildLog.isBuild = true; BuildLog.writeLog("did not find neighbours map in file dir - trying to move back in directory"); try { readText = File.ReadAllText("../Assets/Resources/Voxels/split" + splits + ".neiMap"); if (readText != null && readText.Length > 0) { BuildLog.writeLog("found map by going back in dir"); found = true; } } catch { } } if (!found) { BuildLog.writeLog("did not find neighbours map in prev dir - trying build folder"); try { readText = File.ReadAllText("split" + splits + ".neiMap"); if (readText != null && readText.Length > 0) { BuildLog.writeLog("found map in build folder"); found = true; } } catch { } } if (found) { BuildLog.writeLog("reading neighbours map"); string[] vs = readText.Split('|'); for (int i = 0; i < vs.Length; i++) { neighboursMap[i] = new HashSet <int>(); string[] ns = vs[i].Split(','); foreach (String n in ns) { neighboursMap[i].Add(int.Parse(n)); } } BuildLog.writeLog("loaded neighbours map"); } else { //gen and save foreach (Voxel vox in voxels[0].Values) { neighboursMap[vox.columnID] = new HashSet <int>(); vox.gatherAdjacentNeighbours(); } String map = ""; for (int v = 0; v < voxels[0].Count; v++) { foreach (int n in neighboursMap[v]) { map += n + ","; } map = map.Substring(0, map.Length - 1) + "|"; } map = map.Substring(0, map.Length - 1); BuildLog.writeLog("generating neighbours map"); File.WriteAllText("Assets/Resources/Voxels/split" + splits + ".neiMap", map); Debug.Log("generated and saved neighbours map to file"); } }