public virtual void HitTarget(Enemy pEnemy) { if (!mHit) { pEnemy.lostHealth(mDamage); Vector2 tmp = pEnemy.Center; mEffect.Trigger(ref tmp); mHit = true; BulletSound(); } }
public override void HitTarget(Enemy pEnemy) { foreach (Enemy enemy in mEnemies) { if (!mHit && isInRange(enemy.Center)) { enemy.lostHealth(mDamage); } } if (!mHit) { Vector2 tmp = pEnemy.Center; mEffect.Trigger(ref tmp); mHit = true; BulletSound(); } }
public virtual void Update(GameTime gameTime , bool isPause) { base.Update(gameTime); if (!isPause) //NTA added { if (reloadDuration >= 0) { reloadDuration -= (float)gameTime.ElapsedGameTime.TotalSeconds; } if (target != null && !isInRange(target.Center)) { target = null; } if (bullet != null) { bullet.Update(gameTime); if (!bullet.Alive && target != null) { bullet.HitTarget(target); } } } }
public void Attack(Enemy enemy) { if (reloadDuration <= 0) { reloadDuration = mFireReload; target = enemy; createBullet(); } }
public void Move() { if (mTarget != null) { mDirection = mTarget.Center - mCenter; mTargetCenter = mTarget.Center; if (mDirection.Length() < 15) { age = -1; mTarget = null; } else { mDirection.Normalize(); mVelocity = speed * mDirection; Rotation = findAngle(mVelocity, new Vector2(0, 1)); mCenter += mVelocity; age -= (int)mVelocity.Length(); } } else { mDirection = mTargetCenter - mCenter; if (mDirection.Length() < 15) { age = -1; } else { mDirection.Normalize(); mVelocity = speed * mDirection; Rotation = findAngle(mVelocity, new Vector2(0, 1)); mCenter += mVelocity; age -= (int)mVelocity.Length(); } } }
public void setTarget(Enemy pTarget) { mTarget = pTarget; mTargetCenter = mTarget.Center; mDirection = mTarget.Center - mCenter; age = (int)mDirection.Length(); }