FightIdleSubState.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using UnityEngine;
  2. namespace GameLogic.Combat.Hero.SubStatus
  3. {
  4. /// <summary>
  5. /// 战斗待机状态
  6. /// </summary>
  7. public class FightIdleSubState : SubStatusBasic
  8. {
  9. private Vector3 initPos;
  10. protected Vector3 targetPos;
  11. private Vector3 startPos;
  12. private float moveSpped = 1;
  13. private float addTime;
  14. private float allTime;
  15. private float allTimeX;
  16. protected override void ProInit()
  17. {
  18. initPos = CombatHeroEntity.dotPos;
  19. }
  20. protected override void ProDispose()
  21. {
  22. }
  23. protected override void ProUpdate(float t)
  24. {
  25. allTime += t * 2f;
  26. allTimeX += t * 1f;
  27. Vector3 p = Vector3.Lerp(startPos, targetPos, allTime);
  28. float y = Mathf.Sin(allTime) * (CombatHeroEntity.IsEnemy ? 0.1f : -0.1f);
  29. float x = Mathf.Cos(allTimeX) * (CombatHeroEntity.IsEnemy ? 0.8f : -0.8f);
  30. p = initPos + new Vector3(x, y, 0);
  31. CombatHeroEntity.combatHeroGameObject.SetPosition(p);
  32. }
  33. }
  34. }