InviteData.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3. using System.Collections;
  4. public class InviteData
  5. {
  6. public enum State
  7. {
  8. Online = 0,
  9. Battle = 1,
  10. Offline = 2,
  11. }
  12. private static System.Array stateArr = System.Enum.GetValues (typeof(State));
  13. public static State GetStateByCode(int code)
  14. {
  15. return (State)stateArr.GetValue (code);
  16. }
  17. public enum Action
  18. {
  19. Invite = 0,
  20. Waiting = 1,
  21. Refuse = 2,
  22. InTeam = 3,
  23. }
  24. private static System.Array actionArr = System.Enum.GetValues (typeof(Action));
  25. public static Action GetActionByCode(int code)
  26. {
  27. return (Action)actionArr.GetValue (code);
  28. }
  29. public const float INVITE_HOLD_ON = 30f;
  30. public const float INVITE_REFUSE_HOLD_ON = 5f;
  31. public int id;
  32. public float lastActionTime;
  33. public UnityEvent StateChanged;
  34. public UnityEvent ActionChanged;
  35. public InviteData()
  36. {
  37. StateChanged = new UnityEvent ();
  38. ActionChanged = new UnityEvent ();
  39. }
  40. private State m_State;
  41. public State state
  42. {
  43. get{
  44. return m_State;
  45. }
  46. set{
  47. m_State = value;
  48. StateChanged.Invoke ();
  49. }
  50. }
  51. private Action m_Action;
  52. public Action action
  53. {
  54. get{
  55. return m_Action;
  56. }
  57. set{
  58. m_Action = value;
  59. lastActionTime = GameTime.time;
  60. ActionChanged.Invoke ();
  61. }
  62. }
  63. }