Ejemplo n.º 1
0
    /// <summary>
    /// Necessary so that the gameObject can be exposed to the radiation.
    /// Performs all the needed steps for calculating and recieving the radiation.
    /// </summary>
    private void GetAndApplyDose()
    {
        if (RaySource.Instance == null)
        {
            return;
        }

        // update vertices
        controller.UpdateVertices(RaySource.Instance.transform.position);
        controller.SortOutUnhittedVertices(RaySource.Instance.RayTracer);

        // get doses
        float[] distances  = RaySource.Instance.RayTracer.GetDistances(controller.GetRelevantVerticePositions());
        float[] addedDoses = DoseCalculator.Calculate(distances, RaySource.Instance.BaseEnergy, Time.fixedDeltaTime);

        // store doses
        controller.StoreDoses(addedDoses);

        // calculate colors and avg. dose
        float[] accumulatedDoses = controller.VerticeData.Select(x => x.Dose).ToArray();
        float   avgDose          = DoseCalculator.GetAVGDose(accumulatedDoses);

        Color32[] colors = ColorCalculator.Calculate(accumulatedDoses);

        // appy colors and avg. dose
        container.ApplyColors(colors);
        DoseInfo.Instance.Controller.SetAVGDose(avgDose);
    }
Ejemplo n.º 2
0
    public void CalculateReturnsExpectedColors_Test(float[] doses, float[] r, float[] g, float [] b)
    {
        // setup
        Color32[] rgbColors = GetColors(r, g, b);

        // perform
        Color32[] colors = ColorCalculator.Calculate(doses);

        // assert
        Assert.AreEqual(rgbColors, colors);
    }