コード例 #1
0
    /*
     * Creates a new persister object - writes to DB or log files
     */
    public SimPersister(SimManager simScript, string conn)
    {
        this.simScriptComp = simScript;

        Debug.Log("Setting persistence file name.");
        this.participantName = ParticipantData.name;
        this.startTime       = System.DateTime.Now;
        this.logFileName     = LOG_FILE_PREF + participantName + startTime.ToString(LOG_FILE_PATT) + LOG_FILE_SUFF;

        if (conn != null)
        {
            // TODO
            int a = 1;
        }
        else
        {
            // TODO - log something here?
            int a = 1;
        }

        // Check for file here + make sure valid directory
        if (!System.IO.Directory.Exists(Application.dataPath + "/OutputData"))
        {
            System.IO.Directory.CreateDirectory(Application.dataPath + "/OutputData");
        }

        System.IO.File.CreateText(Application.dataPath + "/OutputData/" + logFileName).Dispose();
        fileWriter = new System.IO.StreamWriter(Application.dataPath + "/OutputData/" + logFileName, true);
        writeIntroduction();
    }
コード例 #2
0
 void Start()
 {
     this.simScriptComp         = this.simManager.GetComponent <SimManager>();
     this.audioManagerComponent = audioManager.GetComponent <AudioManager>();
     soundOn = false;
     elapsed = 0.0f;
 }
コード例 #3
0
 private void QuitToMainMenu()
 {
     DataLogger.Dump();
     SimManager.SetStatus(SimulationStatus.Paused);
     SimManager.Quit();
     SimManager.Instance.StartCoroutine(LoadMainMenu());
 }
コード例 #4
0
        public void TryStartSimulation()
        {
            if (resultWaiting)
            {
                atmLastStage = SimManager.LastAtmStage;
                vacLastStage = SimManager.LastVacStage;

                atmoStats = SimManager.AtmStages;
                vacStats  = SimManager.VacStages;

                resultWaiting = false;
            }

            // I m cheating with the isActiveVessel. Need to add multiple ship handling but it is
            // an edge case that only triggers if 2 nearby ships burn nodes. is this worth the complexity ?
            if ((HighLogic.LoadedSceneIsEditor || vessel.isActiveVessel) && SimManager.ResultsReady())
            {
                if (updateRequested)
                {
                    updateRequested = false;
                    StartSimulation();
                }
                else
                {
                    users.Clear();
                }
            }
        }
コード例 #5
0
        public void noLogPrecModeTest()
        {
            OutputManager outMan = new OutputManager();
            SimManager    simMan = new SimManager(outMan);
            OutputPanelVM outpan = new OutputPanelVM();

            outMan.link(new DisplayVM(), new FileModel(outMan), outpan, simMan);
            double precision = 0.0001;

            simMan.CompStep_    = 2;
            simMan.Duration_    = 5;
            simMan.accuracyMode = true;

            outpan.fromSim      = true;
            outpan.EnableLog    = false;
            outpan.DisplayEnbld = true;
            outpan.DisplayStep  = "1";
            outpan.TargetFile   = "C:\\Users\\Doz\\Source\\Repos\\Physics_Simulator\\ConsoleEntryPoint\\UnitTestOutputFile.txt";

            if (!System.IO.File.Exists(outpan.TargetFile))
            {
                System.IO.File.Create(outpan.TargetFile);
            }

            simMan.addMaterialPoint(0, 0, 0, 0, 0, 0, 1, 0);
            simMan.addActionPoint(0, 0.5, 1, 10.5);
            outMan.launch();

            System.IO.File.Delete(outpan.TargetFile);

            Assert.IsTrue(simMan.sceneElems_[0] - 0.5 * 0.5 * 25 < precision);
            Assert.IsTrue(simMan.sceneElems_[1] - 0.5 * 25 < precision);
            Assert.IsTrue(simMan.sceneElems_[2] - 0.5 * 10.5 * 25 < precision);
        }
