/// <summary> /// Updates the slider /// </summary> /// <param name="elapsed">Time elapsed since the last call</param> public override void update(float elapsed) { if (this.alreadyPicked) { Vector2 delta = InputManager.getInstance().MousePosition - InputManager.getInstance().PreviousMousePosition; if (delta.X < 0) { this.CurrentValue -= .05f; setPosition(); } else if (delta.X > 0) { this.CurrentValue += .05f; setPosition(); } } if (InputManager.getInstance().isLeftButtonDown()) { if (PickingUtils.pickVector(InputManager.getInstance().MousePosition, this.bbox)) { this.alreadyPicked = true; } } else if (!InputManager.getInstance().isLeftButtonDown()) { this.alreadyPicked = false; } this.bar.update(elapsed); this.ball.update(elapsed); this.text.WrittenText = getValue(); this.text.update(elapsed); }
public void update(float elapsed) { foreach (var icon in icons) { if (icon != null) { icon.update(elapsed); } } for (int i = 0; i < selected.Count; i++) { if (InputManager.getInstance().wasLeftButtonPressed()) { if (PickingUtils.pickVector(InputManager.getInstance().MousePosition, selected[i].BBox)) { this.changeSelected.Invoke(i); break; } } } }
/// <summary> /// Updates the Checkbox /// </summary> /// <param name="elapsed">Time elapsed since the last call</param> public override void update(float elapsed) { if (InputManager.getInstance().wasLeftButtonPressed()) { // if we were inside the checkbox if (PickingUtils.pickVector(InputManager.getInstance().MousePosition, this.bbox)) { this.Checked = !this.Checked; } } if (this.Checked) { this.activeImg = this.checkedBoxImag; } else { this.activeImg = this.uncheckedBoxImag; } this.activeImg.update(elapsed); this.text.update(elapsed); }
/// <summary> /// Determines if the actor is over the button /// </summary> /// <param name="actorsPosition">Actors current position</param> /// <returns>boolean based on whether the actor is over the button</returns> public bool isActorOver(Vector2 actorsPosition) { return(PickingUtils.pickVector(actorsPosition, this.bbox)); }
public virtual void update(float elapsed) { linesOfSight.Clear(); closestsGhosts.Clear(); foreach (var mob in mobs) { mob.update(elapsed); } foreach (var dead in this.theDead) { if (dead != null) { dead.update(elapsed); } } foreach (var ghost in this.allGhosts) { ghost.update(elapsed); } updateFieldOfView(elapsed); updateSkills(elapsed); this.hud.updateSkills(this.selectedGhosts); this.hud.update(elapsed); CombatManager.getInstance().update(elapsed); EffectsManager.getInstance().update(elapsed); SoundManager.getInstance().update(); if (looseConditionDetected()) { ((GameDisplayState)GameStateMachine.getInstance().CurrentState).goToGameOver(); } else if (winConditionAchieved()) { LevelContext context = new LevelContext() { Ghosts = allGhosts, MapIndex = GameStateMachine.getInstance().LevelContext.MapIndex }; GameStateMachine.getInstance().LevelContext = context; GameStateMachine.getInstance().goToNextState(); } if (InputManager.getInstance().wasLeftButtonPressed()) { if (!InputManager.getInstance().isKeyDown(Keys.LeftShift)) { clearSelectedGhosts(); } foreach (var ghost in allGhosts) { if (PickingUtils.pickVector(InputManager.getInstance().MousePosition, ghost.BBox) && !ghost.Selected) { selectGhost(ghost); } } } // ghosts spawned as part of this cycle are not applicable to the current frame so add them here if (this.recentlySpawned != null && this.recentlySpawned.Count > 0) { this.allGhosts.AddRange(this.recentlySpawned); this.recentlySpawned = new List <Ghost>(); } #if DEBUG /*Point mouse = InputManager.getInstance().MousePosition.toPoint(); * GWNorthEngine.AI.AStar.BasePathFinder.TypeOfSpace space = AIManager.getInstance().Board[mouse.Y, mouse.X]; * Debug.log(space.ToString());*/ MapEditor.getInstance().update(); #endif }