int layerMask;// = 1 << LayerMask.NameToLayer("Vehicle"); // Use this for initialization void Start() { vehicleScript = GetComponent <BasicVehicle>(); rb = GetComponent <Rigidbody>(); //vehicleScript.initializeSpeed(20,0,false); //vehicleScript.AiControlled = true; //axleInfos = vehicleScript.axleInfos; int layerMask = 1 << LayerMask.NameToLayer("Vehicle"); }
protected virtual void handleVehicleCollision() { if (vehicleCollider.collidersCount() > 0)//&& (rb.velocity.y < 0 || targetedVehicle!= null) { if (!vehicleCollider.returnColliders()[0].transform.root.transform.GetComponent <BasicVehicle>().broken) { hitVehicle = vehicleCollider.returnColliders()[0].transform.root.transform.GetComponent <BasicVehicle>(); } } }
void CopyCarFields(GameObject SourceCar, GameObject TargetCar) { TargetCar.tag = SourceCar.tag; TargetCar.name = SourceCar.name; #region Copy Transform TargetCar.transform.parent = SourceCar.transform.parent; TargetCar.transform.position = SourceCar.transform.position; TargetCar.transform.rotation = SourceCar.transform.rotation; TargetCar.transform.localScale = SourceCar.transform.localScale; #endregion #region Copy RigidBody Rigidbody src = SourceCar.GetComponent <Rigidbody>(); Rigidbody targ = TargetCar.GetComponent <Rigidbody>(); targ.mass = src.mass; targ.drag = src.drag; targ.angularDrag = src.angularDrag; #endregion #region Copy AiController AiController Ai_src = SourceCar.GetComponent <AiController>(); AiController Ai_targ = TargetCar.GetComponent <AiController>(); Ai_targ.disabled = Ai_src.disabled; Ai_targ.laneID = Ai_src.laneID; Ai_targ.DebugThis = Ai_src.DebugThis; Ai_targ.stopUpdate = Ai_src.stopUpdate; #endregion #region Copy Basic Vehicle BasicVehicle BV_src = SourceCar.GetComponent <BasicVehicle>(); BasicVehicle BV_targ = TargetCar.GetComponent <BasicVehicle>(); BV_targ.DebugThis = BV_src.DebugThis; BV_targ.player = BV_src.player; BV_targ.broken = BV_src.broken; BV_targ.disabled = BV_src.disabled; BV_targ.breakInDistance = BV_src.breakInDistance; BV_targ.MotorTorque = BV_src.MotorTorque; BV_targ.MaxSteeringAngle = BV_src.MaxSteeringAngle; BV_targ.SteeringRate = BV_src.SteeringRate; BV_targ.GroundedStablizationRate = BV_src.GroundedStablizationRate; BV_targ.gravityDirection = BV_src.gravityDirection; BV_targ.normalMaxSpeed = BV_src.normalMaxSpeed; BV_targ.computerMaxSpeed = BV_src.computerMaxSpeed; BV_targ.tempMaxSpeed = BV_src.tempMaxSpeed; BV_targ.tempMaxSpeedLowerLimitPercent = BV_src.tempMaxSpeedLowerLimitPercent; BV_targ.potentialMaxSpeed = BV_src.potentialMaxSpeed; BV_targ.crashSpeed = BV_src.crashSpeed; BV_targ.boosting = BV_src.boosting; BV_targ.AutoCorrect = BV_src.AutoCorrect; #endregion }
public AMovementEngine(AmeisenBotConfig config) { Config = config; FindPathEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(500)); RefreshPathEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(500)); DistanceMovedCheckEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(500)); PathQueue = new Queue <Vector3>(); PlacesToAvoidList = new List <(Vector3 position, float radius, DateTime until)>(); PlayerVehicle = new BasicVehicle(); }
public SmartMovementEngine(WowInterface wowInterface, MovementSettings movementSettings) { WowInterface = wowInterface; MovementSettings = movementSettings; Rnd = new Random(); CurrentPath = new Queue <Vector3>(); State = MovementEngineState.None; TryCount = 0; PlayerVehicle = new BasicVehicle(wowInterface, movementSettings.MaxSteering, movementSettings.MaxVelocity, movementSettings.MaxAcceleration); }
public SmartMovementEngine(GetPositionFunction getPositionFunction, GetRotationFunction getRotationFunction, MoveToPositionFunction moveToPositionFunction, GeneratePathFunction generatePathFunction, JumpFunction jumpFunction, ObjectManager objectManager, MovementSettings movementSettings) { State = MovementEngineState.None; GetPosition = getPositionFunction; GetRotation = getRotationFunction; MoveToPosition = moveToPositionFunction; GeneratePath = generatePathFunction; MovementSettings = movementSettings; ObjectManager = objectManager; Jump = jumpFunction; PlayerVehicle = new BasicVehicle(getPositionFunction, getRotationFunction, moveToPositionFunction, jumpFunction, objectManager, movementSettings.MaxSteering, movementSettings.MaxVelocity, movementSettings.MaxAcceleration); }
//attempt to start break in move public virtual void inputBreakIn(int input) { if (input == 1 && false)// && prevVectorToAdd!= Vector3.zero) { //BasicVehicle closestVehicle = null; //handleLockOnCollision(); foreach (BasicVehicle bv in closeVehicles) { if (!bv.broken && (rb.velocity.y < 0 || prevVehicle != bv.gameObject)) { //vectorToAdd = vectorToAdd.normalized; Vector3 dir = prevVectorToAdd; if (cameraLockOn) { dir = calculateForward(); } float dist = (transform.position + (dir * lockOnCollider.transform.GetComponent <SphereCollider>().radius / 2) - bv.transform.position).magnitude; //float dist = DistanceToLine(new Ray (transform.position + vectorToAdd, vectorToAdd), bv.transform.position); if (targetedVehicle == null || dist < (transform.position + (dir * lockOnCollider.transform.GetComponent <SphereCollider>().radius / 2) - targetedVehicle.transform.position).magnitude) { targetedVehicle = bv; } } } if (targetedVehicle != null) { float dist = (targetedVehicle.transform.position - transform.position).magnitude; //DONT CHANGE THIS FOR NOW -- NICK //new max speed and new start speed as a percent of current speed based on proximity to targeted car. right next to car = 99%, farthest away (but still in range) = 1%. storedNewCarMaxSpeed = Mathf.Max(30f, (rb.velocity.magnitude * 0.3f)) + (rb.velocity.magnitude * 1.1f) * Mathf.Max(((lockOnCollider.transform.GetComponent <SphereCollider>().radius + vehicleCollider.transform.GetComponent <SphereCollider>().radius - dist) / (lockOnCollider.transform.GetComponent <SphereCollider>().radius + vehicleCollider.transform.GetComponent <SphereCollider>().radius)), 0); //storedNewCarStartSpeed = Mathf.Max(30f, (rb.velocity.magnitude * 0.5f)) + (rb.velocity.magnitude * 0.2f) * Mathf.Max(((lockOnCollider.transform.GetComponent<SphereCollider>().radius + vehicleCollider.transform.GetComponent<SphereCollider>().radius - dist) / (lockOnCollider.transform.GetComponent<SphereCollider>().radius + vehicleCollider.transform.GetComponent<SphereCollider>().radius)), 0); storedNewCarStartSpeed = 0.6f * storedNewCarMaxSpeed; } } }
public SickMovementEngine(WowInterface wowInterface, AmeisenBotConfig config) { WowInterface = wowInterface; Config = config; PathNodes = new ConcurrentQueue <Vector3>(); PlayerVehicle = new BasicVehicle(wowInterface); Shortcuts = new List <IShortcut>() { // new DeeprunTramShortcut(wowInterface) }; if (WowInterface.MovementSettings.EnableDistanceMovedJumpCheck) { MovementWatchdog = new Timer(250); MovementWatchdog.Elapsed += MovementWatchdog_Elapsed; MovementWatchdog.Start(); } PathDecayEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(1000)); ObstacleCheckEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(500)); MountCheck = new TimegatedEvent(TimeSpan.FromSeconds(3)); BehaviorTree = new AmeisenBotBehaviorTree ( "MovementTree", new Selector ( "DoINeedToMove", () => TargetPosition != default && !WowInterface.ObjectManager.Player.IsDead && !WowInterface.ObjectManager.Player.IsCasting && (WowInterface.ObjectManager.Vehicle == null || !WowInterface.ObjectManager.Vehicle.IsCasting) && MovementAction != MovementAction.None && DateTime.Now > PreventMovementUntil && !IsNearPosition(TargetPosition), new Selector ( "DoINeedToJump", () => JumpOnNextMove, new Leaf(() => { WowInterface.CharacterManager.Jump(); JumpOnNextMove = false; return(BehaviorTreeStatus.Success); }), new Selector ( "DoINeedToUnstuck", () => ShouldBeMoving && !ForceDirectMove && StuckCounter > WowInterface.MovementSettings.StuckCounterUnstuck, new Leaf(DoUnstuck), new Selector ( "DoINeedToDirectlyMove", () => IsDirectMovingState() || WowInterface.ObjectManager.Player.Position.GetDistance(TargetPosition) < 3.0 || WowInterface.ObjectManager.Player.IsSwimming || WowInterface.ObjectManager.Player.IsFlying || ForceDirectMove, new Leaf(HandleDirectMoving), new Selector ( "DoINeedToFindAPath", DoINeedToFindAPath, new Leaf ( "FindPathToTargetPosition", FindPathToTargetPosition ), new Selector ( "DoINeedToMount", DoINeedToMount, new Leaf("MountUp", MountUp), new Selector ( "DoINeedToMove", () => PathNodes.TryPeek(out Vector3 node) && !IsNearPosition(node), new Leaf("MoveToNode", HandleMovement), new Leaf("CheckWaypoint", HandleWaypointCheck) ) ) ) ) ) ), new Selector ( () => Config.AutoDodgeAoeSpells && DoINeedToDodgeAoeSpell(), new Leaf(DodgeAoeSpell), new Leaf(() => { return(BehaviorTreeStatus.Success); }) ) ) ); }
//Brady: Added if statement to determine physics of launch. For the time being, the beginCarJump variable for carspeed is simply the car magnitude divided by 5. public void ExitVehicle() { var randomJump = Random.Range(0, 2); // Replace the sound clip string in the second case when someone finds a second jump sound curVehicle.GetComponent <AudioSource>().Stop(); if (randomJump == 0) { SoundScript.PlaySound(playerSource, "Jump"); } else if (randomJump == 1) { SoundScript.PlaySound(playerSource, "Jump"); } //Debug.Log("EXIT CAR " + buttonLaunch); if (curState != PlayerState.Dead) { curState = PlayerState.Rider; if (curVehicle != null) { curVehicle.transform.GetComponent <Rigidbody>().velocity *= 0.5f; curVehicle.player = false; //let go of steering wheel curVehicle.inputHorz(0); curVehicle.inputAccel(0); Vector3 newUp = Vector3.up; if (curVehicle.easyCheckWheelsOnGround() && curVehicle.gravityDirection.normalized != Vector3.down) { newUp = curVehicle.transform.up; } //spawn rider above car. curRider = Instantiate(selectedCharacter_Prefab, curVehicle.transform.position + newUp * 5f, Quaternion.Euler(0, curVehicle.transform.eulerAngles.y, 0)).GetComponent <BasicRider>(); curRider.externalStart(mainCamera.transform); curRider.beginCarJump(curVehicle.returnExitVelocity(), curVehicle.returnActualMaxSpeed(), newUp, curVehicle.easyCheckWheelsOnGround()); } else { //spawn rider at prefab coordinates. curRider = Instantiate(selectedCharacter_Prefab, selectedCharacter_Prefab.transform.position, selectedCharacter_Prefab.transform.rotation).GetComponent <BasicRider>(); curRider.externalStart(mainCamera.transform); } mainCamera.ChangeFocus(curRider.transform, 0); //mainCamera.ChangeDistance(12f, 2f); prevVehicle = curVehicle.gameObject; prevVehicleIntangibility = 1f; curRider.setPreviousVehicle(curVehicle.gameObject); curVehicle = null; foreach (GameObject go in GameObject.FindGameObjectsWithTag("VisibleWhenPlaying")) { go.SetActive(true); } } else { Debug.Log("big no no error"); } }
public void EnterVehicle(BasicVehicle newVehicle) { //Debug.Log("ENTER CAR " + Time.time); if (curState != PlayerState.Dead) { //successful combo if (comboTimer > 0 && (prevComboPosition - newVehicle.transform.position).magnitude >= comboDistance && newVehicle.gameObject != prevVehicle) { comboMultiplier++; comboTimer = comboTimeSet; //SoundScript.PlaySound(playerSource, "Combo Add"); } //start new combo else if ((prevComboPosition - newVehicle.transform.position).magnitude >= comboDistance && !prevBroken && newVehicle.gameObject != prevVehicle) { if (comboBS) { comboBS.comboStart(); } //SoundScript.PlaySound(playerSource, "Combo Add"); comboMultiplier = 1; comboTimer = comboTimeSet; } //drop combo b/c too close else { CashOutCombo(); } curState = PlayerState.Vehicle; curVehicle = newVehicle; curVehicle.player = true; if (curRider != null) { //curVehicle.initializeSpeed(0, 0, InputManager.GetButton("BreakIn")); curVehicle.initializeSpeed(curRider.calculateNewCarMaxSpeed(), curRider.calculateNewCarStartSpeed(), false); curRider.destroyThis(); } else { curVehicle.initializeSpeed(0, 0, false); } mainCamera.ChangeFocus(curVehicle.transform, 0); //mainCamera.ChangeDistance(10f, 2f); //set position for combo if (prevComboPosition != Vector3.zero) { prevComboPosition = curVehicle.transform.position; } } else { Debug.Log("big no no error"); } newVehicle = null; }
//let playercontroller know to enter a car public virtual void rejectVehicleToEnter() { hitVehicle = null; }