static void Main(string[] args) { Enemy e = new Enemy(); e.Start(); e.Update(); }
private void Update() { if (_initialized) { _enemy.Update(Time.deltaTime); } }
public void Update(GameTime gameTime, ContentManager Content) { foreach (GameItem gi in gameItems) { gi.Update(); } foreach (var atk in attacks) { atk.Update(); } foreach (Bar b in bars) { b.Update(); } fighter.Update(gameTime); enemy.Update(gameTime); control.Update(gameTime, Content); //test playerHealth = control.PlayerHealth.ToString(); playerMana = control.PlayerMana.ToString(); playerAtk = control.PlayerAtk.ToString(); playerSpAtk = control.PlayerSpAtk.ToString(); enemyHealth = control.EnemyHealth.ToString(); enemyMana = control.EnemyMana.ToString(); enemyAtk = control.EnemyAtk.ToString(); enemySpAtk = control.EnemySpAtk.ToString(); //test }
public static void Run() { try { // 敵機のインスタンスの作成 var enemy = new Enemy(); // 敵機の更新処理を30回繰り返す for (int i = 0; i < 30; ++i) { enemy.Update(); } } // スクリプト実行時に発生した例外 catch (CompilationErrorException e) { Console.WriteLine(e.Message); } // プログラム実行時に発生した例外 catch (Exception e) { Console.WriteLine(e.Message); } }
public void UpdateGame(ResponseGameInfo gameInfo, IReadOnlyCollection <SC2APIProtocol.Unit> sc2Units) { if (latestGameInfo == null) { return; } latestGameInfo = gameInfo; Resources.Update(sc2Units); Enemy.Update(sc2Units); Self.Update(sc2Units); foreach (var cc in Self.Buildings.LocateAll <ControlAbleBuilding>()) { cc.Train(Terran.CommandCenter.Units.Scv); } Self.Units.First().SetupHighOrder(new HighLevelOrder() { Goal = Goal.Scout, Duration = Duration.AsLongAsPossible, Area = MapArea.EnemyBase }); }
public void Update(GameTime gameTime) //Update method { if (enemySpawned == numEnemy) //If the number of enemies spawned equals the number of enemies, no more enemies are spawned { actSpawn = false; } if (actSpawn) //If enemies need spawning { spawnTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; //Timer is incremented by the amount of seconds that have passed since the last update if (spawnTimer > 1) //If more than 1 second has passed { addEnemy(); //Calls the addEnemy method } } for (int i = 0; i < enemies.Count; i++) //For each enemy in the list { Enemy enemy = enemies[i]; //The current enemy enemy.Update(gameTime); //Calls the update method in the enemy class if (enemy.IsDead) //If enemy is dead { if (enemy.CurrentHealth > 0) //If current health is bigger than 0, the enemy is considered to be at the end and the player loses lives { enemyAtEnd = true; player.Lives -= 1; } else//If the enemy has no remaining health the player is given currency { player.Money += enemy.GoldGiven; } enemies.Remove(enemy); //We remove the current enemy from the list i--; //Decrement the i value } } }
private void UpdatePhysics(GameTime gameTime) { for (int i = 0; i < enemySpawner.Enemies.Count; i++) { Enemy enemy = enemySpawner.Enemies[i]; if (enemy != null) { enemy.Update(gameTime); if (enemy.Bounds.Intersects(player.Bounds)) { gameScreen = GameScreen.Defeat; } for (int j = 0; j < player.ShotList.Count; j++) { Shot shot = player.ShotList[j]; if (enemy.Bounds.Intersects(shot.Bounds)) { enemySpawner.Enemies.RemoveAt(i); enemy = null; i--; player.ShotList.RemoveAt(j); shot = null; j--; break; } } } } }
public void Update(float deltaTime) { void UpdateUnit(SpaceUnit unit) { Enemy enemy = unit as Enemy; if (enemy.Update(deltaTime)) { enemy.RemoveFromWorld(); } if (enemy.HaveReachedLastWayPoint) { OnEnemyReachedLastPoint?.Invoke(enemy); } } // Update units in cells. for (int y = 0; y < spacePartitioner.TotalCells.Y; y++) { for (int x = 0; x < spacePartitioner.TotalCells.X; x++) { for (int i = spacePartitioner.Cells[y][x].Count - 1; i >= 0; i--) { UpdateUnit(spacePartitioner.Cells[y][x].ElementAt(i)); } } } // Update OutOfBoundsUnits. for (int i = spacePartitioner.OutOfBoundsUnits.Count - 1; i >= 0; i--) { UpdateUnit(spacePartitioner.OutOfBoundsUnits.ElementAt(i)); } }
public void Update(GameTime gameTime) { timer -= gameTime.ElapsedGameTime.TotalSeconds; double fieldOfView = Vector2.Distance(Player.Position, Enemy.Position); // Enemy can see player in field of view and changes direction if (fieldOfView < 500) { Vector2 direction = Player.Position - Enemy.Position; direction.Normalize(); Enemy.Direction = direction; } else if (timer < 0) { int x = RandomNumber.Generator.Next(3) - 1; int y = RandomNumber.Generator.Next(3) - 1; Enemy.Direction = new Vector2(x, y); timer = maxTime; } Enemy.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { keyState = Keyboard.GetState(); // For Mobile devices, this logic will close the Game when the Back button is pressed // Exit() is obsolete on iOS if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || keyState.IsKeyDown(Keys.Escape)) { Exit(); } //Update cities foreach (City city in cities) { city.Update(keyState, gameTime, GraphicsDevice); } //update missile and enemy rocket missile.Update(keyState, gameTime, GraphicsDevice); enemy.Update(keyState, gameTime, GraphicsDevice); CollisionDetection(); // TODO: Add your update logic here base.Update(gameTime); }
private void Update() { //fire1.transform.position = huoba.position; enemy.Update(); if (faceto == 1) { transform.rotation = Quaternion.Euler(0, 90, 0); } else { transform.rotation = Quaternion.Euler(0, -90, 0); } if (Hp <= 0 && !dead) { enemy.SetStage(boss_dead_stage); candamage = false; dead = true; } // tuozhan(); FSeePlayer(); attcd -= Time.deltaTime; exattcd -= Time.deltaTime; houtiao(); }
/// <summary> /// Updates the enemies. /// </summary> /// <param name="gameTime">The GameTime.</param> private void UpdateEnemies(GameTime gameTime) { for (int i = 0; i < Enemies.Count; i++) { Enemy enemy = Enemies[i]; enemy.Position = new Vector2(enemy.Position.X - (enemy.Velocity * gameTime.ElapsedGameTime), enemy.Position.Y); if (enemy.Position.X <= -48) { //the enemy is out of bounds, remove it. Enemies.Remove(enemy); i++; //new patch: also remove some score (75%) Score -= (int)(enemy.Velocity * 1000 * 0.75); if (Score < 0) { Score = 0; } } else { enemy.Update(gameTime); } } }
/// <inheritdoc /> public override void OnUpdate(float delta) { Clear(Pixel.Presets.Black); if (!started) { DrawText(new Point(ScreenWidth / 4, 100), "Dodger", Pixel.Presets.White, 3); DrawText(new Point(ScreenWidth / 5, 150), "Press 'Enter' To Start", Pixel.Presets.White); if (GetKey(Key.Enter).Pressed) { started = true; } return; } if (gameOver) { DrawText(new Point(ScreenWidth / 4, ScreenHeight / 2), $"Your Score: {score}", Pixel.Presets.White); DrawText(new Point(ScreenWidth / 5, ScreenHeight / 2 + 10), "Press 'Enter' To Restart", Pixel.Presets.White); if (GetKey(Key.Enter).Pressed) { Reset(); } } enemyElapsed += delta; if (enemyElapsed > enemyTimer) { enemies.Add(new Enemy(Random(ScreenWidth), -50, Random(200f, 300f), Random(5, 30), Random(5, 30))); enemyElapsed -= enemyTimer; enemyTimer = 0.25f + Random(-0.125f, 0.125f); } player.Render(this, gameOver ? Pixel.Presets.Red : Pixel.Presets.White); for (int i = enemies.Count - 1; i >= 0; i--) { Enemy enemy = enemies[i]; if (!gameOver) { enemy.Update(delta); } enemy.Render(this); if (Colliding(enemy)) { gameOver = true; } if (enemy.Pos.Y >= ScreenHeight + enemy.Height) { score += 10; enemies.RemoveAt(i); } } if (!gameOver) { if (GetKey(Key.Left).Down) {player.Update(-1, delta); } if (GetKey(Key.Right).Down){player.Update(1, delta); } } player.Constrain(this); DrawText(new Point(5, 5), $"Score: {score}", Pixel.Presets.White); }
/// <summary> /// Update everything in the state /// </summary> public override void Update(GameTime gameTime) { //m_player.CollidedWith(m_car); //coll_manager.Update(m_player); //m_player.CollidedWith(m_car); //m_player.CollidedWith(m_block); m_player.Update(); m_enemy.Update(m_player); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { enemy.Update(); player.Update(map, spriteBatch); FPSUpdate(gameTime); UI.Update(gameTime); base.Update(gameTime); if (IDE.ENABLE) { IDE.Update(gameTime); } }
private void UpdateEnemies(GameTime gameTime) { enemyCount = startEnemyCount + (int)(elapsedTime / 10); while (enemies.Count < enemyCount) { Enemy enemy = new Enemy(); enemy.Initialize(this, random); enemies.Add(enemy); } enemies.ForEach(enemy => enemy.Update(gameTime)); }
private void UpdateEnemies() { foreach (EnemyData Enemy in new List <EnemyData>(EnemySprites)) { Enemy.Update(); if (Enemy.Disposed) { EnemySprites.Remove(Enemy); return; } } }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } Cell.UpdateCellsOnScreen(character.camera.position, gameWidth, gameHeight); if (!character.isInteracting) { character.Update(gameTime); } foreach (var npc in map.npcs) { npc.Update(gameTime); } foreach (var col in map.colliders) { col.Update(gameTime); } foreach (var enemy in map.enemies) { enemy.Update(gameTime); } foreach (var so in map.objects) { so.Update(); } #region fps totalSeconds += gameTime.ElapsedGameTime.Ticks / 10000000f; frames++; fps = (1f / (float)totalSeconds) * frames; if ((int)totalSeconds > 1) { frames = 0; totalSeconds = 0; Console.WriteLine(fps); } #endregion base.Update(gameTime); }
public void Update(GameTime gameTime) { EnemyTest.Clear(); for (Byte index = 0; index < maxEnemySpawn; index++) { Enemy enemy = EnemyList[index]; enemy.Update(gameTime); if (EnemyType.Test == enemy.EnemyType) { EnemyTest.Add(enemy); } } }
/// <summary> /// This is where all the Tower defense update calls should be placed so that it is easy to transfer our /// project over to the main one without having to add a lot of code to the main program. /// </summary> /// <param name="gametime">current game time</param> /// <param name="keyboard">keyboard state</param> /// <param name="mouse">mouse state</param> public static void Update(GameTime gametime, KeyboardState keyboard, MouseState mouse) { Random random = new Random(); if (LastWaveUpdate == TimeSpan.Zero) { LastWaveUpdate = gametime.TotalGameTime; } if (currentWave != null && !currentWave.complete) { currentWave.update(gametime); LastWaveUpdate = gametime.TotalGameTime; } else if ((gametime.TotalGameTime - LastWaveUpdate) > SpawnNextWaveIn) { if (TDPlayerStats.currentWave == TDPlayerStats.maxWaves) { TPEngine.Get().State.PopState(); TPEngine.Get().State.PushState(new TDScoreScreenState()); } TDPlayerStats.Money += 5; TDPlayerStats.currentWave++; currentWave = new EnemyWave(random.Next(8, 12), 1); //LastWaveUpdate = gametime.TotalGameTime; } if (TDPlayerStats.Grade <= 0) { TPEngine.Get().State.PopState(); TPEngine.Get().State.PushState(new TDScoreScreenState()); } if (Keyboard.GetState().IsKeyDown(Keys.X) && !clicked) { TDPlayerStats.Grade = 0; TPEngine.Get().State.PopState(); TPEngine.Get().State.PushState(new TDScoreScreenState()); clicked = true; } TowerBuilder.UpdateKeyboardInput(keyboard, mouse); Enemy.Update(gametime); Tower.Update(gametime); Projectile.UpdateProjectiles(gametime); Window.Update(gametime, keyboard, mouse); }
public override void Update() { if (!m_bPause) { base.Update(); if (m_pRenderer.isVisible && m_pEnemyBUS.IsAlive) { m_pEnemyBUS.Update(); } } if (!m_pEnemyBUS.IsAlive && !m_pRenderer.isVisible) // If dead and out of screen { Destroy(gameObject); } }
public void Update(GameTime gameTime) { player.Update(gameTime); enemy.Update(gameTime); ball.Update(gameTime); if (ball.Hitbox.X < 0) { EnemyScores++; StartGame(); } else if (ball.Hitbox.X > graphics.PreferredBackBufferWidth) { PlayerScores++; StartGame(); } }
public void Update(GameTime gameTime) { if (enemiesSpawned == numOfEnemies) { spawningEnemies = false; // stop spawning when we reach max } if (spawningEnemies) { spawnTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (spawnTimer > 2) // every 2 seconds, spawn another enemy { AddEnemy(); } } for (int i = 0; i < enemies.Count; i++) { Enemy enemy = enemies[i]; enemy.Update(gameTime); // if an enemy "dies" we check if it died by a turret or by reaching the end if (enemy.IsDead) { // if enemy still has health, but is tagged as "dead" // than it is at the end of the path. if (enemy.CurrentHealth > 0) { enemyAtEnd = true; player.Lives -= 1; } else { // otherwise the enemy died to a tower, so money should be awarded player.Money += enemy.BountyGiven; } enemies.Remove(enemy); i--; } } }
public void Update(GameTime gameTime) { //enemy toevoegen aan de list if (enemiesSpawned == numOfEnemies) { spawingEnemies = false; } if (spawingEnemies) { spawnTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (spawnTimer > 2) { AddEnemy(); } } //kijken of een enemy in de list dood is for (int i = 0; i < Textures.Waterenemies.Count; i++) { Enemy enemy = Textures.Waterenemies[i]; enemy.Update(gameTime); if (enemy.IsDead) { if (enemy.CurrentHealth > 0) { enemyAtEnd = true; player.Lives -= 1; } else { player.Money += enemy.MoneyGiven; } Textures.Waterenemies.Remove(enemy); i--; } } }
private void Update() { enemy.Update(); if (faceto == 1) { transform.rotation = Quaternion.Euler(0, 90, 0); } else { transform.rotation = Quaternion.Euler(0, -90, 0); } if (Hp <= 0 && !dead) { enemy.SetStage(lizarrd_dead_stage); candamage = false; dead = true; } tuozhan(); }
private void Update() { enemy.Update(); if (faceto == 1) { transform.rotation = Quaternion.Euler(0, 90, 0); } else { transform.rotation = Quaternion.Euler(0, -90, 0); } if (Hp <= 0 && !dead) { enemy.SetStage(assassin_dead_stage); candamage = false; dead = true; } skillcound -= Time.deltaTime; }
public override void Update(GameTime gameTime) { ScreenUpdate(); player.Update(gameTime); Local.waypoints[0] = player.position; if (currentEnemy < 4) { timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (timer >= 10000) { timer = 0; currentEnemy++; pokemon = new Enemy(Local.textures[currentEnemy], pokemon.position, pokemon.speed + 20); } } pokemon.Update(gameTime); }
void Update() { if (k_Target != null) { DistanceBetween(transform.position, k_Target.transform.position); } if (k_UsedStart == false && k_CurrentState != null) { k_CurrentState.Start(); k_UsedStart = true; } if (k_CurrentState != null) { if (k_Target != null) { k_CurrentState.Update(); } } //if (k_Controller.HitObj != null) //{ // if (k_Controller.HitObj.name == "Mega_Man") // { // if (!k_Controller.HitObj.GetComponent<Player>().IsDamaged) // { // if (k_Controller.collisions.left || k_Controller.collisions.right || k_Controller.collisions.below || k_Controller.collisions.above || k_HitPlayer) // { // k_Controller.HitObj.GetComponent<Health>().CurrentHealth -= k_Damage; // k_Controller.HitObj.GetComponent<Player>().Damage(); // k_HitPlayer = false; // } // } // } //} }
private void Update() { enemy.Update(); if (faceto == 1 && !dead) { transform.rotation = Quaternion.Euler(0, 90, 0); } else if (faceto == -1 && !dead) { transform.rotation = Quaternion.Euler(0, -90, 0); } if (Hp <= 0 && !dead) { candamage = false; enemy.SetStage(bird_dead_stage); dead = true; } for (int i = 0; i < 2; i++) { wings[i].transform.Rotate(new Vector3(0, 0, 10)); } }
void Update() { linkedScript.Update(); }