/// <summary> /// Method for drawing NPCs /// </summary> /// <param name="elapsedTime">Elapsed time in milleseconds</param> private void DrawNPC(float elapsedTime) { foreach (Model.NonPlayerCharacter friend in _nonPlayerCharacters) { //Checks wheter the NPC occurs within the camera screen if (friend.ThisUnit.Bounds.Intersects(_camera.GetScreenRectangle)) { friend.CanAddToQuest = true; //Setting the NPC as target on click if (_inputHandler.DidGetTargetedByLeftClick(_camera.VisualizeRectangle(friend.ThisUnit.Bounds)) || _inputHandler.DidGetTargetedByRightClick(_camera.VisualizeRectangle(friend.ThisUnit.Bounds))) { _player.Target = friend; } Vector2 interactPosition = _camera.VisualizeCordinates(friend.ThisUnit.Bounds.X + 10, friend.ThisUnit.Bounds.Y - 24); int bubble = -1; //Drawing dialog box if the NPC ID excists in the XML file for Dialogs if (_conversation.DialogueList.Exists(Message => Message.id == friend.UnitId)) { friend.CanInterract = true; bubble = Convert.ToInt32(Texture.INTERACT); } else if ((_questSystem.QuestList.Exists(Quest => _questSystem.ActiveNpc == friend.UnitId && Quest.Id == _questSystem.CurrentQuest.Id))) { friend.CanInterract = true; if (_questSystem.CurrentQuest.Status == Model.QuestSystem.END) { bubble = Convert.ToInt32(Texture.INTERACT_Q_COMPLETE); } else if (_questSystem.CurrentQuest.Status == Model.QuestSystem.PRE) { bubble = Convert.ToInt32(Texture.INTERACT_Q); } else { bubble = Convert.ToInt32(Texture.INTERACT); } } else { friend.CanInterract = false; } if (friend.CanInterract) { _spriteBatch.Draw(_textures[bubble], new Rectangle((int)interactPosition.X, (int)interactPosition.Y, 30, 30), Color.White); } //Drawing NPC Vector2 npcPosition = _camera.VisualizeCordinates(friend.ThisUnit.Bounds.X + 8, friend.ThisUnit.Bounds.Y + 8); AnimationSystem.Texture animation = 0; if (friend.Type == Model.NonPlayerCharacter.OLD_MAN) { animation = AnimationSystem.Texture.OLD_MAN; } else { animation = AnimationSystem.Texture.CITY_GUARD; } //Drawing target circle DrawTargetCircle(_player, friend); _animationSystem.UpdateAndDraw(elapsedTime, Color.White, npcPosition, friend.UnitState, animation); } else { friend.CanAddToQuest = false; } } }
/// <summary> /// Method for drawing player armor /// </summary> /// <param name="elapsedTime">Elapsed time in milleseconds</param> /// <param name="player">Player object</param> /// <param name="unitState">Unit state</param> /// <param name="armorTextureIndex">Texture index for the armor</param> private void DrawArmor(float elapsedTime, Model.Player player, Model.State unitState, AnimationSystem.Texture armorTextureIndex) { Vector2 armorPlacement = Vector2.Zero; switch (armorTextureIndex) { case AnimationSystem.Texture.ARMOR_HEAD: armorPlacement = _camera.VisualizeCordinates(player.ThisUnit.Bounds.X, player.ThisUnit.Bounds.Y); break; } Model.State armorAnimation; if (unitState == Model.State.MOVING_DOWN) { armorAnimation = Model.State.FACING_CAMERA; } else if (unitState == Model.State.MOVING_UP) { armorAnimation = Model.State.FACING_AWAY; } else if (unitState == Model.State.MOVING_LEFT) { armorAnimation = Model.State.FACING_LEFT; } else if (unitState == Model.State.MOVING_RIGHT) { armorAnimation = Model.State.FACING_RIGHT; } else if (unitState == Model.State.IS_CASTING_HEAL) { armorAnimation = Model.State.FACING_CAMERA; } else { armorAnimation = unitState; } _animationSystem.UpdateAndDraw(elapsedTime, Color.White, armorPlacement, armorAnimation, AnimationSystem.Texture.ARMOR_HEAD); }