private IEnumerator DoSpawn(float delay, Action callback, Transform targetTransform) { yield return new WaitForSeconds(delay); if (!_hasSpawned) { _fighterInst = Instantiate<Fighter>(FighterPrefab); _fighterInst.SpawnVehicle(_fighterInst.gameObject, _fighterInst.VehiclePrefab, Universe.Current.GetUniversePosition(transform.position), transform.rotation); if (targetTransform != null) _fighterInst.SetTarget(targetTransform); if (AddWarpEffect) { _warpEffect = _fighterInst.VehicleInstance.gameObject.AddComponent<WarpEffect>(); _warpEffect.transform.position = transform.position; _warpEffect.transform.forward = transform.forward; _warpEffect.WarpEffectPrefab = SpawnEffect; _warpEffect.Timeout = 0.4f; _warpEffect.Distance = 20f; } _hasSpawned = true; if (callback != null) callback(); if (OnSpawn != null) OnSpawn(_fighterInst.gameObject); } }
public void SpawnSquadronVehicle(Fighter member, UniversePosition position, Quaternion rotation) { member.SpawnVehicle(member.gameObject, member.VehiclePrefab, position, rotation); var memberTracker = member.VehicleInstance.GetComponent<VehicleTracker>(); var profile = member.GetComponent<ShipProfile>(); if (profile.PrimaryWeapon != null) member.VehicleInstance.SetPrimaryWeapon(profile.PrimaryWeapon.gameObject); if (profile.SecondaryWeapon != null) member.VehicleInstance.SetSecondaryWeapon(profile.SecondaryWeapon.gameObject); var squadronTracker = member.VehicleInstance.gameObject.AddComponent<SquadronTracker>(); squadronTracker.ArrowSprite = memberTracker.ArrowSprite; //squadronTracker.TrackerSprite = memberTracker.TrackerSprite; //squadronTracker.FarTrackerSprite = memberTracker.FarTrackerSprite; //squadronTracker.VeryFarTrackerSprite = memberTracker.VeryFarTrackerSprite; squadronTracker.LockingSprite = memberTracker.LockingSprite; squadronTracker.LockedSprite = memberTracker.LockedSprite; squadronTracker.TrackerPlanePrefab = TrackerPlanePrefab; Destroy(memberTracker); squadronTracker.CallSign = profile.CallSign; squadronTracker.TrackerColor = TrackerColor; squadronTracker.LabelFont = SquadronTrackerFont; squadronTracker.IsDisabled = false; member.IsFollowIdleDestination = true; var mapPin = member.VehicleInstance.gameObject.AddComponent<MapPin>(); mapPin.ActivePin = PlayerController.Current.PlayerPinPrefab; mapPin.InactivePin = SquadronPinPrefab; mapPin.SetPinState(MapPin.MapPinState.Inactive); // Apply power profile member.VehicleInstance.Killable.MaxShield = profile.GetShield(); member.VehicleInstance.Killable.Shield = member.VehicleInstance.Killable.MaxShield; var squadronShieldRegenerator = member.VehicleInstance.gameObject.AddComponent<ShieldRegenerator>(); squadronShieldRegenerator.RegenerationDelay = ShieldRegenerateDelay; squadronShieldRegenerator.RegenerationRate = ShieldRegenerateRate; BindMemberEvents(member); member.enabled = true; }