本文整理汇总了C#中Vehicle.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Vehicle.GetComponent方法的具体用法?C# Vehicle.GetComponent怎么用?C# Vehicle.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle.GetComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
protected virtual void Awake()
{
pond = Pond.Instance;
vehicle = GetComponentInParent<Vehicle>();
entity = vehicle.GetComponent<Entity>();
if (randomWeightChangingDelay.To > 0)
{
randomWeightChangingCountdown = new Countdown(0);
}
ChooseRandomWeightFactor();
}
示例2: CycleSquadron
private void CycleSquadron(int dir)
{
var oldSquadronIndex = Squadron.GetCurrentIndex();
var cycleResult = Squadron.CycleSquadronIndex(dir);
Debug.LogFormat("CYCLE {0} => {1}", oldSquadronIndex, Squadron.GetCurrentIndex());
if (cycleResult > -1)
{
if (Squadron.GetCurrentMember() != null)
{
// Set previous controlled vehicle to NPC control
var oldMember = Squadron.GetMember(oldSquadronIndex);
if (_playVehicleInstance != null && oldMember != null)
{
if (_playVehicleInstance.PrimaryWeaponInstance != null)
_playVehicleInstance.PrimaryWeaponInstance.ClearTargetLock();
if (_playVehicleInstance.SecondaryWeaponInstance != null)
_playVehicleInstance.SecondaryWeaponInstance.ClearTargetLock();
_playVehicleInstance.gameObject.layer = LayerMask.NameToLayer("Default");
_playVehicleInstance.MeshTransform.gameObject.layer = LayerMask.NameToLayer("Default");
oldMember.SetVehicleInstance(_playVehicleInstance);
oldMember.enabled = true;
oldMember.VehicleInstance.GetComponent<SquadronTracker>().IsDisabled = false;
oldMember.VehicleInstance.GetComponent<MapPin>().SetPinState(MapPin.MapPinState.Inactive);
oldMember.VehicleInstance.Killable.OnDamage -= PlayerController_OnDamage;
oldMember.VehicleInstance.Killable.OnDie -= PlayerController_OnDie;
oldMember.VehicleInstance.GetComponent<ShieldRegenerator>().OnRegenerate -= PlayerController_OnRegenerate;
}
// Disable next vehicle NPC control and apply PlayerController
var curMember = Squadron.GetCurrentMember();
if (curMember.VehicleInstance != null)
{
var profile = curMember.GetComponent<ShipProfile>();
HeadsUpDisplay.Current.ShowSquadronPrompt(profile.CallSign);
_playVehicleInstance = curMember.VehicleInstance;
_playVehicleInstance.GetComponent<SquadronTracker>().IsDisabled = true;
_playVehicleInstance.gameObject.layer = LayerMask.NameToLayer("Player");
_playVehicleInstance.MeshTransform.gameObject.layer = LayerMask.NameToLayer("Player");
_playVehicleInstance.GetComponent<MapPin>().SetPinState(MapPin.MapPinState.Active);
_playVehicleInstance.Killable.OnDamage += PlayerController_OnDamage;
_playVehicleInstance.Killable.OnDie += PlayerController_OnDie;
_playVehicleInstance.GetComponent<ShieldRegenerator>().OnRegenerate += PlayerController_OnRegenerate;
_playVehicleInstance.Controller = gameObject;
_curCallSlign = profile.CallSign;
curMember.enabled = false;
Universe.Current.WarpTo(_playVehicleInstance.Shiftable);
var cam = Universe.Current.ViewPort.GetComponent<VehicleCamera>();
cam.Target = _playVehicleInstance;
cam.DistanceBehind = _playVehicleInstance.CameraDistance;
cam.Reset();
}
if (OnChangeSquadronMember != null)
OnChangeSquadronMember(oldMember.gameObject, gameObject);
}
HeadsUpDisplay.Current.RefreshSquadronIcon(Squadron.GetCurrentIndex());
HeadsUpDisplay.Current.RefreshSquadronIcon(oldSquadronIndex);
HeadsUpDisplay.Current.ShowCrosshair();
}
else
{
Debug.Log("ALL DEAD!");
}
}
示例3: SpawnVehicle
public void SpawnVehicle(Vehicle vehiclePrefab, UniversePosition universePosition, Quaternion rotation)
{
_playVehicleInstance = ((GameObject)Instantiate(vehiclePrefab.gameObject, universePosition.CellLocalPosition, rotation)).GetComponent<Vehicle>();
_playVehicleInstance.Controller = gameObject;
_playVehicleInstance.Shiftable.SetShiftPosition(universePosition);
_playVehicleInstance.GetComponent<Targetable>().Team = Team;
var member = GetComponent<Fighter>();
member.SetVehicleInstance(_playVehicleInstance);
_playVehicleInstance.Initialize();
var playerCurrent = Squadron.GetMember(Squadron.GetCurrentIndex()).GetComponent<ShipProfile>();
if (playerCurrent.PrimaryWeapon != null)
_playVehicleInstance.SetPrimaryWeapon(playerCurrent.PrimaryWeapon.gameObject);
if (playerCurrent.SecondaryWeapon != null)
_playVehicleInstance.SetSecondaryWeapon(playerCurrent.SecondaryWeapon.gameObject);
_playVehicleInstance.UTurnPath = UTurnPath;
_playVehicleInstance.UTurnDuration = UTurnDuration;
//Destroy(_playVehicleInstance.GetComponent<Tracker>());
Destroy(_playVehicleInstance.GetComponent<VehicleTracker>());
var squadronTracker = _playVehicleInstance.gameObject.AddComponent<SquadronTracker>();
squadronTracker.ArrowSprite = Squadron.ArrowSprite;
//squadronTracker.TrackerSprite = Squadron.TrackerSprite;
//squadronTracker.FarTrackerSprite = Squadron.FarTrackerSprite;
//squadronTracker.VeryFarTrackerSprite = Squadron.VeryFarTrackerSprite;
squadronTracker.LockingSprite = Squadron.LockingTrackerSprite;
squadronTracker.LockedSprite = Squadron.LockedTrackerSprite;
squadronTracker.CallSign = CallSign;
squadronTracker.TrackerColor = TrackerColor;
squadronTracker.LabelFont = Squadron.SquadronTrackerFont;
squadronTracker.IsDisabled = true;
var mapPin = VehicleInstance.gameObject.AddComponent<MapPin>();
mapPin.ActivePin = PlayerPinPrefab;
mapPin.InactivePin = Squadron.SquadronPinPrefab;
_playVehicleInstance.gameObject.layer = LayerMask.NameToLayer("Player");
_playVehicleInstance.Killable.OnDamage += PlayerController_OnDamage;
_playVehicleInstance.Killable.OnDie += PlayerController_OnDie;
// Apply power profile
var powerProfile = GetComponent<ShipProfile>();
_playVehicleInstance.Killable.MaxShield = powerProfile.GetShield();
_playVehicleInstance.Killable.Shield = _playVehicleInstance.Killable.MaxShield;
var shieldRegenerator = _playVehicleInstance.gameObject.GetComponent<ShieldRegenerator>();
shieldRegenerator.RegenerationDelay = Squadron.ShieldRegenerateDelay;
shieldRegenerator.RegenerationRate = Squadron.ShieldRegenerateRate;
shieldRegenerator.OnRegenerate += PlayerController_OnRegenerate;
}