コード例 #6
0
        public void RToutputTest()
        {
            OutputManager outMan = new OutputManager();
            SimManager    simMan = new SimManager(outMan);
            OutputPanelVM outpan = new OutputPanelVM();

            outMan.link(new DisplayVM(), new FileModel(outMan), outpan, simMan);

            simMan.CompStep_    = 2;
            simMan.accuracyMode = false;

            outpan.fromSim      = true;
            outpan.EnableLog    = false;
            outpan.DisplayEnbld = true;
            outpan.DisplayStep  = "1";

            simMan.addMaterialPoint(0, 0, 0, 0, 0, 0, 1, 0);
            simMan.addActionPoint(0, 0.5, 1, 10.5);

            outMan.launch();
            System.Threading.Thread.Sleep(5000);
            outMan.stopTimer();
            double t = 5;

            Assert.IsTrue(simMan.sceneElems_[0] < 0.5 * 0.5 * (t + simMan.CompStep_) * (t + simMan.CompStep_));
            Assert.IsTrue(simMan.sceneElems_[0] > 0.5 * 0.5 * (t - simMan.CompStep_) * (t - simMan.CompStep_));
        }
コード例 #7
0
ファイル: QE_Vessel.cs プロジェクト: stasikos/QuickMods
 internal static void StartSim()
 {
     simEnded = false;
     SimManager.RequestSimulation();
     SimManager.TryStartSimulation();
     Log("Simulation started", "QVessel");
 }
コード例 #8
0
        private void UpdateEditor()
        {
            UpdatePanels();

            if (!_updateSimulator)
            {
                return;
            }

            _updateSimulator = false;

            try
            {
                SimManager.Gravity = _currentBody.GeeASL * GRAVITY;

                if (Atmosphere)
                {
                    SimManager.Atmosphere = _currentBody.GetPressure(_atmosphereDepth) * PhysicsGlobals.KpaToAtmospheres;
                }
                else
                {
                    SimManager.Atmosphere = 0;
                }

                SimManager.Mach = _mach;

                SimManager.RequestSimulation();
                SimManager.TryStartSimulation();
            }
            catch (Exception e)
            {
                BasicLogger.Exception(e, "BasicDeltaV.Update()");
            }
        }
コード例 #9
0
    private void Awake()
    {
        if (_sim != null && _sim != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _sim = this;
        }

        // Populate offices
        offices = new List <GameObject>();
        Room[] temp = officesParent.GetComponentsInChildren <Room>();
        foreach (Room t in temp)
        {
            if (t.gameObject.GetInstanceID() != officesParent.GetInstanceID())
            {
                offices.Add(t.gameObject);
            }
        }

        // Populate discussion rooms
        discussionRooms = new List <GameObject>();
        Room[] temp2 = discussionRoomParent.GetComponentsInChildren <Room>();
        foreach (Room t in temp2)
        {
            if (t.gameObject.GetInstanceID() != discussionRoomParent.GetInstanceID())
            {
                discussionRooms.Add(t.gameObject);
            }
        }
    }
コード例 #10
0
ファイル: VOID_HUDModule.cs プロジェクト: yadenisyur/VOID
        public override void DrawGUI(object sender)
        {
            if (this.core == null)
            {
                return;
            }

            VOID_Styles.labelHud.normal.textColor = textColors [ColorIndex];

            GUI.skin = this.core.Skin;

            if (HighLogic.LoadedSceneIsEditor ||
                (TimeWarp.WarpMode == TimeWarp.Modes.LOW) || (TimeWarp.CurrentRate <= TimeWarp.MaxPhysicsRate)
                )
            {
                SimManager.RequestSimulation();
            }

            HUDWindow window;

            for (int idx = 0; idx < this.Windows.Count; idx++)
            {
                window = this.Windows[idx];

                window.WindowPos = GUILayout.Window(
                    this.core.WindowID,
                    window.WindowPos,
                    VOID_Tools.GetWindowHandler(window.WindowFunction),
                    GUIContent.none,
                    GUIStyle.none
                    );
            }
        }
