public override void SceneLoadLocalBegin(string map) { GameManager.instance.ChangeGameState(GameManager.GameState.PRE_GAME); DebugHUD.setValue("load state", "Loading scene"); FindObjectOfType <LobbyState>().HideDebugDraw = true; //display loading screen }
public void Firing() { if (muzzleFlash != null) { //StartCoroutine(MuzzleFlash()); muzzleFlash.Play(); } DebugHUD.setValue("muzzle flash", muzzleFlash.isPlaying); timeUntilCooldownBegins = CooldownDelay; Temperature += HeatPerShot; if (Temperature >= MaxTemperature) { IsOverheating = true; Temperature = MaxTemperature; player.LaserVisible = false; } else { if (RefreshRaycast()) { IPlayer target = GetTarget(); //Add in check for friendly fire here. if (target != null && target.Team != player.Team) { target.TakeDamage(DamagePerShot, target.Username, -SourceTransform.forward, WeaponID); } } player.MuzzlePoint = GunShotStartTransform.position; player.LaserEndpoint = endpoint; player.LaserVisible = true; } }
public void TakeDamage(MPlayerController.DamageInfo damageInfo) { if (!isServer) { DebugHUD.Debugg("TDmg not SRV"); return; } if (Invulnerable) { DebugHUD.Debugg("Invul"); return; } currentHealth -= damageInfo.amount; var testLocalObj = NetworkServer.FindLocalObject(damageInfo.netId); DebugHUD.Debugg("damage: " + damageInfo.amount + "src: " + (testLocalObj ? testLocalObj.name : "null")); if (currentHealth <= 0) { currentHealth = maxHealth; var damageSource = NetworkServer.FindLocalObject(damageInfo.netId); var player = damageSource.GetComponent <MPlayerController>(); if (player) { player.RpcGetAKill(); } //damageInfo.source.RpcGetAKill(); RpcRespawn(); } }
// Update is called once per frame void Update() { if (!tempSelectedUnit) { tempSelectedUnit = selector.SelectedUnit; } DebugHUD.setValue("Is dismissed", infoPanel.dismissButton.Dismissed); if (match) { updateGameInfo(); // if (selector.SelectedUnit) { // if (!selector.SelectedUnit.Equals(selectedUnit) || infoPanel.dismissButton.Dismissed) { //selectedUnit = selector.SelectedUnit; infoPanel.updateSelectedInfo(selectedUnit); // infoPanel.gameObject.SetActive(true); // infoPanel.dismissButton.Dismissed = false; // alreadyDismissed = false; // } // } else { //// infoPanel.gameObject.SetActive(false); // if (!alreadyDismissed) { // infoPanel.dismissButton.Dismissed = true; // alreadyDismissed = true; // } // } EndTurn.SetActive(match.MyTurn); } else { match = MatchManager.instance; displayJumpButtons(); } }
void Update() { timeleft -= Time.deltaTime; accum += Time.timeScale / Time.deltaTime; ++frames; // Interval ended - update GUI text and start new interval if (timeleft <= 0.0) { // display two fractional digits (f2 format) fps = accum / frames; string format = System.String.Format("{0:F2}", fps); string color; if (fps < 30) { color = "yellow"; } else if (fps < 10) { color = "red"; } else { color = "green"; } DebugHUD.setValue("FPS", "<color=" + color + ">" + format + "</color>"); timeleft = updateInterval; accum = 0.0F; frames = 0; } }
void RpcRecordScore(Scoreboard.LedgerEntry le) { setLedgerLocal(le); scoreboard.UpdateDisplay(le); DebugHUD.Debugg("record Score: " + le.ToString() + " is cli: " + isClient); player.testGetNewScore(le); }
void Update() { DebugHUD.setValue("IsSever", BoltNetwork.isServer); if (BoltNetwork.isClient) { DebugHUD.setValue("ping", BoltNetwork.server.PingNetwork); } DebugHUD.setValue("username", GameManager.instance.CurrentUserName); }
void CmdEquip(int wIndex) { DebugHUD.Debugg("cmd equip: " + wIndex); for (int i = 0; i < _svLookup.Count; ++i) { _svLookup[i] = _svLookup[i].CloneEquiped(i == wIndex); _svLookup.Dirty(i); } }
internal void Start() { _rb = GetComponent <Rigidbody2D>(); _mask = LayerMask.GetMask("Platforms"); _velocity = Vector2.right; _hud = new DebugHUD(DebugMaterial); Unpause(); }
void Update() { if (Physics.Raycast(SourceTransform.position, SourceTransform.forward, out hitInfo, float.PositiveInfinity, shootableLayers)) { IPlayer hitplayer = hitInfo.transform.GetComponent <AbstractPlayer>(); if (hitplayer != null) { if (!assisting) { AimAssist(hitplayer); } } else { if (assisting) { ResetAimAssist(); } } } DebugHUD.setValue("Gun temp", Temperature); DebugHUD.setValue("Gun overheated", IsOverheating); if (timeUntilCooldownBegins > 0f) { timeUntilCooldownBegins = Mathf.Max(0f, timeUntilCooldownBegins - Time.deltaTime); } if (timeUntilCooldownBegins <= 0f && Temperature >= 0f) { Temperature -= CooldownRate * Time.deltaTime * (IsOverheating ? OverheatedCooldownMultiplier : 1.0f); if (Temperature <= 0f) { Temperature = 0f; IsOverheating = false; } } // if (timeUntilNextShot > 0f) { // timeUntilNextShot = Mathf.Max(0f, timeUntilNextShot - Time.deltaTime); // return; // } if (IsOverheating) { player.LaserVisible = false; return; } if (Input.GetButton("Fire1")) { player.LaserVisible = true; Firing(); } else { player.LaserVisible = false; } }
internal void BeDead() { if (isDead) { return; } DebugHUD.Debugg("start dead"); isDead = true; arsenal.loseAll(); StartCoroutine(goToWaitingRoom()); }
public void UpdateDebugDraw <T>(T obj) { if (hud_initialised_) { if (debug_draw_ == null) { debug_draw_ = new DebugHUD(); debug_draw_.Init(); } debug_draw_.Update(obj); } }
//FixedUpdate called at a fixed framerate of 60 //SimulateOwner is called from FixedUpdate, but only for the owner of the object public override void SimulateOwner() { float timeSinceThrown = StartingFuseTime - FuseTimeRemaining; DebugHUD.setValue("DetonateTime", DetonateTime); DebugHUD.setValue("ServerTime", BoltNetwork.serverTime); DebugHUD.setValue("FuseTimeRemaining", FuseTimeRemaining); //Self-destroy object after its fuse is done. if (FuseTimeRemaining <= 0f) { Detonate(); } }
public void SetDamageSourceId(NetworkInstanceId _netId) { if (!isServer) { DebugHUD.Debugg("not server set dmg src id"); return; } DebugHUD.Debugg("setting dmg "); damage = new MPlayerController.DamageInfo() { amount = collisionDamage, netId = _netId }; }
/// <summary> /// update just contains some non-essential debug code /// </summary> void Update() { var t = GetTileAtMouse(); DebugHUD.setValue("TileUnderMouse", t as Tile); if (t != null) { DebugHUD.setValue("UnitsInSightOfTile", "{" + string.Join(", ", t.UnitsInSight.ToArray()) + "}"); } else { DebugHUD.setValue("UnitsInSightOfTile", "N/A"); } }
private IEnumerator goToWaitingRoom() { suspendFixedUpdateMovement = true; respawner.placeInWaitingRoom(this, () => { DebugHUD.Debugg("wroom callback"); teleportToRespawnLocation(() => { isDead = false; }); }); yield return(new WaitForSeconds(.1f)); suspendFixedUpdateMovement = false; }
public override void SceneLoadLocalDone(string map) { //instantiate the player BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.PlayerPrefab); PlayerState ps = entity.GetComponent <PlayerState>(); ps.Name = GameManager.instance.CurrentUserName; //set their name ps.Team = GameManager.instance.Lobby.GetTeamLookup()[GameManager.instance.CurrentUserName]; if (!BoltNetwork.isServer) { entity.AssignControl(BoltNetwork.server); //this line is completely useless and should be removed } DebugHUD.setValue("load state", "Scene loaded, unsynced"); //the scene has now been loaded for this player, but we have not synchronized the players yet }
void Start() { if (instance != null) { Destroy(gameObject); } transform.position = Vector3.up; text = GetComponent <GUIText>(); text.alignment = TextAlignment.Left; text.anchor = TextAnchor.UpperLeft; text.richText = true; text.enabled = Application.isEditor || Debug.isDebugBuild; DontDestroyOnLoad(this); instance = this; }
/// <summary> /// State updates. /// </summary> void Update() { if (this.dead) { return; } // TODO: fix this spelling mistake in the code whereever it originated. DebugHUD.setValue("IsServer", BoltNetwork.isServer); if (BoltNetwork.isClient) { //DebugHUD.setValue("ping", BoltNetwork.server.PingNetwork); } DebugHUD.setValue("username", GameManager.instance.CurrentUserName); }
// Update is called once per frame void Update() { DebugHUD.setValue("laser endpoint", player.LaserEndpoint); line.enabled = player.LaserVisible; line.SetPosition(0, player.MuzzlePoint); line.SetPosition(1, player.LaserEndpoint); // curFadeTime += Time.deltaTime; // if(curFadeTime >= FadeTime){ // Destroy(this.gameObject); // return; // } // float fadePercent = curFadeTime / FadeTime; // float adjustedFade = FadeCurve.Evaluate(fadePercent); // // Color newColor = BeamColor; // newColor.a = adjustedFade; // line.SetColors(newColor, newColor); }
public void PostSignificanceFunction(ManagedObjectInfo objectInfo, float oldSignificance, float significance, bool bUnregistered) { if (significance > 0f) { //提高 AI tick 频率,设置粒子发射器等等 //设置 lod level } else { //关闭 AI tick,关闭粒子等 //关闭 lod } #if UNITY_EDITOR Transform significanceActor = (Transform)objectInfo.GetObject(); DebugHUD textMesh = significanceActor.GetComponentInChildren <DebugHUD>(); textMesh.ShowDebugView(significance, debugDisplayInfo.ShouldDisplayDebug); #endif }
//Sync Event handler (client and server) public override void OnEvent(SyncEvent evnt) { Debug.Log("Sync event recieved"); StartTime = evnt.StartTime; if (evnt.StartTime < BoltNetwork.serverTime) { if (!BoltNetwork.isServer) { BoltNetwork.server.Disconnect(new DisconnectReason("Sync Failure", "Failed to synchronize with the server in time")); } else { Debug.LogWarning("Server recieved sync message that is before the current time?"); } } DebugHUD.setValue("load state", "Synch message recieved"); running = true; //hide loading screen }
void Update() { if (!running) { return; } if (BoltNetwork.serverTime >= StartTime) { DebugHUD.setValue("load state", "Game started"); //allow the player to move running = false; Destroy(this); GameManager.instance.ChangeGameState(GameManager.GameState.IN_GAME); } else { DebugHUD.setValue("load state", "Sync message recieved, game starts in " + (StartTime - BoltNetwork.serverTime)); } DebugHUD.setValue("server time", BoltNetwork.serverTime); DebugHUD.setValue("start time", StartTime); }
private void startLocalOrNot() { if (!animState) { animState = GetComponent <PlayerAnimState>(); } if (!rb) { rb = GetComponent <Rigidbody>(); } if (!collidr) { collidr = GetComponent <Collider>(); } if (!aud) { aud = GetComponent <AudioSource>(); } if (!debugHUD) { debugHUD = FindObjectOfType <DebugHUD>(); } }
private void OnCollisionEnter(Collision collision) { if (collisionDealsDamage) { var health = collision.gameObject.GetComponentInParent <Health>(); // collision.collider.GetComponent<Health>(); if (health) { DebugHUD.Debugg("BulletColl " + collision.collider.name); health.TakeDamage(damage); GetComponent <Collider>().enabled = false; GetComponent <Rigidbody>().isKinematic = true; GetComponent <Renderer>().enabled = false; if (explodeParticles) { explodeParticles.Play(); Destroy(gameObject, explodeParticles.main.duration); } else { Destroy(gameObject); } } } }
// Update is called once per frame void Update() { string stateString = ""; if (inputDisabled) { stateString += "Input Disabled"; } else { if (Input.GetKeyDown(KeyCode.M)) { PanWhenMouseAtEdge = !PanWhenMouseAtEdge; } //DEBUG if (Input.GetKeyDown(KeyCode.Alpha0)) { AnimateMove(Vector3.zero, 5f); } DebugHUD.setValue("Mouse X", Input.GetAxis("Mouse X")); DebugHUD.setValue("Mouse Y", Input.GetAxis("Mouse Y")); bool up = Input.GetKey(KeyCode.UpArrow); bool down = Input.GetKey(KeyCode.DownArrow); bool left = Input.GetKey(KeyCode.LeftArrow); bool right = Input.GetKey(KeyCode.RightArrow); bool shift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); bool leftClick = Input.GetMouseButton(2); bool rightClick = Input.GetMouseButton(1); float x = 0f; float y = 0f; if (shift) { if (up) { y += 1; } if (down) { y -= 1; } if (left) { x -= 1; } if (right) { x += 1; } stateString += "Keyboard Orbit, "; } if (leftClick && !shift) { x += Input.GetAxis("Mouse X"); y -= Input.GetAxis("Mouse Y"); stateString += "Mouse Orbit, "; } ShiftOribitAngles(x, y); DoScrollZoom(); DebugHUD.setValue("OrbitX", x); DebugHUD.setValue("OrbitY", y); if (rightClick) { MoveAlongBoardNonNormalized(new Vector3(Input.GetAxis("Mouse X"), 0f, Input.GetAxis("Mouse Y"))); stateString += "Mouse Pan, "; } if (PanWhenMouseAtEdge && !leftClick && !rightClick) { Vector3 mousePosition = Input.mousePosition; if (mousePosition.y > (Screen.height - MousePanBounds)) { up = true; } if (mousePosition.y < MousePanBounds) { down = true; } if (mousePosition.x > (Screen.width - MousePanBounds)) { right = true; } if (mousePosition.x < MousePanBounds) { left = true; } stateString += "Checking Edges, "; } if ((up || down || left || right) && !shift) { Vector3 movement = Vector3.zero; if (up) { movement += Vector3.forward; } if (down) { movement += Vector3.back; } if (left) { movement += Vector3.left; } if (right) { movement += Vector3.right; } MoveAlongBoardNormalized(movement); stateString += "Panning, "; } } DebugHUD.setValue("Camera States", stateString); }
public void dbugWithName(string s) { DebugHUD.Debugg(string.Format("{0}: {1} {2}", playerData.displayName, cliServer, s)); }
public void moveCharacter(Vector2 inputVector) { //Debouncing for cornering controls if (debounceTime < shiftDebounce) { debounceTime += Time.fixedDeltaTime; } if (firstLerp || secondLerp) { lerp(); return; } //Vector2 inputVector = GetInput(); DebugHUD.setValue("last normal", lastNormal); float movementSpeed = character.velocity.sqrMagnitude; float desiredSpeed = calcupateDesiredSpeed(inputVector); Vector3 worldSpaceVector = pCamera.transform.TransformDirection(inputVector.x, inputVector.y, 0); //Zero movement on axis if necessary //New velocity cancelling code. zeroMovement(inputVector); Vector3 moveFromLast = Vector3.ProjectOnPlane(worldSpaceVector, lastNormal); if (movementSpeed < maxVelocity * maxVelocity) { RaycastHit hit; //Ok so we agree this works, this is the on a surface without extreme angles if (Physics.SphereCast(character.position + (desiredSpeed * moveFromLast * Time.deltaTime), .1f, -lastNormal, out hit, grabDistance + character.GetComponent <SphereCollider>().radius, moveableLayers)) { Vector3 moveVector = Vector3.ProjectOnPlane(worldSpaceVector, hit.normal); if (Vector3.Dot(hit.normal, lastNormal) >= Mathf.Cos(5 * Mathf.Deg2Rad)) { character.AddForce(moveVector * desiredSpeed * Time.fixedDeltaTime * accelerationFactor, ForceMode.Impulse); } else { // Debug.Log("different normal from surface"); character.AddForce(-character.velocity + Quaternion.AngleAxis(Vector3.Angle(lastNormal, hit.normal), Vector3.Cross(lastNormal, hit.normal)) * character.velocity, ForceMode.Impulse); character.AddForce(moveVector * desiredSpeed * Time.fixedDeltaTime * accelerationFactor, ForceMode.Impulse); } if (Vector3.Dot(hit.normal, lastNormal) < Mathf.Cos(90 * Mathf.Deg2Rad)) { lastNormal = hit.normal; lastPoint = hit.point; } } //This would handle transitions between surfaces and not allowing the player to go over the edge else { // Debug.Log("Lost surface"); //First handle not going off the edge, easy, just move in opposite of desired direction. Vector3 moveVector = Vector3.ProjectOnPlane(lastPoint - character.position, lastNormal); character.AddForce(-character.velocity + (.5f * moveVector), ForceMode.Impulse); //Now deal with rounding corners. We're going to try a press button to move around corner approach. //TODO: Use only the actual input system. //if (Input.GetKey(KeyCode.LeftShift) && debounceTime >= shiftDebounce) //{ // shiftDebounce = 0; // roundCorner(inputVector, desiredSpeed); //} } } }
private void debugLE(string s, Scoreboard.LedgerEntry le) { DebugHUD.Debugg(string.Format("{0} : {1} {2}", (isClient ? "CLI" : "SRV"), s, le.ToString())); }
private void Start() { gm = GetComponent <GridManager>(); // Setup level characteristics for GridManager if (currentLevel == 0) { currentLevel = 1; } if (overrideLevelData) { LevelData newLevelData = new LevelData(inspectorGridWidth, inspectorGridHeight, 4, 0); gm.ReceiveLevelData(newLevelData.LevelTable[0]); } else { gm.ReceiveLevelData(levelData.LevelTable[LevelDataIndex]); } gm.Init(); // Setup GridObjectManager gom = GetComponent <GridObjectManager>(); if (overrideSpawnSequence.Length > 0) { for (int i = 0; i < overrideSpawnSequence.Length; i++) { gom.insertSpawnSequences.Add(overrideSpawnSequence[i].Clone()); } } if (VerboseConsole) { debugHUD = GameObject.FindGameObjectWithTag("Debug HUD").GetComponent <DebugHUD>(); } display = GameObject.FindGameObjectWithTag("Game Display").GetComponent <GameDisplay>(); // Setup Player Vector2Int startLocation = new Vector2Int(0, 0); if (overrideSpawnSequence.Length > 0) { startLocation = overrideSpawnSequence[0].playerSpawnLocation; } GameObject player = Instantiate(gom.playerPrefab, gm.GridToWorld(startLocation), Quaternion.identity); if (VerboseConsole) { Debug.Log(player.name + " has been instantiated."); } if (VerboseConsole) { Debug.Log("Adding Player to Grid."); } gm.AddObjectToGrid(player, startLocation); this.player = player.GetComponent <Player>(); this.player.currentWorldLocation = gm.GridToWorld(startLocation); this.player.targetWorldLocation = gm.GridToWorld(startLocation); if (VerboseConsole) { Debug.Log("Player successfully added to Grid."); } this.player.NextLevel(levelData.LevelTable[LevelDataIndex].jumpFuelAmount); // Initialize Game Object Manager now that player exists gom.Init(); this.player.OnPlayerAdvance += OnTick; }