Example #1
0
    public List <Token> getPickableTokens()
    {
        CaseBehavior currentCell = caseActuelle.GetComponent <CaseBehavior>();

        if (currentCell.isNonWoundedEnemyPresent(gameObject))
        {
            return(new List <Token>());                                                 // cannot pick an object when a non wounded enemy is present
        }
        List <Token> result = new List <Token>();

        foreach (Token token in currentCell.tokens_)
        {
            if (token.GetComponent <CharacterBehavior>() != null)
            {
                CharacterBehavior otherCharacter = token.GetComponent <CharacterBehavior>();
                if (otherCharacter != this && otherCharacter.affiliationJoueur == affiliationJoueur && otherCharacter.wounded && otherCharacter.tokenHolder != this)
                {
                    result.Add(token);                                                                                                                                                  // can autopick wounded ally that the character doesn't already carry
                }
            }
            else // item
            {
                // TODO: Fix the case where an ally thief is standing on the pit
                if (token.GetComponent <Item_Corde>() != null && currentCell.type == CaseBehavior.typeCase.caseFosse && currentCell.isOtherAllyPresent(this))
                {
                    continue; // cannot pick a rope on a pit where an ally is standing
                }
                if (token.tokenHolder != this)
                {
                    result.Add(token); // can pick an item that the character doesn't already carry
                }
            }
        }
        return(result);
    }