Exemple #1
0
        public void RemoveToken(GenericToken tokenToRemove, Action callback)
        {
            if (Host.CanRemoveToken(tokenToRemove))
            {
                AssignedTokens.Remove(tokenToRemove);

                if (tokenToRemove.GetType().BaseType == typeof(GenericTargetLockToken))
                {
                    ITargetLockable otherTokenOwner = (tokenToRemove as GenericTargetLockToken).OtherTargetLockTokenOwner;
                    ActionsHolder.ReleaseTargetLockLetter((tokenToRemove as GenericTargetLockToken).Letter);
                    Type oppositeType = (tokenToRemove.GetType() == typeof(BlueTargetLockToken)) ? typeof(RedTargetLockToken) : typeof(BlueTargetLockToken);

                    char         letter = (tokenToRemove as GenericTargetLockToken).Letter;
                    GenericToken otherTargetLockToken = otherTokenOwner.GetAnotherToken(oppositeType, letter);
                    if (otherTargetLockToken != null)
                    {
                        otherTokenOwner.RemoveToken(otherTargetLockToken);
                        if (otherTokenOwner is GenericShip)
                        {
                            (otherTokenOwner as GenericShip).CallOnRemoveTokenEvent(otherTargetLockToken);
                        }
                    }
                }

                tokenToRemove.WhenRemoved();
                Host.CallOnRemoveTokenEvent(tokenToRemove);
            }
            Triggers.ResolveTriggers(TriggerTypes.OnTokenIsRemoved, callback);
        }
Exemple #2
0
        public List <char> GetTargetLockLetterPairsOn(ITargetLockable targetShip)
        {
            List <char> result = new List <char>();

            List <BlueTargetLockToken> blueTokens = GetTokens <BlueTargetLockToken>('*');

            foreach (BlueTargetLockToken blueToken in blueTokens)
            {
                char foundLetter = (blueToken as BlueTargetLockToken).Letter;

                GenericToken redToken = targetShip.GetAnotherToken(typeof(RedTargetLockToken), foundLetter);
                if (redToken != null)
                {
                    result.Add(blueToken.Letter);
                }
            }

            return(result);
        }