您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

79 行
1.9 KiB

  1. using System;
  2. using SUISSEngine;
  3. using UnityEngine;
  4. public class UnlockVehicleShadowController : MonoBehaviour
  5. {
  6. public UnlockVehicleShadowController()
  7. {
  8. Vector3 vector = new Vector3(0f, 1f);
  9. this._flyingHeightUnit = vector.normalized;
  10. }
  11. protected virtual void Awake()
  12. {
  13. this._spriteRenderer = base.gameObject.GetComponent<SpriteRenderer>();
  14. this._lastLocation = this._vehicle.Location;
  15. }
  16. protected virtual void Update()
  17. {
  18. if (this._vehicle != null)
  19. {
  20. base.transform.localPosition = this._flyingHeightUnit * -this._vehicle.FlyingHeight;
  21. this._spriteRenderer.sortingOrder = GridTile.GetSortingOrder(new GridIndex(this._vehicle.Location), new GridSize(this._sizeInTilesU, this._sizeInTilesV));
  22. GridPoint gridPoint = this._vehicle.Location - this._lastLocation;
  23. this._lastLocation = this._vehicle.Location;
  24. Vector2 lhs = new Vector2(gridPoint.u, gridPoint.v);
  25. float num = 0f;
  26. int num2 = 0;
  27. int num3 = 0;
  28. while (num3 < this.spriteDirections.Length && num3 < this.sprites.Length)
  29. {
  30. float num4 = Vector2.Dot(lhs, this.spriteDirections[num3]);
  31. if (num4 > num)
  32. {
  33. num = num4;
  34. num2 = num3;
  35. }
  36. num3++;
  37. }
  38. this._spriteRenderer.sprite = this.sprites[num2 * this.spriteSheetSize + (int)this.spriteAnimationIndex];
  39. }
  40. }
  41. [SerializeField]
  42. private int spriteSheetSize = 1;
  43. [SerializeField]
  44. private int _sizeInTilesU;
  45. [SerializeField]
  46. private int _sizeInTilesV;
  47. [SerializeField]
  48. private float spriteAnimationIndex;
  49. [SerializeField]
  50. private Sprite[] sprites;
  51. [SerializeField]
  52. private Vector2[] spriteDirections = new Vector2[]
  53. {
  54. new Vector2(0f, 1f),
  55. new Vector2(1f, 0f),
  56. new Vector2(0f, -1f),
  57. new Vector2(-1f, 0f)
  58. };
  59. [SerializeField]
  60. private UnlockBuildingVehicle _vehicle;
  61. private Vector3 _flyingHeightUnit;
  62. private GridPoint _lastLocation;
  63. private SpriteRenderer _spriteRenderer;
  64. }