public void SensorsUpdate(SubsystemReferences subsysRef, ShipSensors Data)
    {
        detectedFarObjects   = new List <DetectedFarObject>();
        detectedCloseObjects = new List <DetectedCloseObject>();

        foreach (GWI_Detection detection in Data.GWInterferometer)
        {
            DetectedFarObject obj = new DetectedFarObject();
            obj.type     = detection.signature;
            obj.position = AngleToPosition(subsysRef.currentShipPositionWithinGalaxyMapNode,
                                           detection.angle, ShipSensors.GConstant / detection.waveAmplitude, true);
            obj.destinationName = detection.warpGateDestination;
            detectedFarObjects.Add(obj);
        }

        foreach (EMS_Detection detection in Data.EMSensor)
        {
            DetectedCloseObject obj = new DetectedCloseObject();
            obj.velocity = detection.velocity;
            obj.radius   = detection.radius;
            obj.position = AngleToPosition(subsysRef.currentShipPositionWithinGalaxyMapNode,
                                           detection.angle, ShipSensors.EMConstant / detection.signalStrength, false);
            obj.materialSignature = detection.materialSignature;
            foreach (SpaceMaterial material in Enum.GetValues(typeof(SpaceMaterial)))
            {
                if (Data.CheckSignatureForSpaceMaterial(detection.materialSignature, material))
                {
                    obj.materials.Add(material);
                }
            }
            detectedCloseObjects.Add(obj);
        }
    }
Ejemplo n.º 2
0
    void Start()
    {
        // Get Ship Components
        rigidBody2D      = GetComponent <Rigidbody2D>();
        circleCollider2D = GetComponent <CircleCollider2D>();
        shipSensors      = GetComponent <ShipSensors>();
        turret           = GetComponent <Turret>();
        thrusters        = GetComponent <Thrusters>();
        thrusters.thrusterControlInputs.OnWarpJumpTriggered += HandleWarpJumpTriggered;

        UpdateSystemReference();

        // Health Bar
        healthbar       = GameObject.FindGameObjectWithTag("HealthBar").GetComponent <Slider>();
        shipHealth      = 0f;
        healthbar.value = HealthRatio;
    }
 public void SensorsUpdate(SubsystemReferences subsysRef, ShipSensors Data)
 {
 }
    public void SensorsUpdate(SubsystemReferences subsysRef, ShipSensors Data)
    {
        double EMSangle;
        float  signalStrength;
        int    EMSsignature;

        float  EMSdistance;
        double EMSposX, EMSposY;

        Vector2 pos;
        Vector2 vel;

        bool water  = false;
        bool common = false;
        bool metal  = false;

        //empty lists
        GWIWarpData.RemoveAll();
        EMSData.RemoveAll();

        for (int i = 0; i < Data.EMSensor.Count; i++)
        {
            EMSangle       = (double)Data.EMSensor[i].angle;
            signalStrength = Data.EMSensor[i].signalStrength;
            EMSsignature   = Data.EMSensor[i].materialSignature;

            EMSdistance = ShipSensors.EMConstant / signalStrength;

            EMSposX = EMSdistance * Math.Cos(EMSangle);
            EMSposY = EMSdistance * Math.Sin(EMSangle);

            vel = Data.EMSensor[i].velocity;

            pos = new Vector2((float)EMSposX, (float)EMSposY);

            if (Data.CheckSignatureForSpaceMaterial(EMSsignature, SpaceMaterial.Water))
            {
                water = true;
            }
            if (Data.CheckSignatureForSpaceMaterial(EMSsignature, SpaceMaterial.Common))
            {
                common = true;
            }
            if (Data.CheckSignatureForSpaceMaterial(EMSsignature, SpaceMaterial.Metal))
            {
                metal = true;
            }

            EMSData.Add(new EMSDetection(pos, vel, EMSsignature, water, common, metal));
        }


        String           warpgateDest;
        double           angle;
        float            waveAmplitude;
        GravitySignature signature;

        SpaceMaterial[] material = { };

        //Good data
        float   distance;
        double  distX, distY;
        Vector2 vector;


        for (int i = 0; i < Data.GWInterferometer.Count; i++)
        {
            //get data
            warpgateDest  = Data.GWInterferometer[i].warpGateDestination;
            angle         = (double)Data.GWInterferometer[i].angle;
            waveAmplitude = Data.GWInterferometer[i].waveAmplitude;
            signature     = Data.GWInterferometer[i].signature;

            //distance = G / waveAmp
            distance = ShipSensors.GConstant / waveAmplitude;

            //distance for vectors
            distX = distance * Math.Cos(angle);
            distY = distance * Math.Sin(angle);

            vector = new Vector2((float)distX, (float)distY);

            if (signature == GravitySignature.WarpGate)
            {
                GWIWarpData.Add(new WarpStruct(vector, signature, warpgateDest));
            }
        }
    }