void ChangeActivity(EnemyActivity next_activity) { if (activity == EnemyActivity.AttackTarget) { } switch (next_activity) { case EnemyActivity.AttackTarget: attackEffect.Play(); agent.isStopped = true; break; case EnemyActivity.ChaseTarget: attackEffect.Stop(); agent.isStopped = false; break; case EnemyActivity.ReturnToBase: attackEffect.Stop(); agent.isStopped = false; targetUnit = null; break; case EnemyActivity.IdleOnBase: attackEffect.Stop(); agent.isStopped = true; targetUnit = null; break; } Debug.Log(next_activity); activity = next_activity; }
void Start() { Anim = GetComponent <Animator>(); enemyStats = GetComponent <StatsEnemy>(); enemyAct = gameObject.GetComponent <EnemyActivity>(); attackTimer = enemyStats.attackRate; Anim.SetBool("inCombat", true); }
public EnemyCompositeCharacter(World world, Vector2 position, float width, float height, float mass, Texture2D texture) : base(world, position, width, height, mass, texture) { if (width > height) { throw new Exception("Error width > height: can't make character because wheel would stick out of body"); } this.animation = new Animation(); this.audioEmitter = new AudioEmitter(); activity = EnemyActivity.enemyIdle; wheel.OnCollision += new OnCollisionEventHandler(OnCollision); }
protected override void HandleInput(GameTime gameTime) { if (MainMenuScreen.currentGameScreen == 1) { //handle bear knife attacks if (Math.Abs(Position.X - GameplayScreen.box.Position.X) < 50 && Math.Abs(Position.Y - GameplayScreen.box.Position.Y) < 90 && GameplayScreen.box.activity != Activity.Dead && activity != EnemyActivity.enemyDead) { stopScript(); activity = EnemyActivity.enemyKnife; } handleAnimation(gameTime); //update 3d sound audioEmitter.Position = new Vector3(Position.X, Position.Y, 1f) / GameplayScreen.soundDistanceFactor; if (soundEffectInstance != null) { if (soundEffectInstance.State == SoundState.Playing) { soundEffectInstance.Apply3D(GameplayScreen.audioListener, audioEmitter); } } } else { //handle bear knife attacks if (Math.Abs(Position.X - GameplayScreen2.box.Position.X) < 50 && Math.Abs(Position.Y - GameplayScreen2.box.Position.Y) < 90 && GameplayScreen.box.activity != Activity.Dead && activity != EnemyActivity.enemyDead) { stopScript(); activity = EnemyActivity.enemyKnife; } handleAnimation(gameTime); //update 3d sound audioEmitter.Position = new Vector3(Position.X, Position.Y, 1f) / GameplayScreen2.soundDistanceFactor; if (soundEffectInstance != null) { if (soundEffectInstance.State == SoundState.Playing) { soundEffectInstance.Apply3D(GameplayScreen2.audioListener, audioEmitter); } } } oldActivity = activity; }
public void stopScript() { if (bw != null) { if (bw.IsBusy) { bw.CancelAsync(); while (threadCompleted == false) { Thread.Sleep(1); } threadCompleted = false; activity = EnemyActivity.enemyIdle; } } }
//Fired when we collide with another object. Use this to stop jumping //and resume normal movement public bool OnCollision(Fixture fix1, Fixture fix2, Contact contact) { //Check if we are both jumping this frame and last frame //so that we ignore the initial collision from jumping away from //the ground if (activity == EnemyActivity.enemyJumping && oldActivity == EnemyActivity.enemyJumping && activity != EnemyActivity.enemyKnife) { activity = EnemyActivity.enemyIdle; } return true; }
public void moveRight(int millis, int speed) { motor.MotorSpeed = speed; activity = EnemyActivity.enemyRunning; animation.myEffect = SpriteEffects.FlipHorizontally; Thread.Sleep(20); if (speed < 5) { animation.frameTime = 60; } else { animation.frameTime = 30; } int i = 0; while (bw.CancellationPending == false && i < millis) { Thread.Sleep(10); if (MainMenuScreen.currentGameScreen == 1) { while (!MainMenuScreen.gamePlayScreen.IsActive && bw.CancellationPending == false) { Thread.Sleep(5); } } else { while (!MainMenuScreen.gamePlayScreen2.IsActive && bw.CancellationPending == false) { Thread.Sleep(5); } } i += 10; } motor.MotorSpeed = 0; activity = EnemyActivity.enemyIdle; }
public void jump() { activity = EnemyActivity.enemyJumping; motor.MotorSpeed = 0; jumpForce.Y = jumpImpulse; body.ApplyLinearImpulse(jumpForce, body.Position); while (activity != EnemyActivity.enemyIdle && bw.CancellationPending == false) { Thread.Sleep(10); } activity = EnemyActivity.enemyIdle; }
public void idle(int millis) { activity = EnemyActivity.enemyIdle; int i = 0; while (bw.CancellationPending == false && i < millis) { Thread.Sleep(10); if (MainMenuScreen.currentGameScreen == 1) { while (!MainMenuScreen.gamePlayScreen.IsActive && bw.CancellationPending == false) { Thread.Sleep(5); } } else { while (!MainMenuScreen.gamePlayScreen2.IsActive && bw.CancellationPending == false) { Thread.Sleep(5); } } i += 10; } }