コード例 #11
0
        private void SetVesselInfo()
        {
            SimManager.Gravity = CelestialBodies.SelectedBody.Gravity;

            if (BuildAdvanced.Instance.ShowAtmosphericDetails)
            {
                SimManager.Atmosphere = CelestialBodies.SelectedBody.GetAtmospheres(BuildAdvanced.Altitude);
            }
            else
            {
                SimManager.Atmosphere = 0.0;
            }

            SimManager.RequestSimulation();
            SimManager.TryStartSimulation();

            if (lastStage != null)
            {
                PartInfoItem.Release(infoItems);
                infoItems.Clear();
                infoItems.Add(PartInfoItem.Create("Delta-V", lastStage.deltaV.ToString("N0") + " / " + lastStage.totalDeltaV.ToString("N0") + "m/s"));
                infoItems.Add(PartInfoItem.Create("Mass", Units.ToMass(lastStage.mass, lastStage.totalMass)));
                infoItems.Add(PartInfoItem.Create("TWR", lastStage.thrustToWeight.ToString("F2") + " (" + lastStage.maxThrustToWeight.ToString("F2") + ")"));
                infoItems.Add(PartInfoItem.Create("Parts", lastStage.partCount + " / " + lastStage.totalPartCount));
            }
        }
コード例 #12
0
ファイル: MultiDayUIUpdate.cs プロジェクト: tonyxmella66/zp18
    // Cache all key components for efficient access and destroy / nullify
    // all unneeded components and game objects
    void Start()
    {
        // Existing fields
        this.simManComp        = this.simManager.GetComponent <SimManager>();
        this.timeRemComp       = this.timeRemainingText.GetComponent <UnityEngine.UI.Text>();
        this.dayTextComp       = this.dayText.GetComponent <UnityEngine.UI.Text>();
        this.wageTextComp      = this.wageText.GetComponent <UnityEngine.UI.Text>();
        this.totalEarningsComp = this.totalEarnings.GetComponent <UnityEngine.UI.Text>();

        // Each combination of texts
        this.oneDayEarnDollarsComp     = this.oneDayEarnDollars.GetComponent <UnityEngine.UI.Text>();
        this.oneDayEarnTitleComp       = this.oneDayEarnTitle.GetComponent <UnityEngine.UI.Text>();
        this.twoDayEarnDollars_1Comp   = this.twoDayEarnDollars_1.GetComponent <UnityEngine.UI.Text>();
        this.twoDayEarnDollars_2Comp   = this.twoDayEarnDollars_2.GetComponent <UnityEngine.UI.Text>();
        this.twoDayEarnTitle_1Comp     = this.twoDayEarnTitle_1.GetComponent <UnityEngine.UI.Text>();
        this.twoDayEarnTitle_2Comp     = this.twoDayEarnTitle_2.GetComponent <UnityEngine.UI.Text>();
        this.threeDayEarnDollars_1Comp = this.threeDayEarnDollars_1.GetComponent <UnityEngine.UI.Text>();
        this.threeDayEarnDollars_2Comp = this.threeDayEarnDollars_2.GetComponent <UnityEngine.UI.Text>();
        this.threeDayEarnDollars_3Comp = this.threeDayEarnDollars_3.GetComponent <UnityEngine.UI.Text>();
        this.threeDayEarnTitle_1Comp   = this.threeDayEarnTitle_1.GetComponent <UnityEngine.UI.Text>();
        this.threeDayEarnTitle_2Comp   = this.threeDayEarnTitle_2.GetComponent <UnityEngine.UI.Text>();
        this.threeDayEarnTitle_3Comp   = this.threeDayEarnTitle_3.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnDollars_1Comp  = this.fourDayEarnDollars_1.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnDollars_2Comp  = this.fourDayEarnDollars_2.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnDollars_3Comp  = this.fourDayEarnDollars_3.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnDollars_4Comp  = this.fourDayEarnDollars_4.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnTitle_1Comp    = this.fourDayEarnTitle_1.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnTitle_2Comp    = this.fourDayEarnTitle_2.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnTitle_3Comp    = this.fourDayEarnTitle_3.GetComponent <UnityEngine.UI.Text>();
        this.fourDayEarnTitle_4Comp    = this.fourDayEarnTitle_4.GetComponent <UnityEngine.UI.Text>();

        this.currentDayInt = 0;
    }
