public IsControlKeyPressed ( GameControlKeys key ) : bool | ||
key | GameControlKeys | |
return | bool |
public void Tick(Intellect intellect) { if (intellect.IsControlKeyPressed(keyDecel)) val -= increment; if (intellect.IsControlKeyPressed(keyAccel)) val += increment; if (val < 0) val = 0; if (val > 1) val = 1; }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnTick()"/>.</summary> protected override void OnTick() { base.OnTick(); if (Intellect != null) { if (Intellect.IsControlKeyPressed(GameControlKeys.Fire1)) { WeaponTryFire(false); } if (Intellect.IsControlKeyPressed(GameControlKeys.Fire2)) { WeaponTryFire(true); } } TickContusionTime(); if (activeWeapon == null || activeWeapon.Ready) { UpdateTPSArcadeLookDirection(); } if (activeWeapon != null) { if (EntitySystemWorld.Instance.IsServer()) { Server_TickSendWeaponVerticalAngleToClients(); } } }
/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnTick()"/>.</summary> protected override void OnTick() { base.OnTick(); if (Intellect != null) { if (Intellect.IsControlKeyPressed(GameControlKeys.Fire1)) { GunsTryFire(false); } if (Intellect.IsControlKeyPressed(GameControlKeys.Fire2)) { GunsTryFire(true); } } //send turn to position to clients if (EntitySystemWorld.Instance.IsServer()) { float epsilon = .05f; if (!server_shouldSendTurnToPosition.Equals(server_sentTurnToPosition, epsilon)) { Server_SendTurnToPositionToClients(EntitySystemWorld.Instance.RemoteEntityWorlds, server_shouldSendTurnToPosition); server_sentTurnToPosition = server_shouldSendTurnToPosition; } } }
private void ShiftBooster() { MapObjectAttachedParticle Shift1 = GetAttachedObjectByAlias("Shift1") as MapObjectAttachedParticle; MapObjectAttachedParticle Shift2 = GetAttachedObjectByAlias("Shift2") as MapObjectAttachedParticle; bool boosted = false; if (Intellect.IsControlKeyPressed(GameControlKeys.SHIFT)) { if (ShiftBottel >= 5) { HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta, HelliBody.Rotation * new Vec3(40, 0, 0) * HelliBody.Mass, Vec3.Zero); ShiftBottel -= 0.5f; boosted = true; } } else { boosted = false; if (ShiftBottel < Type.MaxShiftBottel) { ShiftBottel += 0.05f; } } if (Shift1 != null) { Shift1.Visible = boosted; Shift2.Visible = boosted; } }
//Animation fcharacter protected override void OnUpdateBaseAnimation() { if (Intellect != null) { if (Intellect.IsControlKeyPressed(GameControlKeys.Right)) { UpdateBaseAnimation(Type.RightAnimationName, false, false, 1); } if (Intellect.IsControlKeyPressed(GameControlKeys.Left)) { UpdateBaseAnimation(Type.LeftAnimationName, false, false, 1); } } }
private void Ñar_particle() { float carspeed = GetWheelsSpeed(); MapObjectAttachedParticle Carspeed_applyparticle1 = GetAttachedObjectByAlias("Carspeed_applyparticle1") as MapObjectAttachedParticle; MapObjectAttachedParticle Carspeed_applyparticle2 = GetAttachedObjectByAlias("Carspeed_applyparticle2") as MapObjectAttachedParticle; bool Hs1 = false; bool Cp1 = false; float speed_cp = GetWheelsSpeed(); bool on_whell = LRWheel.onGround || RRWheel.onGround; if (speed_cp > Type.Carspeed_applyparticle & on_whell) { Cp1 = true; } float ang = chassisBody.AngularVelocity.Z; float ang2 = ang * carspeed * 2; if (carspeed > 20) { ang2 = ang * carspeed / 2; } else if (carspeed > 50) { ang2 = ang * carspeed / 10; } if (Intellect.IsControlKeyPressed(GameControlKeys.Jump)) { skidsound(true); //EngineApp.Instance.ScreenGuiRenderer.AddText("ang: " + ang2, new Vec2(.6f, .4f)); if (carspeed > 10 & on_whell) { Hs1 = true; chassisBody.AngularDamping = 0; } } else { //dumpings chassisBody.AngularDamping = 3; } Carspeed_applyparticle1.Visible = Hs1; Carspeed_applyparticle2.Visible = Cp1; }
void TickMagnet() { bool userNeedDetach = Intellect != null && (Intellect.IsControlKeyPressed(GameControlKeys.Fire1) || Intellect.IsControlKeyPressed(GameControlKeys.Fire2)); //attach new bodies if (!userNeedDetach) { const int needContacts = 3; foreach (KeyValuePair <Body, int> pair in lastMagnetContactsCount) { Body mapObjectBody = pair.Key; int contactsCount = pair.Value; if (contactsCount >= needContacts) { MagnetAttachObject(mapObjectBody); } } } lastMagnetContactsCount.Clear(); //detach by user if (userNeedDetach) { MagnetDetachAllObjects(); } //detach if joint disposed again: foreach (MagnetObjectItem item in magnetAttachedObjects) { if (item.fixedJoint.IsDisposed) { MagnetDetachObject(item); goto again; } } }
public void Tick(Intellect intellect) { bool damp = true; if (intellect.IsControlKeyPressed(keyMinus)) { damp = false; if (val <= 0) val -= increment; if (val > 0) val -= decrement; } if (intellect.IsControlKeyPressed(keyPlus)) { damp = false; if (val >= 0) val += increment; if (val < 0) val += decrement; } if (damp) { if (val < 0) { val += damping; if (val > 0) val = 0; } if (val > 0) { val -= damping; if (val < 0) val = 0; } } if (val < -1) val = -1; if (val > 1) val = 1; }
void TickRearWheels() { float leftwheelForce = 0; float rightwheelForce = 0; if (Intellect != null) { ServoMotor rightwheel = PhysicsModel.GetMotor("rightwheelMotor") as ServoMotor; ServoMotor leftwheel = PhysicsModel.GetMotor("leftwheelMotor") as ServoMotor; if (rightwheel != null) { if (leftwheel != null) { float speed = Type.Rotationspeed; MathFunctions.Clamp(ref speed, Type.Rotationspeed, Type.Rotationspeed); Radian needAngle = leftwheel.DesiredAngle; if (Intellect.IsControlKeyPressed(GameControlKeys.Left)) { if (3 > 2) { leftwheelForce += speed; rightwheelForce -= speed; } needAngle += Type.Rotation; } else if (Intellect.IsControlKeyPressed(GameControlKeys.Right)) { if (3 > 2) { leftwheelForce -= speed; rightwheelForce += speed; } needAngle -= Type.Rotation; } else { needAngle = 0f; } MathFunctions.Clamp(ref needAngle, new Degree(-Type.Rotationradius).InRadians(), new Degree(Type.Rotationradius).InRadians()); rightwheel.DesiredAngle = needAngle; leftwheel.DesiredAngle = needAngle; } } } ServoMotor motor = PhysicsModel.GetMotor("upMotor") as ServoMotor; if (motor != null) { Radian needAngle = motor.DesiredAngle; needAngle += Intellect.GetControlKeyStrength(GameControlKeys.Fire1) * Type.Forkupspeed; needAngle -= Intellect.GetControlKeyStrength(GameControlKeys.Fire2) * Type.Forkupspeed; MathFunctions.Clamp(ref needAngle, new Degree(-0.0f).InRadians(), new Degree(Type.Forkupmax).InRadians()); motor.DesiredAngle = needAngle; } }
private void TickRotation() { bool onGround = LFWheel.onGround || RFWheel.onGround; float carspeed = GetWheelsSpeed(); float LFWheelThrottle = 0; float RFWheelThrottle = 0; if (Intellect != null) { Body WFR = PhysicsModel.GetBody("FR"); Body WFL = PhysicsModel.GetBody("FL"); Body WRR = PhysicsModel.GetBody("RR"); Body WRL = PhysicsModel.GetBody("RL"); float wheelspeed = GetWheelsSpeed() * 2; Vec3 Wspeed = new Vec3(0, wheelspeed, 0) * chassisBody.Rotation.GetNormalize(); if (onGround) { WFR.AngularVelocity = Wspeed; WFL.AngularVelocity = Wspeed; WRR.AngularVelocity = Wspeed; WRL.AngularVelocity = Wspeed; } { ServoMotor motor_1 = PhysicsModel.GetMotor("wheel1") as ServoMotor; ServoMotor motor_2 = PhysicsModel.GetMotor("wheel2") as ServoMotor; if (motor_1 != null) { if (motor_2 != null) { float turnspeed = 0.5f; MathFunctions.Clamp(ref turnspeed, 0.5f, 0.5f); Radian needAngle = motor_1.DesiredAngle; if (Intellect.IsControlKeyPressed(GameControlKeys.Left)) { if (carspeed > 2) { LFWheelThrottle -= turnspeed; RFWheelThrottle += turnspeed; } if (carspeed < -1) { LFWheelThrottle += turnspeed; RFWheelThrottle -= turnspeed; } needAngle -= 0.2f; } else if (Intellect.IsControlKeyPressed(GameControlKeys.Right)) { if (carspeed > 2) { LFWheelThrottle += turnspeed; RFWheelThrottle -= turnspeed; } if (carspeed < -1) { LFWheelThrottle -= turnspeed; RFWheelThrottle += turnspeed; } needAngle += 0.2f; } else { needAngle = 0f; } MathFunctions.Clamp(ref needAngle, new Degree(-37.0f).InRadians(), new Degree(37.0f).InRadians()); motor_1.DesiredAngle = needAngle; motor_2.DesiredAngle = needAngle; } } } } }
private void TickIntellect() { ShiftBooster(); HelliOn = Intellect != null && Intellect.IsActive(); // GUItest(); //finding motors GearedMotor main = PhysicsModel.GetMotor("hellimain") as GearedMotor; GearedMotor back = PhysicsModel.GetMotor("helliback") as GearedMotor; if (HelliOn) { main.Enabled = true; back.Enabled = true; } //engine force + sound pitch control if (Intellect.IsControlKeyPressed(GameControlKeys.Forward)) { force += forceadd; enpitch += 0.02f; } else if (Intellect.IsControlKeyPressed(GameControlKeys.Backward)) { dec = true; force -= forceadd; enpitch -= 0.02f; } else { dec = false; enpitch -= 0.01f; if (force > 50) { force -= forceadd; } if (force < 50) { force += forceadd; } } MathFunctions.Clamp(ref force, 0.1f, 100 + Type.MaxForce); MathFunctions.Clamp(ref enpitch, 0.8f, 1.3f); //update helli channel position and pitch if (rotorSoundChannel != null) { //update channel rotorSoundChannel.Pitch = enpitch; rotorSoundChannel.Volume = 1; rotorSoundChannel.Position = Position; rotorSoundChannel.MinDistance = 10; } //end of engine force + sound pitch control //Forces //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start helli Pitch if (Intellect.IsControlKeyPressed(GameControlKeys.ArrowUp) || Intellect.IsControlKeyPressed(GameControlKeys.ArrowDown)) { float AUp = Intellect.GetControlKeyStrength(GameControlKeys.ArrowUp) / 2; float ADown = Intellect.GetControlKeyStrength(GameControlKeys.ArrowDown) / 2; Hpitch += (AUp - ADown); MathFunctions.Clamp(ref Hpitch, -10, 10); HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta, HelliBody.Rotation * new Vec3(0, 0, Hpitch / 2) * HelliBody.Mass, new Vec3(-2, 0, 0)); } else { Hpitch = 0; } //end of helli pitch //start helli Z turn if (Intellect.IsControlKeyPressed(GameControlKeys.Right) || Intellect.IsControlKeyPressed(GameControlKeys.Left)) { float right = Intellect.GetControlKeyStrength(GameControlKeys.Right) / 2; float left = Intellect.GetControlKeyStrength(GameControlKeys.Left) / 2; TrunZ += (left - right); MathFunctions.Clamp(ref TrunZ, -10, 10); HelliBody.AddForce(ForceType.GlobalTorque, TickDelta, HelliBody.Rotation * new Vec3(0, 0, TrunZ) * HelliBody.Mass, Vec3.Zero); } else { TrunZ = 0; } //end of helli Z turn //start helli X turn if (Intellect.IsControlKeyPressed(GameControlKeys.ArowRight) || Intellect.IsControlKeyPressed(GameControlKeys.ArowLeft)) { float rightX = Intellect.GetControlKeyStrength(GameControlKeys.ArowRight) / 2; float leftX = Intellect.GetControlKeyStrength(GameControlKeys.ArowLeft) / 2; TrunX += (rightX - leftX); MathFunctions.Clamp(ref TrunX, -10, 10); HelliBody.AddForce(ForceType.GlobalTorque, TickDelta, HelliBody.Rotation * new Vec3(TrunX / 5, 0, 0) * HelliBody.Mass, Vec3.Zero); } else { TrunX = 0; } //end of helli X turn ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //start of adding force MathFunctions.Clamp(ref force, 0.1f, 100); //anti gravity when helli is not decending if (dec == false) { HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta, new Vec3(0, 0, 2) * HelliBody.Mass, Vec3.Zero); } //if Max Alt is not reached add helli motor force if (GetRealAlt() < Type.MaxAlt) { HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta, HelliBody.Rotation * 2 * new Vec3(0, 0, force / 7) * HelliBody.Mass, Vec3.Zero); } //dampings HelliBody.AngularDamping = 1.5f; HelliBody.LinearDamping = 0.4f; //another anti gravity force if (HelliBody.LinearVelocity.Z < 0) { HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta, HelliBody.Rotation * new Vec3(0, 0, -HelliBody.LinearVelocity.Z) * HelliBody.Mass, Vec3.Zero); } }