public void RemoveTargetLocksOnDestruction(GenericShip ship) { while (true) { BlueTargetLockToken token = ship.GetToken(typeof(BlueTargetLockToken), '*') as BlueTargetLockToken; if (token != null) { ship.RemoveToken(token.GetType(), token.Letter); } else { break; } } while (true) { RedTargetLockToken token = ship.GetToken(typeof(RedTargetLockToken), '*') as RedTargetLockToken; if (token != null) { ship.RemoveToken(token.GetType(), token.Letter); } else { break; } } }
private static void FinishAcquireTargetLock(GenericShip thisShip, GenericShip targetShip, Action callback) { BlueTargetLockToken tokenBlue = new BlueTargetLockToken(thisShip); RedTargetLockToken tokenRed = new RedTargetLockToken(targetShip); char letter = GetFreeTargetLockLetter(); tokenBlue.Letter = letter; tokenBlue.OtherTokenOwner = targetShip; tokenRed.Letter = letter; tokenRed.OtherTokenOwner = thisShip; TakeTargetLockLetter(letter); targetShip.Tokens.AssignToken( tokenRed, delegate { thisShip.Tokens.AssignToken(tokenBlue, delegate { thisShip.CallOnTargetLockIsAcquiredEvent(targetShip, callback); }); } ); }
private void ReassignTLTokens(List <RedTargetLockToken> tokens) { if (tokens.Count == 0) { SelectShipSubPhase.FinishSelectionNoCallback(); AskAbility(HostShip, new EventArgs()); // weird hack gotta be a better way of doing this return; } RedTargetLockToken token = tokens[0]; tokens.RemoveAt(0); ActionsHolder.ReassignToken(token, TargetShip, HostShip, delegate { ReassignTLTokens(tokens); }); }
private void BreakAllLocksRecursive(Action callback) { RedTargetLockToken redTlToken = HostShip.Tokens.GetToken <RedTargetLockToken>(letter: '*'); if (redTlToken != null) { Messages.ShowInfo("Lock \"" + redTlToken.Letter + "\" is broken"); HostShip.Tokens.RemoveToken( redTlToken, delegate { BreakAllLocksRecursive(callback); } ); } else { callback(); } }
private void ChooseToken(object sender, EventArgs e) { if (HostShip.Owner.Type == PlayerType.Ai) { DamageSourceEventArgs electronicBaffleDamage = new DamageSourceEventArgs() { Source = "Electronic Battle", DamageType = DamageTypes.CardAbility }; double DamageLevel = (double)(HostShip.State.HullCurrent + HostShip.State.ShieldsCurrent) / (HostShip.State.HullMax + HostShip.State.ShieldsMax); if (DamageLevel > .34 && HostShip.Tokens.HasToken(typeof(IonToken)) && HostShip.Tokens.CountTokensByType(typeof(IonToken)) == Edition.Current.NegativeTokensToAffectShip[HostShip.ShipInfo.BaseSize]) { SelectedToken = HostShip.Tokens.GetToken(typeof(IonToken)); HostShip.Damage.TryResolveDamage(1, electronicBaffleDamage, RemoveTokenAI); } else if (DamageLevel > .75 && HostShip.Tokens.HasToken(typeof(StressToken))) { SelectedToken = HostShip.Tokens.GetToken(typeof(StressToken)); HostShip.Damage.TryResolveDamage(1, electronicBaffleDamage, RemoveTokenAI); } else if (DamageLevel > .99) { Random rnd = new Random(); SelectedToken = RedTokens[rnd.Next(RedTokens.Count)]; HostShip.Damage.TryResolveDamage(1, electronicBaffleDamage, RemoveTokenAI); } else { Triggers.FinishTrigger(); } } else { DecisionSubPhase pilotAbilityDecision = (DecisionSubPhase)Phases.StartTemporarySubPhaseNew( Name, typeof(ElectronicBaffleDecisionSubphase), Triggers.FinishTrigger ); pilotAbilityDecision.InfoText = "Electronic Baffle: Choose which token to remove"; pilotAbilityDecision.RequiredPlayer = HostShip.Owner.PlayerNo; foreach (var Token in RedTokens) { string name = Token.Name; if (Token.GetType() == typeof(RedTargetLockToken)) { RedTargetLockToken targetLockToken = (RedTargetLockToken)Token; name = Token.Name + " " + targetLockToken.Letter; } pilotAbilityDecision.AddDecision(name, delegate { DamageSourceEventArgs electronicBaffleDamage = new DamageSourceEventArgs() { Source = "Electronic Battle", DamageType = DamageTypes.CardAbility }; SelectedToken = Token; HostShip.Damage.TryResolveDamage(1, electronicBaffleDamage, RemoveToken); }); } pilotAbilityDecision.ShowSkipButton = true; pilotAbilityDecision.Start(); } }
public void AssignToken(RedTargetLockToken token, Action callback) { Tokens.AssignToken(token, callback); }
public void AssignToken(RedTargetLockToken token, Action callback) { Tokens.Add(token); //TODO: Show token on obstacle callback(); }