public override BehaviourSM.StateResponse Update(AIController controller) { ChargeBossController bossController = (ChargeBossController)controller; Vector3 lookDirection = controller.target != null ? controller.target.transform.position - controller.transform.position : controller.transform.forward; lookDirection.z = 0.0f; lookDirection.Normalize(); Vector3 currentFacing = controller.headTransform.up; float turnRateMultiplier = (controller.target.transform.position - controller.transform.position).magnitude / bossController.chargeTurnRateFalloffDist; turnRateMultiplier = Mathf.Min(turnRateMultiplier, 1.0f); Vector3 chargeDirection = Vector3.RotateTowards(currentFacing, lookDirection, bossController.chargeTurnRate * Time.deltaTime * turnRateMultiplier, 0.0f); chargeDirection.z = 0.0f; controller.headTransform.up = chargeDirection; // Move direct so that it doesnt path controller.MoveDirect(chargeDirection, controller.baseMoveSpeed * bossController.chargeSpeedModifier); Vector3 toTarget = controller.target.transform.position - controller.transform.position; if(toTarget.magnitude < damageRadius) { // Damage the player, go to the stunned state, knock back the player controller.target.MovementComponent.ApplyForce(toTarget * bossController.chargeKnockbackForce); controller.target.MechComponent.TakeDamage(bossController.chargeHitDamage, controller, null); // A bit of a hack, but do a camera shake CameraController camera = GameObject.FindObjectOfType<CameraController>(); if(camera != null) { CameraController.CameraShake shakeData = new CameraController.CameraShake(0.2f, 1.0f, 1.0f, 1.0f, false); camera.StartCameraShake(ref shakeData, Vector3.up); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.AbandonCurrent, new Behaviour_Boss_Stunned()); } // if it collided this frame, that means it hit a wall and should go into stun state if(controller.MovementComponent.collidedThisFrame) { bossController.OpenWeakSpot(); // Again, do a smaller shake when the boss hits a wall CameraController camera = GameObject.FindObjectOfType<CameraController>(); if(camera != null) { CameraController.CameraShake shakeData = new CameraController.CameraShake(0.3f, 0.3f, 5.0f, 1.0f, false); camera.StartCameraShake(ref shakeData, Vector3.up); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.AbandonCurrent, new Behaviour_Boss_Stunned()); } return new BehaviourSM.StateResponse(BehaviourSM.TransitionMode.NoChange); }
public override bool BeginFire() { //bool beganFire = base.BeginFire(); if(!CanRefire()) { return false; } isFiring = true; laserRenderer.enabled = true; // Do some camera shake, if its the player shooting. TOTO: more generalized way to do camera shake if(owner.GetType() == typeof(PlayerController)) { CameraController.CameraShake shakeData = new CameraController.CameraShake(0.1f, 0.05f, 5.0f, 1.0f, true); PlayerController playerOwner = (PlayerController)owner; playerOwner.PlayerCamera.GetComponent<CameraController>().StartCameraShake(ref shakeData, -GetAimDirection().normalized); } startedFireTime = Time.time; return true; }
public void DoCameraRecoil(float recoilAmount) { if(owner.GetType() == typeof(PlayerController) && recoilAmount > 0.0f) { CameraController.CameraShake shakeData = new CameraController.CameraShake(0.1f, recoilAmount, 5.0f, 1.0f, false); PlayerController playerOwner = (PlayerController)owner; playerOwner.PlayerCamera.GetComponent<CameraController>().StartCameraShake(ref shakeData, -GetAimDirection()); } }
/// <summary> /// Call to start the weapon firing: /// returns true if it starts firing, false if it fails for some reason /// </summary> public virtual bool BeginFire() { if(!CanRefire()) { return false; } Fire(); // Do some camera shake, if its the player shooting. TOTO: more generalized way to do camera shake if(owner.GetType() == typeof(PlayerController) && cameraRecoil > 0.0f) { CameraController.CameraShake shakeData = new CameraController.CameraShake(0.1f, cameraRecoil, 5.0f, 1.0f, false); PlayerController playerOwner = (PlayerController)owner; playerOwner.PlayerCamera.GetComponent<CameraController>().StartCameraShake(ref shakeData, -GetAimDirection()); } isFiring = true; return true; }