CombatChangeMapCom.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class CombatChangeMapCom : MonoBehaviour
  6. {
  7. private Transform frontHero;
  8. public Transform[] ChangeMapTransforms;
  9. public Transform[] ChangeMapNodes;
  10. public void OnEnable()
  11. {
  12. ChangeMapTransforms[0].transform.localPosition = Vector3.zero;
  13. ChangeMapTransforms[1].transform.localPosition = Vector3.forward * 22;
  14. frontHero = null;
  15. }
  16. void Start()
  17. {
  18. }
  19. private float _timer;
  20. private bool _isEnable;
  21. private int curIndex = 1;
  22. void Update()
  23. {
  24. _timer += Time.deltaTime;
  25. if (_timer > 1)
  26. {
  27. _timer = 0;
  28. if (frontHero == null)
  29. {
  30. frontHero = Player.Instance.transform;
  31. }
  32. if (frontHero != null)
  33. {
  34. if (frontHero.position.z > ChangeMapNodes[curIndex].position.z)
  35. {
  36. if (curIndex == 1)
  37. {
  38. ChangeMapTransforms[0].position = ChangeMapNodes[curIndex].position + Vector3.forward * 22;
  39. curIndex = 0;
  40. }
  41. else
  42. {
  43. ChangeMapTransforms[1].position = ChangeMapNodes[curIndex].position + Vector3.forward * 22;
  44. curIndex = 1;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }