public static GlobalTimeManager getInstance() { if (singleton == null) { GameObject globalHolder = new GameObject("GlobalManagers"); globalHolder.tag = "Global"; singleton = globalHolder.AddComponent <GlobalTimeManager> (); singleton.activeObjects = new List <TimeBasedObjects> (); } return(singleton); }
// Update is called once per frame void Update() { if (removeTime(GlobalTimeManager.getDeltaTime())) { //Game Over } if (display != null) { display.text = formatTime(timeLeft); } }
protected override void PausedUpdate() { float delta = GlobalTimeManager.getDeltaTime(); if (spawning && (lifeTimeSpawned + delta) < time.getTimeLeft()) { lifeTimeSpawned += delta; } subtractText.text = "-" + Timer.formatTime(lifeTimeSpawned); }
private void updateGameplayStack() { Vector3 finalPosition = Vector3.zero; Vector3 finalTarget = Vector3.zero; float totalBlend = 0; int length = gameCamStack.Count; for (int i = 0; i < length; i++) { CameraStackData c = gameCamStack.First.Value; float apparentBlending = 1.0f - totalBlend; //Hacky way to increment blend amount if (c.desiredBlend <= 0) { break; } else if (c.desiredBlend < 1.0) { c.desiredBlend += c.blendIncrement != -1.0f?c.blendIncrement * GlobalTimeManager.getDeltaTime():1.0f; } apparentBlending = apparentBlending > c.desiredBlend ? c.desiredBlend : apparentBlending; //Add to vector based on apparent blending amount finalPosition += c.cam.getPosition() * apparentBlending; finalTarget += c.cam.getTarget() * apparentBlending; totalBlend += apparentBlending; //Move camera to end of stack gameCamStack.RemoveFirst(); //If the camera isn't visible, remove it forever from the stack if (apparentBlending > 0) { gameCamStack.AddLast(c); } else { c.cam.Discard(); } } this.mainCam.transform.position = finalPosition; this.mainCam.gameObject.transform.LookAt(finalTarget); }
protected override void RunningUpdate() { if (Input.GetButtonDown("PauseTime")) { GlobalTimeManager.getInstance().Pause(); indicator.endCountDown(); return; } if (!m_Jump) { m_Jump = CrossPlatformInputManager.GetButtonDown("Jump"); } // read inputs h = CrossPlatformInputManager.GetAxis("Horizontal"); v = CrossPlatformInputManager.GetAxis("Vertical"); crouch = Input.GetKey(KeyCode.C); }
protected override void PausedUpdate() { if (Input.GetButtonDown("PauseTime")) { GlobalTimeManager.getInstance().Resume(); return; } if (Input.GetButtonDown("DropItem")) { indicator.startCountDown(); } else if (Input.GetButtonUp("DropItem")) { indicator.endCountDown(); } h = CrossPlatformInputManager.GetAxisRaw("Horizontal"); v = CrossPlatformInputManager.GetAxisRaw("Vertical"); indicator.Move(new Vector2(h * moveSpeed.x, v * moveSpeed.y)); }
void Start() { GlobalTimeManager.registerTimedObject(this); initialize(); }