private void UpdateLog() { StringBuilder sb = new StringBuilder("version:" + bs.settings.version); if (!bs._Loader.ownSite) { sb.Append("a"); } if (errorCount > 0) { sb.Append(" errors:" + errorCount); } if (isDebug) { sb.Append(" Debug"); } if (isDebug && !online) { sb.Append(" offline"); } LogScreen(sb.ToString()); if (Input2.GetKey(android ? KeyCode.Alpha4 : KeyCode.F4) && Input2.GetKeyDown(android ? KeyCode.Alpha6 : KeyCode.F6)) { consoleWindow.enabled = !consoleWindow.enabled; } //print(PhotonNetwork.connectionStateDetailed); sbuilder.Append(sbuilder2); if (log) { log.text = sbuilder.ToString(); } sbuilder = new StringBuilder(); }
public virtual void Update() { if (pl.IsMine) { var mb = Input2.GetKey(KeyCode.Mouse1) && _Game.started && (bullets > 0 || isDebug) && !room.disableRockets && !win.active; if (mb != shooting && shootTm > shootInterval) { pl.CallRPC(pl.SetShoot, mb); } } }
//public new void print(object s) //{ // _Loader.sb.AppendLine(s + ""); //} public bool UpdateInput(CarControl Car, bool reverseRequiresStop, bool brakeRelease) { if (!bot && IsMine && nitro <= 0) { unpressKey.Add(KeyCode.LeftShift); } if (Input2.GetKey(KeyCode.LeftShift)) { pressedKey.Add(KeyCode.W); } nitroDown = InputGetKey(KeyCode.LeftShift); var factor = Time.deltaTime; bool left = InputGetKey(KeyCode.A); bool right = InputGetKey(KeyCode.D); var brake = InputGetKey(KeyCode.Space); var forward = InputGetKey(KeyCode.W) || nitroDown; var back = InputGetKey(KeyCode.S); steerValue = Lerp(steerValue, left ? -1 : right ? 1 : 0, factor); forwardValue = Lerp(forwardValue, forward ? 1 : 0, factor * 3); reverseValue = Lerp(reverseValue, back ? 1 : 0, factor * 3); if (forward) { reverseValue = 0; } if (back) { forwardValue = 0; } handbrakeValue = brake ? 1 : 0; float speedForward = Vector3.Dot(Car.rigidbody.velocity, Car.tr.forward); float speedSideways = Vector3.Dot(Car.rigidbody.velocity, Car.tr.right); float speedRotation = Car.rigidbody.angularVelocity.magnitude; float speedAbs = speedForward * speedForward; speedSideways *= speedSideways; float motorInput = 0; float brakeInput = 0; if (reverseRequiresStop) { if (speedAbs < GEARSPEEDMIN && forwardValue == 0 && reverseValue == 0) { brakeRelease = true; Car.gearInput = 0; } if (brakeRelease) { if (speedAbs < GEARSPEEDMIN) { if (reverseValue > 0) { Car.gearInput = -1; } if (forwardValue > 0) { Car.gearInput = 1; } } else if (speedSideways < GEARSPEEDMIN && speedRotation < GEARSPEEDMIN) { if (speedForward > 0 && Car.gearInput <= 0 && (forwardValue > 0 || reverseValue > 0)) { Car.gearInput = 1; } if (speedForward < 0 && Car.gearInput >= 0 && (forwardValue > 0 || reverseValue > 0)) { Car.gearInput = -1; } } } if (Car.gearInput < 0) { motorInput = reverseValue; brakeInput = forwardValue; } else { motorInput = forwardValue; brakeInput = reverseValue; } if (brakeInput > 0) { brakeRelease = false; } } else { if (speedForward > GEARSPEEDMIN) { Car.gearInput = 1; motorInput = forwardValue; brakeInput = reverseValue; } else if (speedForward <= GEARSPEEDMIN && reverseValue > GEARSPEEDMIN) { Car.gearInput = -1; motorInput = reverseValue; brakeInput = 0; } else if (forwardValue > GEARSPEEDMIN && reverseValue <= 0) { Car.gearInput = 1; motorInput = forwardValue; brakeInput = 0; } else if (forwardValue > GEARSPEEDMIN) { Car.gearInput = 1; } else if (reverseValue > GEARSPEEDMIN) { Car.gearInput = -1; } else { Car.gearInput = 0; } brakeRelease = false; } Car.steerInput = steerValue; Car.motorInput = motorInput; Car.brakeInput = brakeInput; Car.handbrakeInput = handbrakeValue; return(brakeRelease); }
public void Update() { if (!active) { return; } if (KeyDebug(KeyCode.V)) { Score kills = _Game.GetPlayers().FirstOrDefault() == pv.pl ? stats.killLeader : stats.kills; kills.value++; _Hud.centerText(string.Format(Tr("You killed {0}\n+{1}$"), pv.playerName, kills.points)); } UpdateValues(); UpdateLod(); if (GameType.weapons && !dead && room.autoLifeRecovery) { lifeGrow += Time.deltaTime * 2; if (lifeGrow > 10 && life < 100) { life = Mathf.Min(life + lifeGrow * Time.deltaTime, room.lifeDef); } } if (cop) { nitro = Mathf.MoveTowards(nitro, 3, Time.deltaTime * .05f); } //if (IsMine && Input2.GetKeyDown(KeyCode.R)) //{ // RaycastHit h; // if (Physics.Raycast(_Player.posUp, Vector3.down, out h, 3, Layer.levelMask)) // { // var f = _Player.transform.forward; // _Player.transform.up = h.normal; // _Player.transform.forward = f; // } // AddLife(-10, -1); //} //if (_Loader.pursuit && !cop && TimeElapsed(10) && !dead) // pv.score += 1; if (nitroDown) { nitro -= Time.deltaTime; } foreach (var a in nitroParticles) { a.emit = nitroDown; } nitroAudio.enabled = nitroDown; if (nitroDown) { rigidbody.AddForce(transform.forward * bs.settings.nitroForce * rigidbody.mass); } //if(KeyDebug(KeyCode.A)) // DisableCar(); fire.gameObject.SetActive(life < 0); smoke.gameObject.SetActive(life < 40 && (highQuality || !android)); fire.up = Vector3.up; smoke.up = Vector3.up; if (bot) { UpdateBot(); } else if (IsMine) { foreach (KeyCode a in useKeys) { bool k = (Input2.GetKey(a) || pressedKey.Contains(a)) && !unpressKey.Contains(a); if (keys[(int)a] != k) { CallRPC(SetKey, (int)a, k); } } pressedKey.Clear(); unpressKey.Clear(); } if (!dead && _Game.started && !win.active) { m_bBrakeRelease = UpdateInput(m_Car, false, m_bBrakeRelease); } else { DisableCar(); } if (IsMine) { FallCheck(); } UpdateText(); UpdateDm(); if (_Player == this && !dead) { RaycastHit h = default(RaycastHit); if (Vector3.Dot(transform.up, Vector3.up) > .1f || !Physics.Raycast(_Player.posUp, Vector3.down, out h, 3, Layer.levelMask)) { reverseTime = Time.time; } if (Time.time - reverseTime > 3) { var f = _Player.transform.forward; _Player.transform.up = h.normal; _Player.transform.forward = f; _Player.rigidbody.angularVelocity = Vector3.zero; reverseTime = Time.time; } } avrVel = Mathf.Lerp(avrVel, velm, Time.deltaTime); }