예제 #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);
    }
예제 #2
0
    public void CalculateReturnsCorrectDoses_Test(float[] distances, float[] expected)
    {
        // perform
        float[] doses = DoseCalculator.Calculate(distances, 100f, 1f);

        // for easy readable numbers and corrections
        for (int i = 0; i < doses.Length; i++)
        {
            doses[i] = (float)Math.Round(doses[i], 3);
        }

        // assert
        Assert.AreEqual(expected, doses);
    }