Exemplo n.º 1
0
Sensor::ThreatLevel::Value Sensor::IdentifyThreat(const Track& track) const
{
    assert(player);

    if (!UseThreatAssessment())
        return ThreatLevel::None;

    if (track.IsExploding())
        return ThreatLevel::None;

    if (track.HasWeaponLock())
    {
        // I am being targetted by...
        switch (track.GetType())
        {
        case Track::Type::Missile:
            return ThreatLevel::High;

        case Track::Type::CapitalShip:
            if (track.GetRelation() == Track::Relation::Enemy)
                return ThreatLevel::Medium;
            break;

        case Track::Type::Ship:
            if (track.HasTurrets())
                return ThreatLevel::Medium;

            if (!track.HasWeapons())
            {
                // So what are you going to threaten me with? Exhaustion gas?
                return ThreatLevel::None;
            }
            break;

        default:
            break;
        }
        return ThreatLevel::Low;
    }
    return ThreatLevel::None;
}
Exemplo n.º 2
0
GFXColor Sensor::GetColor(const Track& track) const
{
    assert(player);

    static GFXColor friendColor  = RetrColor("friend", GFXColor(-1, -1, -1, -1));
    static GFXColor enemyColor   = RetrColor("enemy", GFXColor(-1, -1, -1, -1));
    static GFXColor neutralColor = RetrColor("neutral", GFXColor(-1, -1, -1, -1));
    static GFXColor baseColor    = RetrColor("base", GFXColor( -1, -1, -1, -1 ));
    static GFXColor planetColor  = RetrColor("planet", GFXColor( -1, -1, -1, -1 ));
    static GFXColor jumpColor    = RetrColor("jump", GFXColor( 0, 1, 1, .8 ));
    static GFXColor navColor     = RetrColor("nav", GFXColor( 1, 1, 1, 1 ));
    static GFXColor starColor    = RetrColor("star", GFXColor( 1, 1, 1, 1 ));
    static GFXColor missileColor = RetrColor("missile", GFXColor( .25, 0, .5, 1 ));
    static GFXColor cargoColor   = RetrColor("cargo", GFXColor( .6, .2, 0, 1 ));
    static GFXColor noColor      = RetrColor("black_and_white", GFXColor( .5, .5, .5 ));

    Track::Type::Value trackType = track.GetType();
    ThreatLevel::Value threatLevel = IdentifyThreat(track);

    if (UseThreatAssessment())
    {
        switch (trackType)
        {
        case Track::Type::Missile:
            return missileColor;

        default:
            break;
        }
    }

    if (UseObjectRecognition())
    {
        switch (trackType)
        {
        case Track::Type::Nebula:
        case Track::Type::Star:
            return starColor;

        case Track::Type::Planet:
        case Track::Type::DeadPlanet:
            return planetColor;

        case Track::Type::Base:
            if (track.HasLock())
                return enemyColor;
            return baseColor;

        case Track::Type::JumpPoint:
            return jumpColor;

        default:
            break;
        }
    }

    if (UseFriendFoe())
    {
        switch (trackType)
        {
        case Track::Type::CapitalShip:
        case Track::Type::Ship:
            {
                if (track.HasLock())
                    return enemyColor;

                switch (track.GetRelation())
                {
                case Track::Relation::Friend:
                    return friendColor;

                case Track::Relation::Enemy:
                    if (UseThreatAssessment() && (threatLevel == ThreatLevel::None))
                        return neutralColor;

                    return enemyColor;

                default:
                    return neutralColor;
                }
            }

        case Track::Type::Cargo:
            return cargoColor;

        default:
            break;
        }
    }
    return noColor;
}