public virtual void Activate(Actor self, Order order, SupportPowerManager manager) { if (Info.DisplayRadarPing && manager.RadarPings != null) { ping = manager.RadarPings.Value.Add( () => order.Player.IsAlliedWith(self.World.RenderPlayer), order.Target.CenterPosition, order.Player.Color, Info.RadarPingDuration); } foreach (var notify in self.TraitsImplementing <INotifySupportPower>()) { notify.Activated(self); } }
public override void SelectTarget(Actor self, string order, SupportPowerManager manager) { if (info.UseDirectionalTarget) { Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName); self.World.OrderGenerator = new SelectDirectionalTarget(self.World, order, manager, Info.Cursor, info.TargetPlaceholderCursorAnimation, info.DirectionArrowAnimation, info.TargetPlaceholderCursorPalette, info.DirectionArrowPalette); } else { base.SelectTarget(self, order, manager); } }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); PlayLaunchSounds(); var info = Info as ProduceActorPowerInfo; var producers = self.World.ActorsWithTrait <Production>() .Where(x => x.Actor.Owner == self.Owner && !x.Trait.IsTraitDisabled && x.Trait.Info.Produces.Contains(info.Type)) .OrderByDescending(x => x.Actor.IsPrimaryBuilding()) .ThenByDescending(x => x.Actor.ActorID); // TODO: The power should not reset if the production fails. // Fixing this will require a larger rework of the support power code var activated = false; foreach (var p in producers) { foreach (var name in info.Actors) { var ai = self.World.Map.Rules.Actors[name]; var inits = new TypeDictionary { new OwnerInit(self.Owner), new FactionInit(BuildableInfo.GetInitialFaction(ai, faction)) }; activated |= p.Trait.Produce(p.Actor, ai, info.Type, inits, 0); } if (activated) { break; } } if (activated) { Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName); } else { Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.BlockedAudio, self.Owner.Faction.InternalName); } }
public SelectConditionTarget(World world, string order, SupportPowerManager manager, GrantExternalConditionPower power) { // Clear selection if using Left-Click Orders if (Game.Settings.Game.UseClassicMouseStyle) { manager.Self.World.Selection.Clear(); } this.manager = manager; this.order = order; this.power = power; footprint = power.info.Footprint.Where(c => !char.IsWhiteSpace(c)).ToArray(); dimensions = power.info.Dimensions; var sequence = world.Map.Rules.Sequences.GetSequence(power.info.FootprintImage, power.info.FootprintSequence); tile = sequence.GetSprite(0); alpha = sequence.GetAlpha(0); }
public SelectDirectionalTarget(World world, string order, SupportPowerManager manager, string cursor, string targetPlaceholderCursorAnimation, string directionArrowAnimation, string targetPlaceholderCursorPalette, string directionArrowPalette) { this.order = order; this.manager = manager; this.cursor = cursor; this.targetPlaceholderCursorPalette = targetPlaceholderCursorPalette; this.directionArrowPalette = directionArrowPalette; targetCursor = new Animation(world, targetPlaceholderCursorAnimation); targetCursor.PlayRepeating("cursor"); for (var i = 0; i < Game.Cursor.Frame; i++) { targetCursor.Tick(); } directionArrows = LoadArrows(directionArrowAnimation, world, arrows.Length); }
public SelectConditionTarget(World world, string order, SupportPowerManager manager, GrantExternalConditionPower power) { // Clear selection if using Left-Click Orders if (Game.Settings.Game.UseClassicMouseStyle) { manager.Self.World.Selection.Clear(); } this.manager = manager; this.order = order; this.power = power; foreach (var pair in power.info.Footprints) { footprints.Add(pair.Key, pair.Value.Where(c => !char.IsWhiteSpace(c)).ToArray()); } dimensions = power.info.Dimensions; tile = world.Map.Rules.Sequences.GetSequence("overlay", "target-select").GetSprite(0); }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); PlayLaunchSounds(); var wsb = self.TraitOrDefault <WithSpriteBody>(); if (wsb != null && wsb.DefaultAnimation.HasSequence(info.Sequence)) { wsb.PlayCustomAnimation(self, info.Sequence); } Game.Sound.Play(SoundType.World, info.OnFireSound, order.Target.CenterPosition); foreach (var a in UnitsInRange(self.World.Map.CellContaining(order.Target.CenterPosition))) { a.TraitsImplementing <ExternalCondition>() .FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(a, self)) ?.GrantCondition(a, self, info.Duration); } }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); var wsb = self.TraitOrDefault <WithSpriteBody>(); if (wsb != null && wsb.DefaultAnimation.HasSequence(info.GrantUpgradeSequence)) { wsb.PlayCustomAnimation(self, info.GrantUpgradeSequence, () => wsb.CancelCustomAnimation(self)); } Game.Sound.Play(info.GrantUpgradeSound, self.World.Map.CenterOfCell(order.TargetLocation)); foreach (var a in UnitsInRange(order.TargetLocation)) { var um = a.TraitOrDefault <UpgradeManager>(); if (um == null) { continue; } foreach (var u in info.Upgrades) { if (info.Duration > 0) { if (um.AcknowledgesUpgrade(a, u)) { um.GrantTimedUpgrade(a, u, info.Duration); } } else { if (um.AcceptsUpgrade(a, u)) { um.GrantUpgrade(a, u, this); } } } } }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { var info = Info as SpawnActorPowerInfo; var position = order.Target.CenterPosition; var cell = self.World.Map.CellContaining(position); if (!Validate(self.World, info, cell)) { return; } base.Activate(self, order, manager); self.World.AddFrameEndTask(w => { PlayLaunchSounds(); Game.Sound.Play(SoundType.World, info.DeploySound, position); if (!string.IsNullOrEmpty(info.EffectSequence) && !string.IsNullOrEmpty(info.EffectPalette)) { w.Add(new SpriteEffect(position, w, info.EffectImage, info.EffectSequence, info.EffectPalette)); } var actor = w.CreateActor(info.Actor, new TypeDictionary { new LocationInit(cell), new OwnerInit(self.Owner), }); if (info.LifeTime > -1) { actor.QueueActivity(new Wait(info.LifeTime)); actor.QueueActivity(new RemoveSelf()); } }); }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); var info = Info as ProduceActorPowerInfo; var sp = self.TraitsImplementing <Production>() .FirstOrDefault(p => p.Info.Produces.Contains(info.Type)); // TODO: The power should not reset if the production fails. // Fixing this will require a larger rework of the support power code var activated = false; if (sp != null) { foreach (var name in info.Actors) { var ai = self.World.Map.Rules.Actors[name]; var inits = new TypeDictionary { new OwnerInit(self.Owner), new FactionInit(BuildableInfo.GetInitialFaction(ai, faction)) }; activated |= sp.Produce(self, ai, info.Type, inits); } } if (activated) { Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName); } else { Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.BlockedAudio, self.Owner.Faction.InternalName); } }
public SelectNukePowerTarget(string order, SupportPowerManager manager, NukePowerInfo info, MouseButton button) : base(order, manager, info.Cursor, button) { this.info = info; }
public override void SelectTarget(Actor self, string order, SupportPowerManager manager) { self.World.OrderGenerator = new SelectNukePowerTarget(order, manager, info, MouseButton.Left); }
public virtual void SelectTarget(Actor self, string order, SupportPowerManager manager) { Game.Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound); self.World.OrderGenerator = new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left); }
public override void SelectTarget(Actor self, string order, SupportPowerManager manager) { self.World.IssueOrder(new Order(order, manager.Self, false)); }
public virtual SupportPowerInstance CreateInstance(string key, SupportPowerManager manager) { return(new SupportPowerInstance(key, info, manager)); }
public override void SelectTarget(Actor self, string order, SupportPowerManager manager) { self.World.OrderGenerator = new SelectConditionTarget(Self.World, order, manager, this); }
public virtual void SelectTarget(Actor self, string order, SupportPowerManager manager) { self.World.OrderGenerator = new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left); }
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) { Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound); return(new SelectTarget(Self.World, order, manager, this)); }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); SendParatroopers(self, self.World.Map.CenterOfCell(order.TargetLocation)); }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); if (self.Owner.IsAlliedWith(self.World.RenderPlayer)) { Game.Sound.Play(Info.LaunchSound); } else { Game.Sound.Play(Info.IncomingSound); } if (!string.IsNullOrEmpty(info.ActivationSequence)) { var wsb = self.Trait <WithSpriteBody>(); wsb.PlayCustomAnimation(self, info.ActivationSequence, () => wsb.CancelCustomAnimation(self)); } var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation); var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette; var missile = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown, self.CenterPosition + body.LocalToWorld(info.SpawnOffset), targetPosition, info.FlightVelocity, info.FlightDelay, info.SkipAscent, info.FlashType); self.World.AddFrameEndTask(w => w.Add(missile)); if (info.CameraActor != null) { var camera = self.World.CreateActor(false, info.CameraActor, new TypeDictionary { new LocationInit(order.TargetLocation), new OwnerInit(self.Owner), }); camera.QueueActivity(new Wait(info.CameraSpawnAdvance + info.CameraRemoveDelay)); camera.QueueActivity(new RemoveSelf()); Action addCamera = () => self.World.AddFrameEndTask(w => w.Add(camera)); self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.FlightDelay - info.CameraSpawnAdvance, addCamera))); } if (Info.DisplayBeacon) { var beacon = new Beacon( order.Player, targetPosition, Info.BeaconPaletteIsPlayerPalette, Info.BeaconPalette, Info.BeaconImage, Info.BeaconPoster, Info.BeaconPosterPalette, Info.ArrowSequence, Info.CircleSequence, Info.ClockSequence, () => missile.FractionComplete); Action removeBeacon = () => self.World.AddFrameEndTask(w => { w.Remove(beacon); beacon = null; }); self.World.AddFrameEndTask(w => { w.Add(beacon); w.Add(new DelayedAction(info.FlightDelay - info.BeaconRemoveAdvance, removeBeacon)); }); } }
protected override void Created(Actor self) { supportPowerManager = self.Owner.PlayerActor.Trait <SupportPowerManager>(); }
public override void SelectTarget(Actor self, string order, SupportPowerManager manager) { Game.Sound.PlayToPlayer(SoundType.World, manager.Self.Owner, Info.SelectTargetSound); self.World.OrderGenerator = new SelectConditionTarget(Self.World, order, manager, this); }
public virtual IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) { Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound); return(new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left)); }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); SendParatroopers(self, order.Target.CenterPosition, !info.UseDirectionalTarget || order.ExtraData == uint.MaxValue, (int)order.ExtraData); }
public SelectNukePowerTarget(string order, SupportPowerManager manager, NukePower power, MouseButton button) : base(order, manager, power.Info.Cursor, button) { this.power = power; }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); if (self.Owner.IsAlliedWith(self.World.RenderPlayer)) { Sound.Play(Info.LaunchSound); } else { Sound.Play(Info.IncomingSound); } var rb = self.Trait <RenderSimple>(); rb.PlayCustomAnim(self, "active"); var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation); var missile = new NukeLaunch(self.Owner, info.MissileWeapon, self.CenterPosition + body.LocalToWorld(info.SpawnOffset), targetPosition, info.FlightVelocity, info.FlightDelay, info.SkipAscent, info.FlashType); self.World.AddFrameEndTask(w => w.Add(missile)); if (info.CameraActor != null) { var camera = self.World.CreateActor(false, info.CameraActor, new TypeDictionary { new LocationInit(order.TargetLocation), new OwnerInit(self.Owner), }); camera.QueueActivity(new Wait(info.CameraSpawnAdvance + info.CameraRemoveDelay)); camera.QueueActivity(new RemoveSelf()); Action addCamera = () => self.World.AddFrameEndTask(w => w.Add(camera)); self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.FlightDelay - info.CameraSpawnAdvance, addCamera))); } if (Info.DisplayBeacon) { var beacon = new Beacon( order.Player, targetPosition, Info.BeaconPalettePrefix, Info.BeaconPoster, Info.BeaconPosterPalette, () => missile.FractionComplete); Action removeBeacon = () => self.World.AddFrameEndTask(w => { w.Remove(beacon); beacon = null; }); self.World.AddFrameEndTask(w => { w.Add(beacon); w.Add(new DelayedAction(info.FlightDelay - info.BeaconRemoveAdvance, removeBeacon)); }); } }
public SupportPowerInstance(string key, SupportPowerManager manager) { this.manager = manager; Key = key; }