コード例 #13
0
 public override void OnStart(PartModule.StartState state)
 {
     SimManager.UpdateModSettings();
     SimManager.OnReady -= this.GetStageInfo;
     SimManager.OnReady += this.GetStageInfo;
     base.OnAwake();
 }
コード例 #14
0
    // Use this for initialization
    void Start()
    {
        // Set static variable so everything can access this
        instance             = this;
        globalTableSnapshots = new List <float[, ]>();
        globalTable          = new ResourceValueTable();

        // Ensure at least 1 group and 1 agent are in the simulation
        if (numberOfGroups <= 0)
        {
            numberOfGroups = 1;
        }
        if (numberOfAgentsPerGroup <= 0)
        {
            numberOfAgentsPerGroup = 1;
        }

        // Generate a new seed if one is not specified
        System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
        if (seed == 0)
        {
            seed = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds;
        }

        // Initialize the seed and print it to the console
        Random.InitState(seed);
        print("Seed: " + seed);

        // Setup the appriopriate array
        colors      = new Color[numberOfGroups];
        populations = new int[numberOfGroups];
        for (int j = 0; j < colors.Length; j++)   // Generate colors for each group. Ensure that each colour is somewhat different.
        {
            bool validColor = false;
            int  iter       = 0;
            while (!validColor && iter < 100)
            {
                iter++;
                colors[j]  = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
                validColor = true;
                for (int k = 0; k < colors.Length; k++)
                {
                    if (j == k || colors[k] == null)
                    {
                        continue;
                    }
                    else if (Vector3.Distance(new Vector3(colors[j].r, colors[j].g, colors[j].b), new Vector3(colors[k].r, colors[k].g, colors[k].b)) < 0.5f)                       // Treat the colours as Vector3s in order to computer difference
                    {
                        validColor = false;
                        break;
                    }
                }
            }
        }

        // Setup the rest of the simulation
        SpawnResources();
        SpawnAgents();
    }
コード例 #15
0
    private void Start()
    {
        sim = SimManager._sim;

        nearbyPeople = new List <GameObject>();

        InfectionCd = sim.personInteractionDuration;
    }
コード例 #16
0
 // Awake is called when this agent is instantiated, used to assign traits
 void Awake()
 {
     simScript         = GameObject.Find("SimManager").GetComponent <SimManager>();
     age               = 0;
     altruismBonus     = 5f;
     travelTime        = 0.5f;
     markedForDeletion = false;
 }
コード例 #17
0
 internal void CompleteJob(Job job)
 {
     _data.incompleteJobs.Remove(job);
     _data.CompletedJobCount++;
     SimManager.UpdateCompleteCount();
     SimManager.AllIncompleteJobs.Remove(job);
     SimManager.AllJobs.Remove(job);
 }
コード例 #18
0
 private void OnEnable()
 {
     if (SimManager.Status != SimulationStatus.Paused && SimManager.Status != SimulationStatus.EditMode)
     {
         SimManager.SetStatus(SimulationStatus.Paused);
     }
     _index = (int)Count++;
 }
コード例 #19
0
 public void JobDequeued(bool isDelayed)
 {
     _data.NumberOfJobsInQueue--;
     SimManager.JobDequeued();
     if (isDelayed)
     {
         DequeuedDelay();
     }
 }
コード例 #20
0
 public void UpdateDelay(float dt)
 {
     _data.TotalDelayOfCompletedJobs += dt;
     if (dt > 0)
     {
         UpdateDelayCount();
     }
     SimManager.UpdateDelay(dt);
 }
