void Awake() { _signalSprite = GetComponent <SpriteRenderer>(); _diffuseMaterial = _signalSprite.material; _lightSource.SetActive(false); _gameTime = GetInstance <IGameTime>(); }
public void Draw(IGameState entity, IGameTime gameTime) { _gameContext.GameGraphics.Draw(_backgroundImage, _gameContext.GameGraphics.ScreenBounds, Color.White); _gameContext.GameGraphics.DrawText(_logoLine1Text, _line1Position, Color.White); _gameContext.GameGraphics.DrawText(_logoLine2Text, _line2Position, Color.White); }
public void Update(IEnemy enemy, IGameTime gameTime) { //If the enemy moves out of screen bounds, reset it if (enemy.Position.Y >= _gameContext.GameGraphics.ScreenBounds.Height || enemy.Position.X >= _gameContext.GameGraphics.ScreenBounds.Width || enemy.Position.X <= _gameContext.GameGraphics.ScreenBounds.Left - enemy.Size.X) { Reset(enemy); return; } if (enemy.Target != null) { var movementDirection = Vector2.Subtract(enemy.Target.Position, enemy.Position); movementDirection.Normalize(); movementDirection.X *= _horizontalSpeedMultiplier * 10; movementDirection.Y *= _verticalSpeedMultiplier; //Move towards target enemy.Position += Vector2.Multiply(movementDirection, enemy.MovementSpeed * 0.8f * gameTime.ElapsedGameTime.TotalSeconds.ToFloat()); } else { //Move the enemy enemy.Position += Vector2.Multiply(_movementDirection, enemy.MovementSpeed * 0.8f * gameTime.ElapsedGameTime.TotalSeconds.ToFloat()); } }
public void Update(IGameObject healthPack, IGameTime gameTime) { //Move the healthPack healthPack.Position += Vector2.Multiply(_movementDirection, healthPack.MovementSpeed * gameTime.ElapsedGameTime.TotalSeconds.ToFloat()); healthPack.Position = KeepGameObjectInScreenBounds(healthPack, healthPack.Position); }
public override void Update(IGameTime gameTime) { //ToDo move this logic out of the enemy classS if (_playerManager.Player != null) { if (Vector2.Distance(_playerManager.Player.Position, Position) < _aggroRange && Position.Y < _playerManager.Player.Position.Y && _playerManager.Player.Position.X >= Position.X - _aggroRange / 2 && _playerManager.Player.Position.X <= Position.X + _aggroRange / 2) { Target = _playerManager.Player; } else { Target = null; } } else { Target = null; } _physicsComponent.Update(this, gameTime); _graphicsComponent.Update(this, gameTime); _healthComponent.Update(this, gameTime); }
public void Update(IGameTime gameTime) { if (_isPaused) { return; } foreach (var entity in _entities) { foreach (var otherEntity in _entities) { if (!entity.IsActive || !otherEntity.IsActive || entity.CollisionLayer == otherEntity.CollisionLayer) { continue; } if (entity.Bounds.Intersects(otherEntity.Bounds)) { entity.CollidedWith(otherEntity); otherEntity.CollidedWith(entity); } } } _entities.AddRange(_entitiesToAdd); _entitiesToAdd.Clear(); }
protected bool CanSendPackage(ref BitOutputStream output, IGameTime gameTime) { if (!outstandingPackages.Available(outSequence)) // running out here means we hit 64 packs without any acks from client... { // We have too many outstanding packages. We need the other end to send something to us, so we know he // is alive. This happens for example when we break the client in the debugger while the server is still // sending messages but potentially it could also happen in extreme cases of congestion or package loss. // We will try to send empty packages with low frequency to see if we can get the connection up and running again if (gameTime.FrameTime >= chokedTimeToNextPackage) { chokedTimeToNextPackage = gameTime.FrameTime + NetworkConfig.netChokeSendInterval.FloatValue; // Treat the last package as lost int chokedSequence; var info = outstandingPackages.TryGetByIndex(outSequence % outstandingPackages.Capacity, out chokedSequence); GameDebug.Assert(info != null); NotifyDelivered(chokedSequence, info, false); counters.chokedPackagesOut++; info.Reset(); outstandingPackages.Remove(chokedSequence); // Send empty package TPackageInfo emptyPackage; BeginSendPackage(ref output, out emptyPackage); CompleteSendPackage(emptyPackage, ref output); } return(false); } return(true); }
/// <summary> /// Do next iteration. /// </summary> /// <param name="gameTime"></param> internal void Update(IGameTime gameTime) { if (_done) { return; } if (_wait != null) { _wait.Update(gameTime); if (!_wait.IsOver) { return; } _wait = null; } if (!_coroutine.MoveNext()) { _done = true; _whenDone?.Invoke(this); return; } _wait = _coroutine.Current as CoroutineWait; }
public virtual void Draw(IGameTime gameTime) { foreach (var gameObject in GameObjects) { gameObject.Draw(gameTime); } }
private void init() { if (_initialised) { return; } _initialised = true; logger.info("Initializing Atma Asteroids..."); logger.info("Version: 0.1 ALPHA"); //logger.info("Home path: {}", PathManager.getInstance().getHomePath()); //logger.info("Install path: {}", PathManager.getInstance().getInstallPath()); //logger.info("Java: {} in {}", System.getProperty("java.version"), System.getProperty("java.home")); //logger.info("Java VM: {}, version: {}", System.getProperty("java.vm.name"), System.getProperty("java.vm.version")); //logger.info("OS: {}, arch: {}, version: {}", System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version")); //logger.info("Max. Memory: {} MB", Runtime.getRuntime().maxMemory() / (1024 * 1024)); //logger.info("Processors: {}", Runtime.getRuntime().availableProcessors()); //time = CoreRegistry.putPermanently("core:time", new StopwatchTime()); foreach (var s in _subsystems) { CoreRegistry.putPermanently(s.uri, s); } CoreRegistry.putPermanently(Assets.AssetManager.Uri, new Assets.AssetManager()); foreach (var s in _subsystems) { s.init(); } time = CoreRegistry.require <IGameTime>(TimeBase.Uri); }
public void Update(IGameObject meteor, IGameTime gameTime) { //Move the meteor meteor.Position += Vector2.Multiply(_movementDirection, meteor.MovementSpeed * 0.8f * gameTime.ElapsedGameTime.TotalSeconds.ToFloat()); meteor.Position = KeepGameObjectInScreenBounds(meteor, meteor.Position); }
public void Update(IGameObject healthPack, IGameTime gameTime) { _activeSprite = _hSprite; //ToDo add sprite "animation" here healthPack.Size = _activeSprite.Size; }
public void Update(IGameObject meteor, IGameTime gameTime) { _activeSprite = _mSprite; //ToDo add sprite "animation" here meteor.Size = _activeSprite.Size; }
public override void Update(IGameTime gameTime) { UpdateWasInvoked = true; if (RemoveFromGameObjectDuringUpdate) { this.GameObject.RemoveComponent(this); } }
public override void Update(IGameTime gameTime) { base.Update(gameTime); if (_allowSpawn) { StartCoroutine(Spawn()); } }
public void Update(IPlayer player, IGameTime gameTime) { _thrusterSprite.Update(gameTime); //ToDo Possibly move into physics components as setting up bounds player.Size = _playerShipSprite.Size; player.Origin = _playerShipSprite.Origin; }
public void Update(IGameObject enemy, IGameTime gameTime) { _activeSprite = _eSprite; //ToDo add sprite "animation" here enemy.Size = _activeSprite.Size; }
public override void Draw(IGameTime gameTime) { _mainMenuStateGraphics.Draw(this, gameTime); _textMenu.Draw(gameTime); base.Draw(gameTime); }
public override void Update(IGameTime gameTime) { this.Transform.Position += new Vector2(-1, 0) * _speed * gameTime.Delta; if (this.Transform.Position.X < 0) { this.Transform.Position += new Vector2(1280, 0); } }
public override void Update(IGameTime gameTime) { _mainMenuStateGraphics.Update(this, gameTime); _textMenu.Update(gameTime); base.Update(gameTime); }
public override void Update(IGameTime gameTime) { this.Transform.Position += (_direction * _speed * gameTime.Delta); if (this.Transform.Position.X < -24) { Destroy(); } }
internal void Update(IGameTime gameTime) { if (this.IsStatic) return; this._timeToNextFrame -= gameTime.Delta; if (this._timeToNextFrame <= 0) this.NextFrame(); }
/// <summary> /// Invoked when this GameObject should be updated. /// </summary> public void Update(IGameTime gameTime) { _componentsToUpdate.Clear(); _componentsToUpdate.AddRange(_components); _componentsToUpdate.ForEach((c) => { c.Update(gameTime); (c as Behavior)?.UpdateCoroutines(gameTime); }); }
public override void Update(IGameMenu textMenu, IGameTime gameTime) { base.Update(textMenu, gameTime); if (_inputController.IsEscapeButtonPressed()) { textMenu.IsEnabled = !textMenu.IsEnabled; } }
public void Update(IGameTime gameTime) { if (_isPaused) { return; } Player.Update(gameTime); }
public void Update(IGameTime gameTime) { foreach (var bullet in _bullets) { if (bullet.IsActive) { bullet.Update(gameTime); } } }
/// <summary> /// Updates any Coroutines this GameObject has in flight. /// </summary> /// <param name="gameTime"></param> internal void UpdateCoroutines(GameTime gameTime) { if (_isKilled) { return; } this.GameTime = new GameTimeWrapper(gameTime); ForEachBehavior(b => b.UpdateCoroutines()); }
public virtual void Update(IGameTime gameTime) { if (!_isPaused) { foreach (var gameObject in GameObjects) { gameObject.Update(gameTime); } } }
public void Draw(IGameTime gameTime) { foreach (var bullet in _bullets) { if (bullet.IsActive) { bullet.Draw(gameTime); } } }
public void Draw(IGameTime gameTime) { foreach (var bonus in _bonuses) { if (bonus.IsActive) { bonus.Draw(gameTime); } } }
public void Draw(IGameState entity, IGameTime gameTime) { if (_logoLine1Text.IsVisible) { _gameContext.GameGraphics.DrawText(_logoLine1Text, _line1Position, Color.White); } if (_logoLine2Text.IsVisible) { _gameContext.GameGraphics.DrawText(_logoLine2Text, _line2Position, Color.White); } }
public void Update(IGameTime gameTime, GameStateManager gameStateManager) { foreach (MovableObject movObj in gameStateManager.MovableObjects) { movObj.Reset(); } //level.Reset(); gameStateManager.Level.Reset(); gameStateManager.GameState = GameState.Playing; }
/// <summary> /// Draws the background screen. /// </summary> public override void Draw(IGameTime gameTime) { SpriteBatch spriteBatch = ScreenManager.SpriteBatch; Viewport viewport = ScreenManager.GraphicsDevice.Viewport; var fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height); spriteBatch.Begin(); spriteBatch.Draw(backgroundTexture, fullscreen, new Color(TransitionAlpha, TransitionAlpha, TransitionAlpha)); spriteBatch.End(); }
/// <summary> /// Updates the game /// </summary> /// <param name="gameTime">the current gametime</param> /// <param name="gameStateManager">a reference to the gamestateManager</param> public void Update(IGameTime gameTime, GameStateManager gameStateManager) { gameStateManager.Level.Update(gameTime); foreach (MovableObject movableObject in gameStateManager.MovableObjects) { movableObject.Update(gameTime); if (movableObject is PacMan) { foreach (MovableObject ghost in gameStateManager.MovableObjects) { if (ghost is Ghost && ghost.CurrentCell.GridPosition == movableObject.CurrentCell.GridPosition) { gameStateManager.GameState = GameState.Death; } } } } }
public override void Update(IGameTime gameTime) { secAmount += gameTime.ElapsedGameTime.Milliseconds; if (!IsActive) { if (secAmount > goodyRounds * 3500) { IsActive = true; goodyRounds++; secAmount = 0; } } else { if (secAmount > 2500) { this.IsActive = false; } } }
/// <summary> /// Draws the menu. /// </summary> public override void Draw(IGameTime gameTime) { // make sure our entries are in the right place before we draw them UpdateMenuEntryLocations(); GraphicsDevice graphics = ScreenManager.GraphicsDevice; SpriteBatch spriteBatch = ScreenManager.SpriteBatch; SpriteFont font = ScreenManager.Font; spriteBatch.Begin(); // Draw each menu entry in turn. for (int i = 0; i < menuEntries.Count; i++) { MenuEntry menuEntry = menuEntries[i]; bool isSelected = IsActive && (i == selectedEntry); menuEntry.Draw(this, isSelected, gameTime); } // Make the menu slide into place during transitions, using a // power curve to make things look more interesting (this makes // the movement slow down as it nears the end). var transitionOffset = (float) Math.Pow(TransitionPosition, 2); // Draw the menu title centered on the screen var titlePosition = new Vector2(graphics.Viewport.Width/2, 80); Vector2 titleOrigin = font.MeasureString(menuTitle)/2; Color titleColor = new Color(192, 192, 192)*TransitionAlpha; float titleScale = 1.25f; titlePosition.Y -= transitionOffset*100; spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0, titleOrigin, titleScale, SpriteEffects.None, 0); spriteBatch.End(); }
/// <summary> /// Do next iteration. /// </summary> /// <param name="gameTime"></param> internal void Update(IGameTime gameTime) { if (_done) return; if (_wait != null) { _wait.Update(gameTime); if (!_wait.IsOver) return; _wait = null; } if (!_coroutine.MoveNext()) { _done = true; _whenDone?.Invoke(this); return; } _wait = _coroutine.Current as CoroutineWait; }
/// <summary> /// Draws the message box. /// </summary> public override void Draw(IGameTime gameTime) { SpriteBatch spriteBatch = ScreenManager.SpriteBatch; SpriteFont font = ScreenManager.Font; // Darken down any other screens that were drawn beneath the popup. ScreenManager.FadeBackBufferToBlack(TransitionAlpha*2/3); // Center the message text in the viewport. Viewport viewport = ScreenManager.GraphicsDevice.Viewport; var viewportSize = new Vector2(viewport.Width, viewport.Height); Vector2 textSize = font.MeasureString(message); Vector2 textPosition = (viewportSize - textSize)/2; // The background includes a border somewhat larger than the text itself. const int hPad = 32; const int vPad = 16; var backgroundRectangle = new Rectangle((int) textPosition.X - hPad, (int) textPosition.Y - vPad, (int) textSize.X + hPad*2, (int) textSize.Y + vPad*2); // Fade the popup alpha during transitions. Color color = Color.White*TransitionAlpha; spriteBatch.Begin(); // Draw the background rectangle. spriteBatch.Draw(gradientTexture, backgroundRectangle, color); // Draw the message box text. spriteBatch.DrawString(font, message, textPosition, color); spriteBatch.End(); }
public ObjectDestroyed(IGameTime timeSent, IGameObject gameObject) : base(timeSent) { GameObject = gameObject; }
/// <summary> /// Updates the state of the game. This method checks the GameScreen.IsActive /// property, so the game will stop updating when the pause menu is active, /// or if you tab away to a different application. /// </summary> public override void Update(IGameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { if(IsActive) { switch (gameStateManager.GameState) { case GameState.Playing: PlayGame(gameTime); break; case GameState.Death: OnDeath(gameTime); break; case GameState.Loading: gameStateManager.GameState = GameState.Starting; break; case GameState.Starting: StartGame(gameTime); break; default: break; } } base.Update(gameTime, otherScreenHasFocus, false); // Gradually fade in or out depending on whether we are covered by the pause screen. if (coveredByOtherScreen) { pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1); } else { pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0); if(GameState == GameState.Loading) { GameState = GameState.Playing; } } }
/// <summary> /// Starts the current game /// </summary> /// <param name="gameTime">the current gametime</param> public void StartGame(IGameTime gameTime) { gameStateManager.GameState = GameState.Playing; }
/// <summary> /// Updates the cell /// </summary> /// <param name="gameTime">GameTime from the game class</param> public override void Update(IGameTime gameTime) { PickUp pU = cellEffect as PickUp; if(pU != null) { pU.Update(gameTime); } }
public WidgetsDestroyAll(IGameTime timeSent) : base(timeSent) { }
public ExitGameRequest(IGameTime timeSent) : base(timeSent) { }
public GameObjectRequest(IGameTime timeSent, IGameObject gameObject) { TimeSent = timeSent; GameObject = gameObject; }
public override void Update(IGameTime gameTime) { }
/// <summary> /// Updates the background screen. Unlike most screens, this should not /// transition off even if it has been covered by another screen: it is /// supposed to be covered, after all! This overload forces the /// coveredByOtherScreen parameter to false in order to stop the base /// Update method wanting to transition off. /// </summary> public override void Update(IGameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, false); }
public RequestCloseMessage(IGameTime timeSent) : base(timeSent) { }
public KeyUpMessage(IGameTime timeSent, Keys key) : base(timeSent) { Key = key; }
public override void Update(IGameTime gameTime) { throw new NotImplementedException(); }
/// <summary> /// Helper for updating the screen transition position. /// </summary> private bool UpdateTransition(IGameTime gameTime, TimeSpan time, int direction) { // How much should we move by? float transitionDelta; if (time == TimeSpan.Zero) transitionDelta = 1; else transitionDelta = (float) (gameTime.ElapsedGameTime.TotalMilliseconds/ time.TotalMilliseconds); // Update the transition position. transitionPosition += transitionDelta*direction; // Did we reach the end of the transition? if (((direction < 0) && (transitionPosition <= 0)) || ((direction > 0) && (transitionPosition >= 1))) { transitionPosition = MathHelper.Clamp(transitionPosition, 0, 1); return false; } // Otherwise we are still busy transitioning. return true; }
/// <summary> /// Updates the level /// </summary> /// <param name="gameTime">Game time from the game class</param> public void Update(IGameTime gameTime) { foreach (Cell cell in grid) { cell.Update(gameTime); } }
/// <summary> /// Allows the screen to run logic, such as updating the transition position. /// Unlike HandleInput, this method is called regardless of whether the screen /// is active, hidden, or in the middle of a transition. /// </summary> public virtual void Update(IGameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { this.otherScreenHasFocus = otherScreenHasFocus; if (isExiting) { // If the screen is going away to die, it should transition off. screenState = ScreenState.TransitionOff; if (!UpdateTransition(gameTime, transitionOffTime, 1)) { // When the transition finishes, remove the screen. ScreenManager.RemoveScreen(this); } } else if (coveredByOtherScreen) { // If the screen is covered by another, it should transition off. if (UpdateTransition(gameTime, transitionOffTime, 1)) { // Still busy transitioning. screenState = ScreenState.TransitionOff; } else { // Transition finished! screenState = ScreenState.Hidden; } } else { // Otherwise the screen should transition on and become active. if (UpdateTransition(gameTime, transitionOnTime, -1)) { // Still busy transitioning. screenState = ScreenState.TransitionOn; } else { // Transition finished! screenState = ScreenState.Active; } } }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(IGameTime gameTime) { // Our player and enemy are both actually just text strings. SpriteBatch spriteBatch = ScreenManager.SpriteBatch; spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.GetTransformation(ScreenManager.GraphicsDevice)); gameStateManager.Level.Draw(spriteBatch, 5); //foreach (MovableObject movableObject in movOb) foreach(MovableObject movableObject in gameStateManager.MovableObjects) { movableObject.Draw(spriteBatch, 4, gameStateManager.Level.LevelPosition); } foreach(GUIElement element in guiElements) { element.Draw(spriteBatch, 6); } spriteBatch.End(); doTransition(); }
public void Update(IGameTime gameTime) { timestamp = gameTime.TotalGameTime.TotalMilliseconds; System.Console.WriteLine(timestamp); //controller.Update(); /*if (this.MovObjType == MovObjType.LocalPacMan) { KeyboardState state = Keyboard.GetState(); if (inputState.IsNewKeyPress(Keys.Up, this.index, out this.index)) { Direction = Direction.Up; Send(); } else if (inputState.IsNewKeyPress(Keys.Down, this.index, out this.index)) { Direction = Direction.Down; Send(); } else if (inputState.IsNewKeyPress(Keys.Right, this.index, out this.index)) { Direction = Direction.Right; Send(); } else if (inputState.IsNewKeyPress(Keys.Left, this.index, out this.index)) { Direction = Direction.Left; Send(); } } else { Receive(); } */ //this.Update(); }
/// <summary> /// Handles the gamestate if pacman is eaten /// </summary> /// <param name="gameTime">the current gametime</param> public void OnDeath(IGameTime gameTime) { foreach (MovableObject movableObject in gameStateManager.MovableObjects) { movableObject.Reset(); } //Das hier auskommentiert lassen, damit beim Sterben nicht das Level von neuem beginnt //gameStateManager.Level.Reset(); gameStateManager.GameState = GameState.Starting; }
public ObjectCreationRequest(IGameTime timeSent, Type objectType) : base(timeSent) { ObjectType = objectType; }
/// <summary> /// Plays the game, updates it according to the current playbehaviour /// </summary> /// <param name="gameTime">the current gametime</param> public void PlayGame(IGameTime gameTime) { playBehaviour.Update(gameTime, gameStateManager); camera.Update(); }
/// <summary> /// Updates the menu. /// </summary> public override void Update(IGameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); // Update each nested MenuEntry object. for (int i = 0; i < menuEntries.Count; i++) { bool isSelected = IsActive && (i == selectedEntry); menuEntries[i].Update(this, isSelected, gameTime); } }
public ObjectCreated(IGameTime timeSent, IGameObject gameObject) : base(timeSent) { GameObject = gameObject; }