public void Update() { if (health > 100) { shield = true; health--; shieldHealth++; if (shieldHealth > 100) { shieldHealth = 100; } } else if (health < 100) { if (shieldHealth > 0) { shieldHealth--; health++; } else { shield = false; } } //calculate speed speed = Vector2.Subtract(game.joystick_right.anchorPos, game.joystick_right.position).Length() / 100; //create boundingbox for player and randomcube //TESTS// physicsBody = new BoundingBox(new Vector3(position.X - 5, position.Y - 5, position.Y - 5), new Vector3(position.X + 5, position.Y + 5, position.Y + 5)); //if shooting == touching but not moving joystick if (game.joystick_left.isPressed) { angle = game.LookAt(new Vector3(game.joystick_left.anchorPos.X, -game.joystick_left.anchorPos.Y, 0), new Vector3(game.joystick_left.position.X, -game.joystick_left.position.Y, 0), angle, turnSpeed); Shoot(); } else if (game.mouseClicking) { angle = game.LookAt(position, game.mouseInWorld, angle, turnSpeed); Shoot(); } position.Z = 0; healthBar.Update(health); if (game.combo < 15) { gunStage = 1; } else { if (game.combo > 50) { gunStage = 3; } else { gunStage = 2; } } }
public void Update() { //update new bounding box position to this enemy physicsBody = new BoundingBox(position - new Vector3(3, 3, 3), position + new Vector3(3, 3, 3)); angle = game.LookAt(position, game.player.position, angle, 0.08f); //if enemy is far away from player, move it towards players position if ((position - game.player.position).Length() > 3f) { flyDir = Vector3.Normalize(game.player.position - position) * enemySpeed; position += flyDir; } //check if enemy is close enough to player, then make it die else { shouldDie = true; game.player.health -= 5; game.hit.Play(0.8f, 0, 0); game.combo = 0; } if (lastShot + shootDelay < game.time) { Shoot(); lastShot = (float)game.time; } }