public void CreateExample() { if (dataFolder == "") { return; } string path = Path.Combine(dataFolder, "Example"); if (!Directory.CreateDirectory(path).Exists) { DebugText.LogError("Could not create Example folder"); } else { try { System.IO.File.WriteAllText(Path.Combine(path, "scenes.json"), exampleScenario.ToJson()); System.IO.File.WriteAllText(Path.Combine(path, "instructions.txt"), exampleScenario.instructions); for (int i = 0; i < exampleScenario.images.Length; i++) { if (exampleScenario.images[i].name != "" && exampleScenario.images[i].image != null) { SaveImage(exampleScenario.images[i].image, Path.Combine(path, exampleScenario.images[i].name)); } } } catch (Exception e) { DebugText.LogError("Could not save example scenario (" + e.GetType().ToString() + ")"); } } RefreshFolder(); DebugText.Log("Created Example Scenario"); }
public static void Update() { ProcessDone(); timer += Time.unscaledDeltaTime; if (timer >= 1f) { timer -= 1f; solved = acc; acc = 0; } try { DebugText.Log(pending.Count + " / " + MAX_PENDING + " pathfinding operations pending, " + hasPending.Count + " unique keys.", Color.Lerp(Color.green, Color.red, pending.Count / (float)MAX_PENDING)); if (times.Count > 0) { DebugText.Log("Solved per second: " + solved + " <--", Color.yellow); DebugText.Log("Latest path time: " + times[times.Count - 1] + "ms <--", Color.yellow); DebugText.Log("Average path time (" + times.Count + " samples): " + Mathf.RoundToInt((float)times.Average()) + "ms <--", Color.yellow); DebugText.Log("Lowest path time (" + times.Count + " samples): " + times.Min() + "ms <--", Color.yellow); DebugText.Log("Highest path time (" + times.Count + " samples): " + times.Max() + "ms <--", Color.yellow); DebugText.Log(finished.Count + " processed requests pending for application.", Color.yellow); } } catch { // Gotta catch em' all! } }
public void SetVideo(string path, string ending, Action <string> actionHandler, float delay, Action onLoaded) { if (gameObject.activeSelf) { StopAllCoroutines(); } gameObject.SetActive(true); DebugText.Log("Loading Video File"); player.url = new Uri(path, UriKind.Absolute).AbsoluteUri; player.Play(); this.onLoaded = onLoaded; this.timeToStart = Time.time + delay; if (ending == "loop") { player.isLooping = true; } else { player.isLooping = false; if (ending != "") { action = ending; onEnding = actionHandler; } } }
private uint CastRay(Vector3 pos, Quaternion rot, out int hitId) { hitId = -1; uint hitmask = 0; DrawRay(pos, rot); //RaycastHit raycasthit; int hitcount = Physics.RaycastNonAlloc(new Ray(pos, rot * (Vector3.forward)), hits); for (int i = 0; i < hitcount; i++) { NetworkSyncTransform hitNST = hits[i].collider.transform.root.GetComponent <NetworkSyncTransform>(); if (hitNST == null) { continue; } ((int)(hitNST.NstId)).SetBitInMask(ref hitmask, true); } //Debug.Log(hitmask.PrintBitMask()); DebugText.Log(hitmask.PrintBitMask() + " INIT", true); return(hitmask); }
void OnLoopPoint(VideoPlayer vp) { DebugText.Log("Video reached its end"); if (onEnding != null) { onEnding(action); } }
public override void OnClientDisconnect(NetworkConnection conn) { base.OnClientDisconnect(conn); DebugText.Log("Disconnected! Reconnecting..."); StopMatchMaker(); StartMatchMaker(); Begin(); }
public static void LogOnScreen(string message) { DebugText debugText = DebugText.instance; if (debugText == null) { debugText = DebugText.Create(); } debugText.Log(message); }
public void Update() { timer += Time.unscaledDeltaTime; if (timer >= 1f) { timer -= 1f; TranslationsPerSecond = Translation.TranslationCounter; Translation.TranslationCounter = 0; } DebugText.Log("Current Language: " + Translation.GetCurrentLanguageVerbose()); DebugText.Log("Translations Per Second: ~" + TranslationsPerSecond); }
/// <summary> /// When a custom message is received, the OnCustomMsgRcvEvent is fired. Note that the rotations will only be correct if you have the NST set to update /// rotations on events. If it is set to 'changes only' these rotations values will be zero. /// </summary> private static void OnCustomMsgRcv(NetworkConnection ownerConn, byte[] bytearray, NetworkSyncTransform shooterNst, Vector3 pos, List <GenericX> positions, List <GenericX> rotations) { //For this example we fired locally already when the custom message was sent (with OnCustomMsgSend). Firing again here on the local player would cause repeat fire events. //Note however that code for the local player can be added here to sync the projectile with the server, by adding a projectileID to your custom events. Weapon wpn = shooterNst.GetComponent <Weapon>(); PlayerFireCustomMsg weaponFireMsg = bytearray.DeserializeToStruct <PlayerFireCustomMsg>(); if ((WeaponType)weaponFireMsg.weaponId == WeaponType.Bullet) { if (!shooterNst.isLocalPlayer) { wpn.FireBullet(pos, rotations[0], weaponFireMsg); } } // Hitscan arrive on server/other clients else if ((WeaponType)weaponFireMsg.weaponId == WeaponType.Hitscan) { //DebugText.Log(weaponFireMsg.hitmask.PrintBitMask() + " RCV " + (WeaponType)weaponFireMsg.weaponId); uint confirmedHitmask = 0; // Draw the graphic if this isn't the local player if (!shooterNst.isLocalPlayer) { wpn.DrawRay(pos, rotations[0]); } // Server needs to test if this was a hit. if (NetworkServer.active) { for (int i = 0; i < 32; i++) { if (weaponFireMsg.hitmask.GetBitInMask(i) == false) { continue; } NetworkSyncTransform hitNst = NetworkSyncTransform.GetNstFromId((uint)i); bool hit = hitNst.TestHitscanAgainstRewind(ownerConn, new Ray(pos, (Quaternion)rotations[0] * Vector3.forward)); if (hit) { ((int)hitNst.NstId).SetBitInMask(ref confirmedHitmask, true); } } DebugText.Log("Rewind Confirmation Mask : \n" + confirmedHitmask.PrintBitMask(), true); } } }
public override void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo) { base.OnMatchCreate(success, extendedInfo, matchInfo); if (success) { DebugText.Log("Match created!"); } else { DebugText.Log("FAILED OnMatchCreate: " + extendedInfo); } }
/// <summary> /// Solicita ao servidor os dados da partida correspondente a string /// os dados seram armazenados na ServerCommunication. /// Apos receber os dados a partida interativa é iniciada. /// </summary> public void SendGameRequestInteractive(InputField input) { string game = input.text; if (ServerCommunication.JoinGame(game)) { SceneManager.LoadScene("Interactive"); loadingScreen.SetActive(true); } else { DebugText.Log("Falha na conexão.", Color.red, 3); } }
public void Update() { if (World.Instance == null) { return; } CompileChunks(); UpdateAndRemoveChunks(); LoadChunks(); DebugText.Log(Objects.Count + " Active Objects"); DebugText.Log(RequestedChunks.Count + " Requested Chunks."); }
public void Update() { if (isServer) { time += Time.deltaTime / SecondsPerDay; } DebugText.Log("Time: " + GetTimeFull()); if (dayTracker != GetDay()) { dayTracker = GetDay(); DayChangedEvent.Invoke(); } }
public override void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo) { base.OnMatchJoined(success, extendedInfo, matchInfo); if (success) { DebugText.Log("Match joined!"); if (numPlayers == 0) { //DebugText.Log("No one here, start match!"); } } else { DebugText.Log("FAILED OnMatchJoined: " + extendedInfo); } }
void Dump() { string s = ""; for (int i = 0; i < 9; i++) { for (int j = 8; j >= 0; j--) { s += (table[i * 9 + j] == null) ? "0" : table[i * 9 + j].ID.ToString(); s += ','; } //dbg.Log(s); //s = ""; s += '\n'; } dbg.Log(s); }
public override void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matches) { base.OnMatchList(success, extendedInfo, matches); if (success) { if (matches.Count == 0) // no match available { matchMaker.CreateMatch(MATCH_NAME, 10, true, "", "", "", ELO_SCORE, REQUEST_DOMAIN, OnMatchCreate); } else { print("Found " + matches.Count); matchMaker.JoinMatch(matches[0].networkId, "", "", "", ELO_SCORE, REQUEST_DOMAIN, OnMatchJoined); } } else { DebugText.Log("FAILED OnMatchList: " + extendedInfo); } }
void Prepared(VideoPlayer vp) { DebugText.Log("Video Loaded"); if (Time.time > this.timeToStart) { if (onLoaded != null) { onLoaded(); } vp.Play(); } else { vp.Stop(); StartCoroutine(Utils.RunLater(() => { if (onLoaded != null) { onLoaded(); } vp.Play(); }, timeToStart - Time.time)); } }
public void Update() { if (RequestGear) { // Request the gear for this player. if (!isServer) { Player.Local.NetUtils.CmdRequestGear(this.gameObject); } RequestGear = false; } gameObject.name = Name; DebugText.Log("[" + Name + " - " + Team + "] @ " + transform.position.ToString("F0"), Color.cyan); // If this is the local player, load the chunks around them. if (isLocalPlayer) { RectInt bounds = World.Instance.TileMap.GetCameraChunkBounds(); int chunkSize = World.Instance.TileMap.ChunkSize; int x = bounds.xMin / chunkSize; int y = bounds.yMin / chunkSize; int endX = bounds.xMax / chunkSize; int endY = bounds.yMax / chunkSize; AO.CancelAllRequests(); for (int X = x; X < endX; X++) { for (int Y = y; Y < endY; Y++) { AO.RequestChunk(X, Y); } } } }
public void InitCards(string strInit) { if (_hasInit) { return; } _hasInit = true; DebugText.Log("Init Cards " + strInit); int i = 0; var listLoc = new List <EatLocation>(EatLocation.Presets.Values); var listIndex = new List <int>(); string[] tok = strInit.Split('|'); foreach (string s in tok) { listIndex.Add(int.Parse(s)); } foreach (var index in listIndex) { _listCard[i].Setup(listLoc[index]); ++i; if (i >= _listCard.Count) { break; } } _stackCard.Push(_listCard[2]); _stackCard.Push(_listCard[1]); _stackCard.Push(_listCard[0]); _initialNumCards = _listCard.Count; _coroutine = StartCoroutine(DoTimer()); }
public static bool Save(string path, string filename, AudioClip clip) { if (!filename.ToLower().EndsWith(".wav")) { filename += ".wav"; } var filepath = Path.Combine(path, filename); Debug.Log(filepath); DebugText.Log(filepath, Color.green, 10); // Make sure directory exists if user is saving to sub dir. Directory.CreateDirectory(Path.GetDirectoryName(filepath)); using (var fileStream = CreateEmpty(filepath)) { ConvertAndWrite(fileStream, clip); WriteHeader(fileStream, clip); } return(true); // TODO: return false if there's a failure saving the file }
public void Update() { DebugText.Log(Chunk.InstanceCount + " chunks instantiated."); }
public void Update() { int x = (int)InputManager.GetMousePos().x; int y = (int)InputManager.GetMousePos().y; if (Input.GetKey(KeyCode.E)) { if (isServer) { Furniture f = World.Instance.Furniture.GetFurnitureAt(x, y); if (f != null) { Destroy(f.gameObject); } } if (CanPlaceTile(x, y)) { SetTile(null, x, y); } } if (isServer && Input.GetKeyDown(KeyCode.H)) { Pawn.SpawnPawn("Caveman", InputManager.GetMousePos()); } if (!DebugText._Instance.Active) { return; } if (isServer) { int chunks = 0; int count = 0; foreach (int index in PendingOperations.Keys) { if (AnyPendingOperationsFor(index)) { chunks++; } else { continue; } count += PendingOperations[index].Count; } DebugText.Log(count + " pending tile operations over " + chunks + " chunks."); if (Saving) { DebugText.Log("Saving '" + Name + "' ... ", Color.green); DebugText.Log("Chunks Pending: " + ChunksLeftToSave, Color.green); DebugText.Log("Tile Ops Pending: " + OperationsPendingInSave, Color.green); } } DebugText.Log(loading.Count + " chunks are loading."); DebugText.Log(unloading.Count + " chunks are unloading."); }
void OnDropped(VideoPlayer vp) { DebugText.Log("Video Frame Dropped"); }
public void Update() { DebugText.Log("{0} pending tile/furniture placement requests.".Form(Pending.Count)); }
public void Update() { DebugText.Log(furniture.Count + " furniture placed throughout the world."); }
void OnStarted(VideoPlayer vp) { DebugText.Log("Video Started Playing"); }