public override void DiscardEffect(Ship.GenericShip host) { Messages.ShowInfo("Pilot Skill is restored"); host.RemoveToken(typeof(Tokens.DamagedCockpitCritToken)); host.RemovePilotSkillModifier(this); Roster.UpdateShipStats(host); }
public static bool AssignTargetLockToPair(Ship.GenericShip thisShip, Ship.GenericShip targetShip) { bool result = false; if (Letters.Count == 0) { InitializeTargetLockLetters(); } ShipDistanceInformation distanceInfo = new ShipDistanceInformation(thisShip, targetShip); if (distanceInfo.Range < 4) { Tokens.GenericToken existingBlueToken = thisShip.GetToken(typeof(Tokens.BlueTargetLockToken), '*'); if (existingBlueToken != null) { if ((existingBlueToken as Tokens.BlueTargetLockToken).LockedShip != null) { (existingBlueToken as Tokens.BlueTargetLockToken).LockedShip.RemoveToken(typeof(Tokens.RedTargetLockToken), (existingBlueToken as Tokens.BlueTargetLockToken).Letter); } thisShip.RemoveToken(typeof(Tokens.BlueTargetLockToken), (existingBlueToken as Tokens.BlueTargetLockToken).Letter); } Tokens.BlueTargetLockToken tokenBlue = new Tokens.BlueTargetLockToken(); Tokens.RedTargetLockToken tokenRed = new Tokens.RedTargetLockToken(); char letter = GetFreeTargetLockLetter(); tokenBlue.Letter = letter; tokenBlue.LockedShip = targetShip; tokenRed.Letter = letter; TakeTargetLockLetter(letter); Selection.ThisShip.AssignToken(tokenBlue); targetShip.AssignToken(tokenRed); result = true; } else { Messages.ShowErrorToHuman("Target is out of range of Target Lock"); } return(result); }
public static void AssignTargetLockToPair(Ship.GenericShip thisShip, Ship.GenericShip targetShip, Action successCallback, Action failureCallback) { if (Letters.Count == 0) { InitializeTargetLockLetters(); } ShipDistanceInformation distanceInfo = new ShipDistanceInformation(thisShip, targetShip); if (distanceInfo.Range >= thisShip.TargetLockMinRange && distanceInfo.Range <= thisShip.TargetLockMaxRange) { Tokens.GenericToken existingBlueToken = thisShip.GetToken(typeof(Tokens.BlueTargetLockToken), '*'); if (existingBlueToken != null) { thisShip.RemoveToken(typeof(Tokens.BlueTargetLockToken), (existingBlueToken as Tokens.BlueTargetLockToken).Letter); } Tokens.BlueTargetLockToken tokenBlue = new Tokens.BlueTargetLockToken(); Tokens.RedTargetLockToken tokenRed = new Tokens.RedTargetLockToken(); char letter = GetFreeTargetLockLetter(); tokenBlue.Letter = letter; tokenBlue.OtherTokenOwner = targetShip; tokenRed.Letter = letter; tokenRed.OtherTokenOwner = Selection.ThisShip; TakeTargetLockLetter(letter); targetShip.AssignToken( tokenRed, delegate { thisShip.AssignToken(tokenBlue, successCallback); }); } else { Messages.ShowErrorToHuman("Target is out of range of Target Lock"); failureCallback(); } }
public void RemoveToken(System.Type type, char letter = ' ', bool recursive = false) { Tokens.GenericToken assignedToken = GetToken(type, letter); if (assignedToken != null) { if (assignedToken.Count > 1) { assignedToken.Count--; if (AfterTokenIsRemoved != null) { AfterTokenIsRemoved(this, type); } if (recursive) { RemoveToken(type, letter, true); } } else { AssignedTokens.Remove(assignedToken); if (AfterTokenIsRemoved != null) { AfterTokenIsRemoved(this, type); } if (assignedToken.GetType().BaseType == typeof(Tokens.GenericTargetLockToken)) { GenericShip otherTokenOwner = (assignedToken as Tokens.GenericTargetLockToken).OtherTokenOwner; Actions.ReleaseTargetLockLetter((assignedToken as Tokens.GenericTargetLockToken).Letter); System.Type oppositeType = (assignedToken.GetType() == typeof(Tokens.BlueTargetLockToken)) ? typeof(Tokens.RedTargetLockToken) : typeof(Tokens.BlueTargetLockToken); if (otherTokenOwner.HasToken(oppositeType, letter)) { otherTokenOwner.RemoveToken(oppositeType, letter); } } } } }