public override void Update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Vector3 currentPosition = translation.Translation;

            // seek player, Unlike standard enemies (buggy) this big guy always seeks player regardless of dmg.

            Vector3? targetPlayer = GetNearestPlayer();

            if (targetPlayer.HasValue) {
                HandleAStarSeek(targetPlayer.Value, currentPosition, gameTime);
            }

            if (seekLocation.HasValue) {
                HandleRotation(seekLocation.Value, currentPosition);
                currentSeekState = seekState.Player;

            }

            MovementClamp();

            // change enemy model to signify damage
            if (health < MAX_HEALTH) {
                base.tintColour = BasicModel.TINT_RED;
            } else {
                base.tintColour = BasicModel.TINT_TRANSPARENT;
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Vector3 currentPosition = translation.Translation;
            Vector3? targetItem = GetNearestEnergyItem();

            if (!targetItem.HasValue) {
                targetItem = randomPoint;
            }

            // if damaged, then seek health box
            // however, if Game1.EnemyDamagedBehaviour is read from XML Behaviour config, and set to agressive then don't hunt health,
            // just attack player mercilessly!
            if (health < MAX_HEALTH && game.enemyDamagedBehaviour == Game1.EnemyDamagedBehaviour.normal) {

                // first clear previous player seek path.
                if (!bClearedPlayerSeekPaths) {
                    this.aStarPaths.Clear();
                    bClearedPlayerSeekPaths = true;

                }

                if (targetItem.HasValue) {

                    if (targetItem.HasValue) {
                        HandleAStarSeek(targetItem.Value, currentPosition, gameTime);
                    }

                    if (seekLocation.HasValue) {
                        HandleRotation(seekLocation.Value, currentPosition);
                    }

                    currentSeekState = seekState.EnergyItem;
                } else {
                    currentSeekState = seekState.Flee;
                }

            } else if (game.enemyDamagedBehaviour == Game1.EnemyDamagedBehaviour.thief) {
                // if game1 behaviour is set to thief then regardless of what happens just steal the energy items!
                if (targetItem.HasValue) {
                    HandleAStarSeek(targetItem.Value, currentPosition, gameTime);
                }

                if (seekLocation.HasValue) {
                    HandleRotation(seekLocation.Value, currentPosition);
                }
                currentSeekState = seekState.EnergyItem;
            } else {

                // if not damaged then seek player

                Vector3? targetPlayer = GetNearestPlayer();
                bClearedPlayerSeekPaths = false;

                if (targetPlayer.HasValue) {
                    HandleAStarSeek(targetPlayer.Value, currentPosition, gameTime);
                }

                if (seekLocation.HasValue) {
                    HandleRotation(seekLocation.Value, currentPosition);
                    currentSeekState = seekState.Player;
                }

            }

            if (this.knockbackModelPosition != null) {
                HandleJump(false);
            }

            MovementClamp();

            // change enemy model to signify damage
            if (health < MAX_HEALTH) {
                base.tintColour = BasicModel.TINT_RED;
            } else {
                base.tintColour = BasicModel.TINT_TRANSPARENT;
            }

            base.Update(gameTime);
        }