public void CooldownUpdate_ReturnsFalseWhenCalledToSoon() { var cd = new Cooldown(TimeSpan.FromMilliseconds(100)); var now = DateTime.Now; Assert.That(cd.Update(now), Is.True); Assert.That(cd.Update(now), Is.False); Assert.That(cd.Update(now.AddMilliseconds(99)), Is.False); Assert.That(cd.Update(now.AddMilliseconds(100)), Is.True); }
private void FixedUpdate() { if (!m_character.CanMove()) { m_character.Move(Vector3.zero, false); m_character.StopSprint(); return; } m_sprintCooldown.Update(Time.fixedDeltaTime); m_sprintDurationAfterSprintStopped.Update(Time.fixedDeltaTime); switch (controlsMode) { case ControlsMode.Controller: case ControlsMode.KeyboardMouse: if (Input.GetButton("TargetMode")) { HandleAiming(); } else { HandleControllerMovement(); m_headControl.updateHeadRotation = false; m_isAiming = false; } break; case ControlsMode.KeyboardMouseSpecial: HandleMouseKeyboardMovement(); break; } }
public void Update(GameTime gameTime) { if (isWaiting) { wasWaiting = true; return; } if (wasWaiting) { wasWaiting = false; delay.Reset(DelayMs); } if (!delay.IsElapsed) { delay.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (!delay.IsElapsed) { return; } } UpdateOverride(gameTime); }
public override void UpdateOverride(GameTime gameTime, GameObject gameObject) { base.UpdateOverride(gameTime, gameObject); var isShooting = Capacity == 0 || remainingBullets > 0; if (!isShooting) { reloadCooldown.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (reloadCooldown.IsElapsed) { gunCooldown.Reset(NeedsCooldownAfterReload ? GunCooldownMs : 0); remainingBullets = Capacity; } return; } gunCooldown.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (isShooting && gunCooldown.IsElapsed) { Fire(gameObject); remainingBullets--; gunCooldown.Reset(GunCooldownMs); if (remainingBullets < 1) { reloadCooldown.Reset(ReloadDurationMs); } } }
public override void update() { switch (_gameState) { case GameState.Starting: break; case GameState.Started: break; case GameState.Ending: Time.timeScale *= 0.9975f; _camera.BaseZoom *= 1.0025f; _broScene.LetterBox.letterboxSize = 0.99f * _broScene.LetterBox.letterboxSize + 0.01f * LetterBoxSize; _transitionDelay.Update(); if (_transitionDelay.IsReady()) { PrepareForNewRound(); if (_gameHandler.WeHaveAWinner()) { EndGame(); } else { StartNextRound(); } } break; case GameState.Ended: break; } }
void Update() { setWeapon(); coolDown.Update(PlayerConfiguration.ActiveWeapon.Frequency); Fire(PlayerConfiguration.ActiveWeapon); FireKnife(WeaponCollection.KNIFE); Die(); }
public override void Update(GameTime gameTime) { base.Update(gameTime); lengthCooldown.Update(gameTime.ElapsedMs()); if (lengthCooldown.IsElapsed) { this.RemoveSelf(); } }
public override void UpdateOverride(GameTime gameTime, GameObject gameObject) { fireCooldown.Update(gameTime.ElapsedMs()); if (fireCooldown.IsElapsed) { EventBroker.FireEvent(EventName); } }
void Update() { m_afterSeconds.Update(Time.deltaTime); if (m_afterSeconds.IsOver() && !m_changedLayer) { m_changedLayer = true; gameObject.layer = (int)Mathf.Log(m_layer, 2.0f); } }
public override void Update(GameTime gameTime) { base.Update(gameTime); damageCooldown.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (damageCooldown.IsElapsed) { Tint = originalTint; } }
public void Update(float deltaTime) { monsterSpawnCooldown.Update(deltaTime); waveSpawnCooldown.Update(deltaTime); waveService.CollectKillRewards(); goldManagerController.UpdateView(); SpawnNextWave(); SpawnNextMonster(); }
public void Update(float deltaTime) { fireCooldownCounter.Update(deltaTime); if (fireCooldownCounter.IsOver) { MonsterView[] nearbyMonsters = View.GetMonstersInRange(); StartShootingAtMonster(nearbyMonsters); UpdateView(); } }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, GameObject gameObject) { delay.Update(gameTime.ElapsedMs()); if (!delay.IsElapsed) { return; } var rate = (((IHealth)gameObject).Health.Amount / (double)((IHealth)gameObject).Health.OriginalAmount); DrawInner(spriteBatch, rate); }
public override void UpdateOverride(GameTime gameTime, GameObject gameObject) { base.UpdateOverride(gameTime, gameObject); if (TimeoutMs != null) { timeoutCooldown.Update(gameTime.ElapsedMs()); } if (readyToCommit || (timeoutCooldown != null && timeoutCooldown.IsElapsed)) { gameObject.RemoveSelf(); } }
void Update() { coolDown.Update(Ennemy.Weapon.Frequency); if (PlayerConfiguration.CurrentPlayer.gameObject == null) { return; } LineCastDetection(); DetectTriggerFire(); Die(); }
public virtual void Update() { if (isHitted == false) { cooldownSpawn.Update(); sprite.transform.localScale = Vector3.one * Mathf.Lerp(0f, size, cooldownSpawn.timeRatio); } else { cooldownSplash.Update(); sprite.transform.localScale = Vector3.one * Mathf.Lerp(size, 0f, cooldownSplash.timeRatio); } }
public void Shoot(Vector2 parentPosition, Vector2 orientationChange) { if (cooldown.Ready) { foreach (var init in shotInitializers) { Bullet bullet = Instantiate(bulletPrefab, parentPosition + init.StartPoint, Quaternion.identity); bullet.tag = tag; if (isAutotargeted) { var player = FindObjectOfType <Player>(); var targetVector = (player.transform.position - bullet.transform.position); targetVector.Normalize(); bullet.moveVector = targetVector; } else { bullet.moveVector = init.Orientation * orientationChange; } bullet.transform.localScale = Vector3.one * scale; bullet.damage = damage; cooldown.Update(Time.deltaTime, true); if (isHoming) { if (tag == "Player") { var enemies = FindObjectsOfType <Enemy>(); if (enemies.Length > 0) { bullet.target = enemies[0].transform; } } } } } }
public override void UpdateOverride(GameTime gameTime, GameObject gameObject) { base.UpdateOverride(gameTime, gameObject); if (activeIndex >= KeyFrames.Count) { return; } var akf = KeyFrames[activeIndex]; keyFrameDuration.Update(gameTime.ElapsedGameTime.TotalMilliseconds); keyFrameHold.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (keyFrameDuration.IsElapsed) { if (!isHoldingFrame) { isHoldingFrame = true; keyFrameHold.Reset(akf.HoldMs); } else if (keyFrameHold.IsElapsed) { activeIndex++; if (activeIndex >= KeyFrames.Count) { return; } akf = KeyFrames[activeIndex]; KeyFrameStarted(akf, gameTime, gameObject); } return; } var amount = keyFrameDuration.Progress; var cx = MathHelper.Lerp(keyFrameStartX, (float)(akf.ToX ?? gameObject.Ox + akf.TranslateX), (float)Ease(amount)); var cy = MathHelper.Lerp(keyFrameStartY, (float)(akf.ToY ?? gameObject.Oy + akf.TranslateY), (float)Ease(amount)); if (akf.ToR.HasValue || akf.FromR.HasValue) { gameObject.R = MathHelper.Lerp((float)(akf.FromR ?? keyFrameStartR), (float)(akf.ToR ?? keyFrameStartR), (float)Ease(amount)); } gameObject.MoveX += cx - gameObject.X; gameObject.MoveY += cy - gameObject.Y; }
IEnumerator StunRoutine(Interactor interactor) { ElephantMovement movement = interactor.GetComponent <ElephantMovement>(); if (movement) { movement.Punch(); } if (OnStun != null) { OnStun(new StunEventData(interactor.gameObject, gameObject)); } var stateEnemy = GetComponent <StatePatternEnemy>(); var navMeshAgent = GetComponent <NavMeshAgent>(); stateEnemy.StopMovement(); stateEnemy.enabled = false; navMeshAgent.enabled = false; interactor.GetComponent <AudioSource>().PlayOneShot(stunEnemyHitSound); if (stunIndicatorDestroyComp == null) { // Spawn stun indicator GameObject go = Instantiate <GameObject>(stunIndicatorPrefab); go.transform.parent = transform; go.transform.localPosition = stunIndicatorOffset; stunIndicatorDestroyComp = go.GetComponent <FadeAndDestroy>(); stunIndicatorDestroyComp.FadeInOutAndDestroy(0.15f, m_stunDuration.timeInSeconds - 0.5f, 0.35f); } else { stunIndicatorDestroyComp.ResetDuration(); } while (!m_stunDuration.IsOver()) { m_stunDuration.Update(Time.deltaTime); yield return(null); } m_stunDuration.Start(); stateEnemy.enabled = true; navMeshAgent.enabled = true; m_stunRoutine = null; stunIndicatorDestroyComp = null; }
public void Update(GameTime gameTime, GameObject gameObject) { if (!isWaitingForEvent && WaitForEvent != null) { isWaitingForEvent = true; EventBroker.SubscribeOnce(WaitForEvent, s => { isWaitingForEvent = false; WaitForEvent = null; }); } if (isWaitingForEvent) { return; } if (delay == null) { delay = new Cooldown(DelayMs); } if (length == null) { length = new Cooldown(DelayMs + LengthMs); } length.Update(gameTime.ElapsedMs()); if (length.IsElapsed) { return; } if (!delay.IsElapsed) { delay.Update(gameTime.ElapsedMs()); if (!delay.IsElapsed) { return; } } if (isFirstUpdate) { OnFirstUpdate(gameTime, gameObject); isFirstUpdate = false; } UpdateOverride(gameTime, gameObject); }
void Update() { towerProjection.transform.position = transform.position; collisionCooldown.Update(Time.deltaTime); if (collisionCooldown.IsOver) { isColliding = false; } else { isColliding = true; } RaycastForProjectionState(); VisualizePlaceability(); }
void Update() { m_cooldown.Update(Time.deltaTime); if (Stunned()) { time_stunned += Time.deltaTime; if (time_stunned > maxStunTime) { maxStunTime = time_stunned; if (stunTimeArchieved != null) { stunTimeArchieved.Invoke(maxStunTime); } } } }
void Update() { if (m_elefantmovement.IsInStonePose()) { return; } if (m_controllWithSlider) { m_animatorForTrunk.SetFloat("TrunkStiffness", desiredTrunkStiffness); return; } m_stiffnessChangeCooldown.Update(Time.deltaTime); if (m_stiffnessChangeCooldown.IsOver() && Mathf.Abs(m_elefantmovement.GetRotationSpeed()) > m_rotationSpeedEpsilon || m_elephantControl.aiming) { desiredTrunkStiffness = 1.0f; } else { desiredTrunkStiffness = 0.0f; } float direction = 0.0f; if (m_trunkStiffness < desiredTrunkStiffness - Mathf.Epsilon) { direction = 1.0f; } else if (m_trunkStiffness > desiredTrunkStiffness + Mathf.Epsilon) { direction = -1.0f; } m_trunkStiffness += m_transitionSpeed * Time.deltaTime * direction; Mathf.Clamp(m_trunkStiffness, desiredTrunkStiffness, 1.0f); Mathf.Clamp01(m_trunkStiffness); m_animatorForTrunk.SetFloat("TrunkStiffness", m_trunkStiffness); }
public override void Update(GameTime gameTime) { base.Update(gameTime); damageCooldown.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (damageCooldown.IsElapsed) { Tint = Color.White; } increaseDifficultyCooldown.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (increaseDifficultyCooldown.IsElapsed) { GameSpeedManager.IncreaseDifficulty(); increaseDifficultyCooldown.Reset(increaseDifficultyDelay); } UpdateMana(gameTime); UpdatePayback(gameTime); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (!hadOneFullUpdate) { hadOneFullUpdate = true; return; } duplicateCooldown.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (duplicateCooldown.IsElapsed && Count > 1) { var c = this.originalClone; this.originalClone = null; this.Count = 0; c.Count--; Game.Objects.Add(c); c.GeneralDirection += DegIncrement; } }
private void Update() { if (m_stunned) { m_stunnedCooldown.Update(Time.deltaTime); if (m_stunnedCooldown.IsOver() && OnStunnedCooldownOver != null) { OnStunnedCooldownOver(); m_stunned = false; m_stunnedCooldown.Start(); } } if (!_shockCooldown.IsOver()) { _shockCooldown.Update(Time.deltaTime); if (!CamouflageModeActive) { return; } } List <GameObject> miceInRange; if (IsMouseInRange(out miceInRange)) { if (CamouflageModeActive) { ExitCamouflageMode(); } Debug.Log("OnElephantShocked()"); if (OnElephantShocked != null) { OnElephantShocked(new ShockEventData(miceInRange)); } } }
private void Update() { _crosshairFadeCooldown.Update(Time.deltaTime); _ammunitionFadeCooldown.Update(Time.deltaTime); _killCountFadeCooldown.Update(Time.deltaTime); Crosshair.color = Utility.ColorAlpha(insightCrosshairColours[inSightType], Crosshair.color.a); var vehicle = PlayerController.Current.GetVehicle(); if (vehicle != null) { KillCountText.text = string.Format("{0}", Player.Current.KillCount); AmmunitionText.text = string.Format("{0} / {1}", vehicle.GetPrimaryWeapon().GetClipRemaining(), vehicle.GetPrimaryWeapon().ClipCapacity); } if (hitCooldown >= 0f) { hitCooldown -= Time.deltaTime; var hitAlpha = hitCooldown / hitTime; HitCrosshair.color = new Color(1f, 1f, 1f, hitAlpha); if (hitCooldown < 0) { HitCrosshair.enabled = false; } } if (DamageCooldown > 0) { DamageCooldown -= Time.deltaTime; } if (DamageCooldown < 0) { DamageCooldown = 0; } Damage.color = new Color(1, 1, 1, Mathf.Clamp(DamageCooldown, 0, 1)); }
protected override void UpdateOverride(GameTime gameTime) { if (Count < 1) { return; } cooldown.Update(gameTime.ElapsedGameTime.TotalMilliseconds); if (cooldown.IsElapsed) { var c = (GameObject)Prototypes.All[ReferenceName].Clone(); GameObject.Game.Objects.Add(c); c.X = X; c.Y = Y; c.R += totalRIncrement; X += XIncrement; Y += YIncrement; totalRIncrement += RIncrement; Count--; cooldown.Reset(CooldownMs); } }
void Update() { if (m_removed) { return; } if (removeOnRigidbodyRest) { if (m_rigidbody && m_rigidbody.IsSleeping()) { Remove(); } } else { if (removeAfter.IsOver()) { Remove(); } } removeAfter.Update(Time.deltaTime); }
void Update() { m_cooldown.Update(Time.deltaTime); if (Input.GetMouseButton(0) && m_cooldown.IsOver()) { RaycastHit hitInfo; var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var rayHit = Physics.Raycast(ray, out hitInfo); if (rayHit) { var bullet = global::Spawner.Spawn(m_bulletPrefab, Camera.main.ScreenToWorldPoint(Input.mousePosition)); Debug.Assert(bullet.GetComponent <SpawnerExampleBullet>(), "Bullet should have a bullet component."); bullet.GetComponent <SpawnerExampleBullet>().Shoot(ray.direction * 10.0f); if (OnShoot != null) { OnShoot.Invoke(new ShootEventData(gameObject)); } m_cooldown.Start(); } } }