コード例 #21
0
 protected override void Start()
 {
     Buttons[0].onClick.AddListener(QuitToMainMenu);
     Buttons[1].onClick.AddListener(SaveSimulation);
     Buttons[2].onClick.AddListener(LoadSimulation);
     Buttons[3].onClick.AddListener(ExportToCSV);
     Buttons[4].onClick.AddListener(() => SimManager.SetStatus(SimulationStatus.EditMode));
     base.Start();
 }
コード例 #22
0
    void Start()
    {
        if (!flowLimitEnabled)
        {
            flowManager.GetComponent <FlowManager>().startFlow();
        }

        this.simManComponent  = simManager.GetComponent <SimManager>();
        this.flowManComponent = flowManager.GetComponent <FlowManager>();
    }
コード例 #23
0
ファイル: UIUpdate.cs プロジェクト: tonyxmella66/zp18
 void Start()
 {
     this.simManComp         = simManager.GetComponent <SimManager>();
     this.timeRemComp        = timeRemainingText.GetComponent <UnityEngine.UI.Text>();
     this.dayTextComp        = dayText.GetComponent <UnityEngine.UI.Text>();
     this.moneyTextComp      = moneyText.GetComponent <UnityEngine.UI.Text>();
     this.todayMoneyTextComp = todayMoneyText.GetComponent <UnityEngine.UI.Text>();
     this.totalDays          = simManComp.getTotalDays().ToString();
     this.wageTextComp       = wageText.GetComponent <UnityEngine.UI.Text>();
 }
コード例 #24
0
 void Start()
 {
     this.simManagerComponent   = simManager.GetComponent <SimManager>();
     this.audioManagerComponent = audioManager.GetComponent <AudioManager>();
     this.payTextComp           = payText.GetComponent <UnityEngine.UI.Text>();
     this.waitTextComp          = waitText.GetComponent <UnityEngine.UI.Text>();
     treatmentDay = false;
     justWait     = false;
     justPay      = false;
 }
コード例 #25
0
        public static void LookHere(Vector3 position)
        {
            position.y = 0;
            SimManager.HighlightPosition(position);
            var back = -CameraTransform.forward;

            position += back * ActiveCamera.transform.position.y / back.y;
            ActiveCamera.StopCoroutine(FlyTowards(position));
            ActiveCamera.StartCoroutine(FlyTowards(position));
        }
コード例 #26
0
 private void QuitToMainMenu()
 {
     SimManager.SimStatus = SimulationStatus.Paused;
     SimManager.ClearObjects();
     BatteryData.Reset();
     DroneData.Reset();
     HubData.Reset();
     NFZData.Reset();
     StartCoroutine(LoadMainMenu());
 }
コード例 #27
0
 public void FailJob()
 {
     IsDataStatic = true;
     GetDrone().AssignJob(null);
     AssignDrone(null);
     _Data.status    = JobStatus.Failed;
     _Data.completed = _EoT;
     _Data.earnings  = -Loss;
     SimManager.UpdateRevenue(Earnings);
 }
コード例 #28
0
ファイル: SimManager.cs プロジェクト: lizhidong815/RobotVR
 private void Awake()
 {
     if (instance == null || instance == this)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
コード例 #29
0
ファイル: Person.cs プロジェクト: Kichlids/CoronaSimulation
    private void Start()
    {
        sim           = SimManager._sim;
        agent         = GetComponent <NavMeshAgent>();
        agent.enabled = true;

        sim.people.Add(gameObject);

        Init();

        ClaimEmptyOffice();
    }
コード例 #30
0
        public void CompleteJob()
        {
            _Data.completed = TimeKeeper.Chronos.Get().SetReadOnly();
            _Data.status    = JobStatus.Complete;
            IsDataStatic    = true;

            GetDrone().CompleteJob();
            AssignDrone(null);
            _Data.earnings = _Data.costFunction.GetPaid(CompletedOn, Deadline);
            SimManager.UpdateDelay(Deadline.Timer());
            SimManager.UpdateRevenue(Earnings);
        }