Esempio n. 1
0
        /// <summary>
        /// Shared constructor for both pMC and standard (photon) databases
        /// </summary>
        /// <param name="virtualBoundaryType"></param>
        /// <param name="detectorInputs">List of IDetectorInputs designating binning</param>
        /// <param name="databaseInput">Database information needed for post-processing</param>
        private PhotonDatabasePostProcessor(
            VirtualBoundaryType virtualBoundaryType,
            IList <IDetectorInput> detectorInputs,
            SimulationInput databaseInput)
        {
            _rng = RandomNumberGeneratorFactory.GetRandomNumberGenerator(
                RandomNumberGeneratorType.MersenneTwister, -1); // -1 = random seed

            _virtualBoundaryType = virtualBoundaryType;

            _databaseInput = databaseInput;

            _tissue = Factories.TissueFactory.GetTissue(
                databaseInput.TissueInput,
                databaseInput.Options.AbsorptionWeightingType,
                databaseInput.Options.PhaseFunctionType,
                databaseInput.Options.RussianRouletteWeightThreshold);

            _detectors = DetectorFactory.GetDetectors(detectorInputs, _tissue, _rng);

            _detectorController = new DetectorController(_detectors);
        }
    public void FillUnitFields(GameObject unit)
    {
        IdentityController uid  = unit.GetComponent <IdentityController>();
        MoverController    umov = unit.GetComponent <MoverController>();
        DetectorController udet = unit.GetComponent <DetectorController>();
        HealthController   uhp  = unit.GetComponent <HealthController>();

        name = uid.GetLocalizedName();
        InputField namefield = NameVal.GetComponent <InputField> ();

        namefield.text = name;
        InputField currentHealth = CurHealthVal.GetComponent <InputField> ();

        curhp = uhp.GetCurrentHealth();
        currentHealth.text = uhp.GetCurrentHealth().ToString();
        InputField maxHealth = MaxHealthVal.GetComponent <InputField> ();

        maxhp          = uhp.GetMaxHealth();
        maxHealth.text = uhp.GetMaxHealth().ToString();
        InputField mov = MoveVal.GetComponent <InputField> ();

        move     = umov.GetIdealMoveRange();
        mov.text = move.ToString();

        InputField surfrange = SurfRadarVal.GetComponent <InputField> ();

        surfrange.text = udet.SurfaceRange.ToString();

        InputField airrange = AirRadarVal.GetComponent <InputField> ();

        airrange.text = udet.AirRange.ToString();

        InputField subrange = SubSonarVal.GetComponent <InputField> ();

        subrange.text = udet.SonarRange.ToString();

        FillWeaponDropdown(unit);
    }
    public void AlterUnitData()
    {
        //		IdentityController uid = currentObject.GetComponent <IdentityController>();
        //		MoverController umov = currentObject.GetComponent <MoverController>();
        //		DetectorController udet = currentObject.GetComponent <DetectorController>();
        //		AttackController uat = currentObject.GetComponent <AttackController>();
        //		HealthController uhp = currentObject.GetComponent <HealthController>();
        IdentityController uid = currentObject.GetComponent(
            ObjectFactoryHelper.DetermineControllerLiveObject(
                "Identity", currentObject)) as IdentityController;
        MoverController umov = currentObject.GetComponent(
            ObjectFactoryHelper.DetermineControllerLiveObject(
                "Mover", currentObject)) as MoverController;
        DetectorController udet = currentObject.GetComponent(
            ObjectFactoryHelper.DetermineControllerLiveObject(
                "Detector", currentObject)) as DetectorController;
        AttackController uat = currentObject.GetComponent(
            ObjectFactoryHelper.DetermineControllerLiveObject(
                "Attack", currentObject)) as AttackController;
        HealthController uhp = currentObject.GetComponent(
            ObjectFactoryHelper.DetermineControllerLiveObject(
                "Health", currentObject)) as HealthController;

        //Debug.Log ("max health at start: " + uhp.GetMaxHealth ());

        Single validator = 0.0f;
        //validate hp input
        string maxhpstring = MaxHealthVal.GetComponent <InputField> ().text;
        bool   maxhpvalid  = Single.TryParse(maxhpstring, out validator);

        float maxhp_event = uhp.GetMaxHealth();

        if (maxhpvalid)
        {
            maxhp_event = Single.Parse(maxhpstring);
            //uhp.SetMaxHealth(maxhp_event);
        }

        string namestring = NameVal.GetComponent <InputField>().text;

        string curhpstring = CurHealthVal.GetComponent <InputField> ().text;
        bool   curhpvalid  = Single.TryParse(curhpstring, out validator);
        float  curhp_event = uhp.GetCurrentHealth();

        if (curhpvalid)
        {
            curhp_event = Single.Parse(curhpstring);
            //uhp.SetCurrentHealth(curhp_event);
        }
        //same for movement
        string movstring = MoveVal.GetComponent <InputField> ().text;
        bool   movvalid  = Single.TryParse(movstring, out validator);
        float  mov_event = umov.GetMoveRange();

        if (movvalid)
        {
            mov_event = Single.Parse(movstring);
            //umov.SetMoveRange(mov_event);
        }

        ////Debug.Log ("max health after: " + uhp.GetMaxHealth ());

        //same for ranges

        string airstring = AirRadarVal.GetComponent <InputField> ().text;
        bool   airvalid  = Single.TryParse(airstring, out validator);

        float airval = 0f;

        if (airvalid)
        {
            airval = Single.Parse(airstring);
        }
        else
        {
            airval = udet.AirRange;
        }

        string surfstring = SurfRadarVal.GetComponent <InputField> ().text;
        bool   surfvalid  = Single.TryParse(surfstring, out validator);
        float  surfval    = 0f;

        if (surfvalid)
        {
            surfval = Single.Parse(surfstring);
        }
        else
        {
            surfval = udet.SurfaceRange;
        }
        string substring = SubSonarVal.GetComponent <InputField> ().text;
        bool   subvalid  = Single.TryParse(substring, out validator);
        float  subval    = 0f;

        if (subvalid)
        {
            subval = Single.Parse(substring);
        }
        else
        {
            subval = udet.SonarRange;
        }

        if (!namestring.Equals(name))
        {
            uid.ThrowNameChangeEvent(namestring);
        }

        uhp.ThrowMaxHealthChangeEvent(maxhp_event);
        uhp.ThrowCurrentHealthChangeEvent(curhp_event);
        umov.ThrowRangeChangeEvent(mov_event);
        udet.ThrowRangeChangeEvent(DetectorController.Event_Air_Change, airval);
        udet.ThrowRangeChangeEvent(DetectorController.Event_Surf_Change, surfval);
        udet.ThrowRangeChangeEvent(DetectorController.Event_Sonar_Change, subval);

        int    index     = WepDropdown.SelectedIndex;
        string comboname = WepDropdown.Items [index].LocalItem.ToString();

        AlterWeaponData(comboname);
    }
