Exemple #1
0
    public bool IsEnemy(CharacterStatus unit)
    {
        var identity = unit.characterIdentity;

        switch (identity)
        {
        case CharacterIdentity.transfiguration:
            if (playerNumber != unit.playerNumber)
            {
                var buff = (TransfigurationBuff)unit.Buffs.Find(b => b.GetType() == typeof(TransfigurationBuff));
                //buff中的目标不是自己人,则一定可以判定为敌人。
                if (buff.target.GetComponent <Unit>().playerNumber != playerNumber)
                {
                    return(true);
                }
                //buff中的目标是自己人,则只有与该目标相同外观的角色能判定其为敌人。
                else if (unit.GetComponentsInChildren <Renderer>()[0].material.name.Contains(GetComponentsInChildren <Renderer>()[0].material.name))
                {
                    return(true);
                }
            }
            break;

        default:
            return(playerNumber != unit.playerNumber);
        }
        return(false);
    }