private void SetRudderBroken(VehicleEntity vehicle, VehiclePartIndex index) { var controller = vehicle.GetController <AdvancedShipController>(); var controllerIndex = VehicleIndexHelper.ToVehicleControllerRudderIndex(index); controller.rudders[controllerIndex].IsBroken = true; }
/// <summary> /// 刷新载具上对应位置轮胎爆胎情况 /// </summary> /// <param name="index"></param> private void UpdateWheelStateByIndex(VehiclePartIndex index) { VehicleUiWheelIndex uiIndex; bool isWheelBroke = _adapter.IsWheelBrokeByIndex(index, out uiIndex); SetWheelShow(uiIndex, isWheelBroke); }
public override float DecreaseHp(VehiclePartIndex index, float amount, EUIDeadType damageType, EntityKey damageSource) { AssertUtility.Assert(amount >= 0); switch (index) { case VehiclePartIndex.FirstWheel: FirstWheelHp = FirstWheelHp < amount ? 0.0f : FirstWheelHp - amount; return(FirstWheelHp); case VehiclePartIndex.SecondWheel: SecondWheelHp = SecondWheelHp < amount ? 0.0f : SecondWheelHp - amount; return(SecondWheelHp); case VehiclePartIndex.ThirdWheel: ThirdWheelHp = ThirdWheelHp < amount ? 0.0f : ThirdWheelHp - amount; return(ThirdWheelHp); case VehiclePartIndex.FourthWheel: FourthWheelHp = FourthWheelHp < amount ? 0.0f : FourthWheelHp - amount; return(FourthWheelHp); default: return(base.DecreaseHp(index, amount, damageType, damageSource)); } }
public float GetHitFactor(VehicleEntity vehicle, Collider collider, out VehiclePartIndex partIndex) { var config = GetShipConfig(vehicle); partIndex = GetPartIndexByName(vehicle, collider.name); return(config.bodyHitBoxFator); }
public static CarWheelComponent GetWheel(VehicleEntity vehicle, VehiclePartIndex index) { switch (index) { case VehiclePartIndex.FirstWheel: { return(vehicle.carFirstRewnWheel); } case VehiclePartIndex.SecondWheel: { return(vehicle.carSecondRewnWheel); } case VehiclePartIndex.ThirdWheel: { return(vehicle.carThirdRewnWheel); } case VehiclePartIndex.FourthWheel: { return(vehicle.carFourthRewnWheel); } default: return(null); } }
private void OnWheelHpChange(VehicleEntity vehicle, VehiclePartIndex index) { if (!WheelEntityUtility.HasWheel(vehicle, index)) { return; } if (vehicle.carGameData.GetWheelHp(index) <= 0.0f) { if (_isServer) { vehicle.vehicleBrokenFlag.SetVehiclePartBroken(index); } else { WheelEntityEffectUtility.PlayWheelExplosion(vehicle, index); if (_isOffline) { vehicle.vehicleBrokenFlag.SetVehiclePartBroken(index); } } } else { if (!_isServer && !_isOffline) { WheelEntityEffectUtility.EnableWheelRender(vehicle, index, true); } } }
private float GetVehicleFactor(RaycastHit hit, VehicleEntity target, out VehiclePartIndex partIndex) { Collider collider = hit.collider; var hitBoxFactor = VehicleEntityUtility.GetHitFactor(target, collider, out partIndex); return(hitBoxFactor); }
public float GetHitFactor(VehicleEntity vehicle, Collider collider, out VehiclePartIndex partIndex) { var config = GetCarConfig(vehicle); partIndex = GetPartIndexByName(vehicle, collider.name); return(partIndex == VehiclePartIndex.Body ? config.bodyHitBoxFator : config.wheelHitBoxFactor); }
protected override void SetWheel(VehicleEntity vehicle, VehiclePartIndex index, WheelAbstractState state) { base.SetWheel(vehicle, index, state); var fromState = (WheelState)state; var comp = WheelEntityUtility.GetWheel(vehicle, index); comp.SteerAngle = fromState.SteerAngle; }
public static VehicleUiWheelIndex GetUiWheelIndex(VehicleEntity vehicle, VehiclePartIndex index) { if (HasWheel(vehicle, index)) { var controller = GetController(vehicle); var controllerIndex = VehicleIndexHelper.ToVehicleControllerWheelIndex(index); return(controller.GetWheelUiIndex(controllerIndex)); } return(VehicleUiWheelIndex.None); }
public static void PlayWheelExplosion(VehicleEntity vehicle, VehiclePartIndex index) { //disable wheel mesh render EnableWheelRender(vehicle, index, false); //play explosion effect var go = vehicle.gameObject; var controllerIndex = VehicleIndexHelper.ToVehicleControllerWheelIndex(index); var effect = go.UnityObjWrapper.Value.GetComponent <VehicleEventEffect>(); effect.WheelExplosion(controllerIndex); }
public static bool HasRudder(VehicleEntity vehicle, VehiclePartIndex index) { switch (index) { case VehiclePartIndex.FirstRudder: return(vehicle.hasShipFirstRudderDynamicData); case VehiclePartIndex.SecondRudder: return(vehicle.hasShipSecondRudderDynamicData); default: return(false); } }
public static ShipRudderDynamicData GetRudder(VehicleEntity vehicle, VehiclePartIndex index) { switch (index) { case VehiclePartIndex.FirstRudder: return(vehicle.shipFirstRudderDynamicData); case VehiclePartIndex.SecondRudder: return(vehicle.shipSecondRudderDynamicData); default: return(null); } }
public bool IsWheelBrokeByIndex(VehiclePartIndex index, out VehicleUiWheelIndex uiIndex) { AssertUtility.Assert(IsOnVehicle); uiIndex = VehicleUiWheelIndex.None; var vehicle = GetCurrentVehicle(); if (vehicle != null && vehicle.IsCar()) { uiIndex = WheelEntityUtility.GetUiWheelIndex(vehicle, index); return(vehicle.vehicleBrokenFlag.IsVehiclePartBroken(index)); } return(false); }
public virtual float DecreaseHp(VehiclePartIndex partIndex, float amount, EUIDeadType damageType, EntityKey damageSource) { if (partIndex == VehiclePartIndex.Body) { if (Hp > 0 && Hp < amount) { LastDamageType = damageType; LastDamageSource = damageSource; } Hp = Hp < amount ? 0.0f : Hp - amount; return(Hp); } return(0.0f); }
public static bool HasWheel(VehicleEntity vehicle, VehiclePartIndex index) { switch (index) { case VehiclePartIndex.FirstWheel: return(vehicle.hasCarFirstRewnWheel); case VehiclePartIndex.SecondWheel: return(vehicle.hasCarSecondRewnWheel); case VehiclePartIndex.ThirdWheel: return(vehicle.hasCarThirdRewnWheel); case VehiclePartIndex.FourthWheel: return(vehicle.hasCarFourthRewnWheel); default: return(false); } }
public static void EnableWheelRender(VehicleEntity vehicle, VehiclePartIndex index, bool enabled) { var go = vehicle.gameObject; var controllerIndex = VehicleIndexHelper.ToVehicleControllerWheelIndex(index); var controller = go.UnityObjWrapper.Value.GetComponent <VehicleAbstractController>(); var rendererRoot = controller.GetTireMeshRenderRoot(controllerIndex); if (rendererRoot == null) { var meshRender = controller.GetTireMeshRender(controllerIndex); if (meshRender != null && meshRender.enabled != enabled) { meshRender.enabled = enabled; } } else if (rendererRoot.gameObject.activeSelf != enabled) { rendererRoot.gameObject.SetActive(enabled); } }
public float GetWheelHp(VehiclePartIndex index) { switch (index) { case VehiclePartIndex.FirstWheel: return(FirstWheelHp); case VehiclePartIndex.SecondWheel: return(SecondWheelHp); case VehiclePartIndex.ThirdWheel: return(ThirdWheelHp); case VehiclePartIndex.FourthWheel: return(FourthWheelHp); default: throw new Exception("Undefined Vehicle Wheel Index!"); } }
private void SetWheelBroken(VehicleEntity vehicle, VehiclePartIndex index) { AssertUtility.Assert(index != VehiclePartIndex.Body); var controller = vehicle.GetController <VehicleAbstractController>(); var controllerIndex = VehicleIndexHelper.ToVehicleControllerWheelIndex(index); controller.SetWheelBroken(controllerIndex); if (!controller.IsKinematic) { var config = controller.GetComponent <VehicleConfig>(); var impulse = config.wheelExplosionImpulse; if (impulse > 0) { var force = controller.transform.up * impulse * controller.cachedRigidbody.mass; vehicle.AddImpulseAtPosition(force, controller.GetWheel(controllerIndex).wheelTransform.position); } } vehicle.vehicleBrokenFlag.SetVehiclePartColliderBroken(index); }
private void SetShipRudderState(VehicleEntity vehicle, VehiclePartIndex index, RudderState state) { var rudder = ShipEntityUtility.GetRudder(vehicle, index); rudder.Angle = state.Angle; }
public bool IsVehiclePartColliderBroken(VehiclePartIndex index) { AssertUtility.Assert(index != VehiclePartIndex.Body); return((ColliderFlag & (1 << ((int)index + 1))) != 0); }
public void SetVehiclePartColliderBroken(VehiclePartIndex index) { AssertUtility.Assert(index != VehiclePartIndex.Body); ColliderFlag |= 1 << ((int)index + 1); }
public static int ToVehicleControllerRudderIndex(VehiclePartIndex index) { return((int)index - (int)VehiclePartIndex.FirstRudder); }
public static int ToVehicleControllerWheelIndex(VehiclePartIndex index) { return((int)index - (int)VehiclePartIndex.FirstWheel); }
public static float GetHitFactor(this VehicleEntity vehicle, Collider collider, out VehiclePartIndex partIndex) { return(EntityAPI[vehicle.GetTypeValue()].GetHitFactor(vehicle, collider, out partIndex)); }
protected virtual void SetWheel(VehicleEntity vehicle, VehiclePartIndex index, WheelAbstractState state) { var comp = WheelEntityUtility.GetWheel(vehicle, index); comp.ColliderSteerAngle = state.ColliderSteerAngle; }
public float DecreaseHp(VehiclePartIndex partIndex, float amount) { return(DecreaseHp(partIndex, amount, EUIDeadType.Weapon, EntityKey.Default)); }
public float DecreaseHp(VehiclePartIndex partIndex, float amount, EntityKey damageSource) { return(DecreaseHp(partIndex, amount, EUIDeadType.Weapon, damageSource)); }
public float DecreaseHp(VehiclePartIndex partIndex, float amount, EUIDeadType damageType) { return(DecreaseHp(partIndex, amount, damageType, EntityKey.Default)); }
public override float DecreaseHp(VehiclePartIndex index, float amount, EUIDeadType damageType, EntityKey damageSource) { AssertUtility.Assert(amount >= 0); return(base.DecreaseHp(index, amount, damageType, damageSource)); }