public void EndFrame() { float realtimeSinceStartup = Time.realtimeSinceStartup; float num = realtimeSinceStartup - lastAssetUpdate; if (num >= 10f) { lastAssetUpdate = realtimeSinceStartup; if (AutomaticMemorySampling) { UpdateAssetMemoryUsage(); } } updateMetrics(); num = realtimeSinceStartup - lastTime; lastTime = realtimeSinceStartup; FrameTime.UpdateValue(num * 1000f); frameCount++; num = realtimeSinceStartup - lastFPSUpdate; if (num >= 1f) { lastFPSUpdate = lastTime; FramesPerSecond.UpdateValue((int)Math.Round((float)frameCount / num)); frameCount = 0uL; } }
static public FramesPerSecond GetInstance() { if (Instance == null) { GameObject obj = new GameObject("_FramesPerSecond"); obj.transform.position = new Vector3(0.05f, 0.05f, 0.0f); DontDestroyOnLoad(obj); Instance = obj.AddComponent <FramesPerSecond>(); } return(Instance); }
public void Update() { var info = GetFrameInfo(); if (info == null) { return; } if (FramesPerSecond.Count < 1) { info.TimeDiff = 0.0; } FramesPerSecond.Add(info); }
static public FramesPerSecond GetInstance() { if (Instance == null) { GameObject obj = new GameObject("_FramesPerSecond"); obj.transform.position = new Vector3(0.05f, 0.05f, 0.0f); GUIText guiTextObj = obj.AddComponent <GUIText>(); guiTextObj.fontSize = 16; guiTextObj.fontStyle = FontStyle.Bold; DontDestroyOnLoad(obj); Instance = obj.AddComponent <FramesPerSecond>(); } return(Instance); }
static public SetPanelCtrl GetInstance() { if (Instance == null) { GameObject obj = new GameObject("_SetPanelCtrl"); //DontDestroyOnLoad(obj); Instance = obj.AddComponent <SetPanelCtrl>(); if (!FreeModeCtrl.IsServer) { pcvr.GetInstance(); } FramesPerSecond.GetInstance(); ScreenLog.init(); } return(Instance); }
protected override Dictionary <string, string> GetParameters(string applicationKey, string signature, string callBackURL, string dataName, string dataValue) { Dictionary <string, string> parameters = CreateParameters(applicationKey, signature, callBackURL, dataName, dataValue); parameters.Add("width", Width.ToString()); parameters.Add("height", Height.ToString()); parameters.Add("duration", Duration.ToString()); parameters.Add("speed", Speed.ToString()); parameters.Add("customwatermarkid", CustomWaterMarkId); parameters.Add("start", Start.ToString()); parameters.Add("fps", FramesPerSecond.ToString()); parameters.Add("repeat", Repeat.ToString()); parameters.Add("reverse", Convert.ToInt32(Reverse).ToString()); parameters.Add("quality", Quality.ToString()); return(parameters); }
internal Video( string fileName, GraphicsDevice device, int durationMS, int width, int height, float framesPerSecond, VideoSoundtrackType soundtrackType ) : this(fileName, device) { /* If you got here, you've still got the XNB file! Well done! * Except if you're running FNA, you're not using the WMV anymore. * But surely it's the same video, right...? * Well, consider this a check more than anything. If this bothers * you, just remove the XNB file and we'll read the OGV straight up. * -flibit */ if (width != Width || height != Height) { throw new InvalidOperationException( "XNB/OGV width/height mismatch!" + " Width: " + Width.ToString() + " Height: " + Height.ToString() ); } if (Math.Abs(FramesPerSecond - framesPerSecond) >= 1.0f) { throw new InvalidOperationException( "XNB/OGV framesPerSecond mismatch!" + " FPS: " + FramesPerSecond.ToString() ); } // FIXME: Oh, hey! I wish we had this info in Theora! Duration = TimeSpan.FromMilliseconds(durationMS); needsDurationHack = false; VideoSoundtrackType = soundtrackType; }
public Status(JObject jsonObj) { addr = jsonObj["addr"].ToString(); status = jsonObj["status"].ToString(); DateTime startFrominit = (DateTime)jsonObj["startFrom"]; startFrom = startFrominit.ToString("yyyy-MM-ddTHH:mm:ssZ"); try { bytesPerSecond = (float)jsonObj["bytesPerSecond"]; float audio = (float)jsonObj["framesPerSecond"]["audio"]; float video = (float)jsonObj["framesPerSecond"]["video"]; float data = (float)jsonObj["framesPerSecond"]["data"]; framesPerSecond = new FramesPerSecond(audio, video, data); } catch (System.NullReferenceException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } mJsonString = jsonObj.ToString(); }
/// <inheritdoc /> public int CompareTo(Framerate other) => FramesPerSecond.CompareTo(other.FramesPerSecond);
/// <summary> /// Combine multiple Frames Per Seconds into smallest FrameRate that will Capture all Timestamps.... /// </summary> /// <param name="FramesPerSecond"></param> /// <returns></returns> public static int Combine(params int[] FramesPerSecond) { return(FramesPerSecond.Aggregate((S, val) => S * val / GetGCD(S, val))); }
public Status(JObject jsonObj) { addr = jsonObj["addr"].ToString(); status = jsonObj["status"].ToString(); DateTime startFrominit = (DateTime)jsonObj["startFrom"]; startFrom = startFrominit.ToString("yyyy-MM-ddTHH:mm:ssZ"); try { bytesPerSecond = (float)jsonObj["bytesPerSecond"]; float audio = (float)jsonObj["framesPerSecond"]["audio"]; float video = (float)jsonObj["framesPerSecond"]["video"]; float data = (float)jsonObj["framesPerSecond"]["data"]; framesPerSecond = new FramesPerSecond(audio, video, data); } catch (System.NullReferenceException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } mJsonString = jsonObj.ToString(); }
public AudioClip correctSound; public AudioClip fallSound; public AudioClip openBoxSound; private AudioSource source; // Messages to the screen private string displayMessage = "noMessage"; public string textMessage = ""; public bool displayCue; public bool interactableObjectVisible; public int trialScore = 0; public int totalScore = 0; public int nextScore; public bool flashTotalScore = false; public bool scoreUpdated = false; public bool pauseClock = false; public bool congratulated = false; public bool audioFeedbackSounded = false; public bool flashColourFeedback = false; // Timer variables private Timer experimentTimer; private Timer stateTimer; private Timer movementTimer; private Timer restbreakTimer; private Timer getReadyTimer; public Timer messageTimer; public float responseTime; public float totalExperimentTime; public float currentTickingTrialTime; // current trial time for measuring RX. Measured from 'go' cue public bool displayTimeLeft; public float maxResponseTime; private float preDisplayCueTime; private float goCueDelay; private float displayCueTime; private float finalGoalHitPauseTime; public float displayMessageTime; public float errorDwellTime; public float restbreakDuration; public float elapsedRestbreakTime; public float getReadyTime; public float getReadyDuration; public float pausePriorFeedbackTime; private float feedbackFlashDuration; public float dataRecordFrequency; // NOTE: this frequency is referred to in TrackingScript.cs for player data and here for state data public float timeRemaining; private float minFramerate = 30f; // minimum fps required for decent gameplay on webGL build (fps depends on user's browser and plugins) // Error flags public bool FLAG_trialError; public bool FLAG_trialTimeout; public bool FLAG_fullScreenModeError; public bool FLAG_dataWritingError; // Game-play state machine states public const int STATE_STARTSCREEN = 0; public const int STATE_SETUP = 1; public const int STATE_STARTTRIAL = 2; public const int STATE_CUEAPPEAR = 3; public const int STATE_DELAY = 4; public const int STATE_GO = 5; public const int STATE_MOVING = 6; public const int STATE_CHOICEMADE = 7; public const int STATE_FINISH = 8; public const int STATE_NEXTTRIAL = 9; public const int STATE_INTERTRIAL = 10; public const int STATE_TIMEOUT = 11; public const int STATE_ERROR = 12; public const int STATE_FEEDBACK = 13; public const int STATE_REST = 14; public const int STATE_GETREADY = 15; public const int STATE_PAUSE = 16; public const int STATE_EXIT = 17; public const int STATE_MAX = 18; private string[] stateText = new string[] { "StartScreen","Setup","StartTrial","CueAppear","Delay","Go","Moving","ChoiceMade", "Finish","NextTrial","InterTrial","Timeout","Error","Feedback","Rest","GetReady","Pause","Exit","Max" }; public int State; public int previousState; // Currently unused, but useful for transitioning back to same point in gameplay following an event public List<string> stateTransitions = new List<string>(); // recorded state transitions private bool gameStarted = false; // ********************************************************************** // void Awake () // Awake() executes once before anything else { // Make GameController a singleton if (control == null) // if control doesn't exist, make it { DontDestroyOnLoad(gameObject); control = this; } else if (control != this) // if control does exist, destroy it { Destroy(gameObject); } } // ********************************************************************** // private void Start() // Start() executes once when object is created { dataController = FindObjectOfType<DataController>(); // usually we should be careful with 'Find', but since there is only one DataController should be ok. source = GetComponent<AudioSource>(); frameRateMonitor = GetComponent<FramesPerSecond>(); // Trial invariant data filepath = dataController.filePath; Debug.Log("File path: " + filepath); dataRecordFrequency = dataController.GetRecordFrequency(); restbreakDuration = dataController.GetRestBreakDuration(); getReadyDuration = dataController.GetGetReadyDuration(); // Initialise the timers experimentTimer = new Timer(); movementTimer = new Timer(); messageTimer = new Timer(); restbreakTimer = new Timer(); getReadyTimer = new Timer(); // Initialise FSM State State = STATE_STARTSCREEN; previousState = STATE_STARTSCREEN; stateTimer = new Timer(); stateTimer.Reset(); stateTransitions.Clear(); // Ensure cue images are off displayCue = false; interactableObjectVisible = false; StartExperiment(); } // ********************************************************************** // private void Update() // Update() executes once per frame { UpdateText(); CheckFullScreen(); if (!pauseClock) { currentTickingTrialTime = movementTimer.ElapsedSeconds(); } switch (State) { case STATE_STARTSCREEN: // Note: we chill out here in this state until all the starting info pages are done if (gameStarted) { StateNext(STATE_SETUP); } break; case STATE_SETUP: switch (TrialSetup()) { case "StartTrial": // ensure the reward is hidden from sight interactableObjectVisible = false; StateNext(STATE_STARTTRIAL); break; case "Menus": // ***HRS to remove: this case should never have to do anything break; case "GetReady": getReadyTimer.Reset(); StateNext(STATE_GETREADY); break; case "RestBreak": restbreakTimer.Reset(); StateNext(STATE_REST); break; case "Exit": totalExperimentTime = experimentTimer.ElapsedSeconds(); EnableCursor(true); StateNext(STATE_EXIT); break; } break; case STATE_STARTTRIAL: StartRecording(); // Wait until the goal/target cue appears if (stateTimer.ElapsedSeconds() >= preDisplayCueTime) {
// float TimeSetEnterMoveBt; // ButtonState SetEnterBtSt = ButtonState.UP; void Update() { // if (SetEnterBtSt == ButtonState.DOWN && Time.time - TimeSetEnterMoveBt > 2f) { // HardwareCheckCtrl.OnRestartGame(); // } if (pcvr.bIsHardWare && !pcvr.IsTestGetInput) { return; } PlayerFX[0] = Input.GetAxis("Horizontal"); PlayerYM[0] = Input.GetAxis("Vertical"); if (!pcvr.IsTestBianMaQi) { PlayerTB[0] = Input.GetMouseButton(0) == true ? 1f : 0f; } if (Input.GetKeyUp(KeyCode.T)) { GlobalData.GetInstance().Icon++; } if (Input.GetKeyDown(KeyCode.Space)) { InputEventCtrl.PlayerSC[0] = 1f; } if (Input.GetKeyUp(KeyCode.Space)) { InputEventCtrl.PlayerSC[0] = 0f; } //StartBt if (Input.GetKeyUp(KeyCode.G)) { ClickStartBt(ButtonState.UP); } if (Input.GetKeyDown(KeyCode.G)) { ClickStartBt(ButtonState.DOWN); } //setPanel enter button if (Input.GetKeyUp(KeyCode.F4)) { ClickSetEnterBt(ButtonState.UP); } if (Input.GetKeyDown(KeyCode.F4)) { ClickSetEnterBt(ButtonState.DOWN); } //setPanel move button if (Input.GetKeyUp(KeyCode.F5)) { ClickSetMoveBt(ButtonState.UP); FramesPerSecond.GetInstance().ClickSetMoveBtEvent(ButtonState.UP); } if (Input.GetKeyDown(KeyCode.F5)) { ClickSetMoveBt(ButtonState.DOWN); FramesPerSecond.GetInstance().ClickSetMoveBtEvent(ButtonState.DOWN); } //Fire button if (Input.GetKeyUp(KeyCode.F)) { ClickFireBt(ButtonState.UP); } if (Input.GetKeyDown(KeyCode.F)) { ClickFireBt(ButtonState.DOWN); } //OutCard button if (Input.GetKeyUp(KeyCode.O)) { ClickStopDongGanBt(ButtonState.UP); } if (Input.GetKeyDown(KeyCode.O)) { ClickStopDongGanBt(ButtonState.DOWN); } }
/// <summary> /// Inicializacion del componente /// </summary> private void Start() { // Obtengo los id de las capas PlayerLayer = LayerMask.NameToLayer("Player"); ObstaclesLayer = LayerMask.NameToLayer("Obstacles"); // Busco componentes FPS = GetComponent<FramesPerSecond>(); Track = GetComponent<PlayerTrack>(); MemoryStats = GetComponent<ShowMemoryStats>(); TargetFrameRate = LastFrameRate = -1; // Solo inicializo si hay un game manager //if (GameManager.Instance) // Time = GameManager.Instance.GetComponent<TimeManager>(); // Solo inicializo estos si hay un Player asignado if (Player) { InmunityComponent = Player.GetComponentInChildren<Inmunity>(); FSM = Player.GetComponentInChildren<PlayerManager>(); } // Inicializo GUI InmortalText = "Inmortal"; GUISettings(); // SETEAR EL FRAME RATE DE LA APLICACION Application.targetFrameRate = 60; }