Advertisement
shadowx320

EnemyTarget.cs

May 25th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. namespace SA {
  6. public class EnemyTarget : MonoBehaviour
  7. {
  8. public int index;
  9. public List<Transform> targets = new List<Transform>();
  10. public List<HumanBodyBones> h_bones = new List<HumanBodyBones>();
  11.  
  12. Animator anim;
  13.  
  14. void Start()
  15. {
  16. anim = GetComponent<Animator>();
  17. if (anim.isHuman == false)
  18. return;
  19.  
  20. for (int i = 0; i < h_bones.Count; i++)
  21. {
  22. targets.Add(anim.GetBoneTransform(h_bones[i]));
  23. }
  24. }
  25.  
  26. public Transform GetTarget(bool negative = false)
  27. {
  28. if (targets.Count == 0)
  29. return transform;
  30.  
  31. int targetIndex = index;
  32.  
  33. if (negative == false)
  34. {
  35. if(index < targets.Count - 1)
  36. {
  37. index++;
  38. }
  39. else
  40. {
  41. index = 0;
  42. targetIndex = 0;
  43. }
  44. }
  45. else
  46. {
  47. if(index < 0)
  48. {
  49. index = targets.Count - 1;
  50. targetIndex = targets.Count - 1;
  51. }
  52. else
  53. {
  54. index--;
  55. }
  56. }
  57.  
  58. return targets[index];
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement