Unit.cs 888 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. namespace Model
  3. {
  4. public enum UnitType
  5. {
  6. Hero,
  7. Npc
  8. }
  9. [ObjectEvent]
  10. public class UnitEvent : ObjectEvent<Unit>, IAwake<UnitType>
  11. {
  12. public void Awake(UnitType unitType)
  13. {
  14. this.Get().Awake(unitType);
  15. }
  16. }
  17. public sealed class Unit: Entity
  18. {
  19. public UnitType UnitType { get; private set; }
  20. public VInt3 IntPos;
  21. public GameObject GameObject;
  22. public void Awake(UnitType unitType)
  23. {
  24. this.UnitType = unitType;
  25. }
  26. public Vector3 Position
  27. {
  28. get
  29. {
  30. return GameObject.transform.position;
  31. }
  32. set
  33. {
  34. GameObject.transform.position = value;
  35. }
  36. }
  37. public Quaternion Rotation
  38. {
  39. get
  40. {
  41. return GameObject.transform.rotation;
  42. }
  43. set
  44. {
  45. GameObject.transform.rotation = value;
  46. }
  47. }
  48. public override void Dispose()
  49. {
  50. if (this.Id == 0)
  51. {
  52. return;
  53. }
  54. base.Dispose();
  55. }
  56. }
  57. }