Esempio n. 4
0
 public AirRadarController(DetectorController detectorParent) : base(detectorParent)
 {
 }
Esempio n. 5
0
 public BaseDetectorController(DetectorController detectorParent)
 {
     DetectorParent = detectorParent;
 }
 public SonarController(DetectorController detectorParent) : base(detectorParent)
 {
 }
 public VisualDetectorController(DetectorController detectorParent) : base(detectorParent)
 {
 }
Esempio n. 8
0
    void Move(Vector2 v)
    {
        DetectorController dcCube = dcdcmap[v];

        GameObject dCube = dcmap[v];

        if (dcCube.ground == true)
        {
            //coordinates(snapObject.GetComponent<SegmentController>().GetCoordinates());
            //Walk normally
            float xx = (float)Math.Round(dCube.transform.position.x * 2, MidpointRounding.AwayFromZero) / 2;
            float yy = (float)Math.Round(dCube.transform.position.z * 2, MidpointRounding.AwayFromZero) / 2;
            if (xx % 2 == 0)
            {
                xx += 0.5f;
            }
            if (yy % 2 == 0)
            {
                yy += 0.5f;
            }
            aVector    = transform.position;
            bVector    = new Vector3(xx, transform.position.y, yy);
            lerpTimer  = 0f;
            snapObject = null;
        }

        if (dcCube.pit == true && dcCube.SnapObject() == null)
        {
            //Walk straight forward into the pit
            aVector    = transform.position;
            bVector    = transform.position + new Vector3(v.x, 0, v.y);
            lerpTimer  = 0f;
            snapObject = null;
        }

        if (dcCube.SnapObject() != null)
        {
            snapObject = dcCube.SnapObject();


            float xx = Math.Abs(snapObject.transform.position.x - dcCube.transform.position.x) * -Math.Sign(snapObject.transform.position.x - dcCube.transform.position.x);
            float zz = Math.Abs(snapObject.transform.position.z - dcCube.transform.position.z) * -Math.Sign(snapObject.transform.position.z - dcCube.transform.position.z);

            if (Math.Max(snapObject.transform.lossyScale.x, snapObject.transform.lossyScale.z) % 2 == 0)
            {
                if (snapObject.transform.localScale.x < snapObject.transform.localScale.z)
                {
                    zz = (float)Math.Round(zz) + 0.5f;
                    xx = (float)Math.Round(xx);
                }
                else
                {
                    xx = (float)Math.Round(xx) + 0.5f;
                    zz = (float)Math.Round(zz);
                }
            }
            else
            {
                if (snapObject.transform.localScale.x < snapObject.transform.localScale.z)
                {
                    zz = (float)Math.Round(zz);
                    xx = (float)Math.Round(xx);
                }
                else
                {
                    xx = (float)Math.Round(xx);
                    zz = (float)Math.Round(zz);
                }
            }


            if (zz > snapObject.transform.lossyScale.z / 2)
            {
                zz--;
            }
            if (xx > snapObject.transform.lossyScale.x / 2)
            {
                xx--;
            }

            snapPos   = new Vector3(xx, transform.position.y, zz);
            aVector   = transform.position;
            bVector   = new Vector3(snapObject.transform.position.x, 0, snapObject.transform.position.z) + snapPos;
            lerpTimer = 0f;
        }
    }
Esempio n. 9
0
 public SubmarineController(DetectorController detectorParent) : base(detectorParent)
 {
     Radar = new RadarController(detectorParent);
     Sonar = new SonarController(detectorParent);
 }
Esempio n. 10
0
 public void Setup()
 {
     _detectorController = new DetectorController(_logger.Object);
 }