BattleInviteManager.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using Api;
  4. using Plugins.CxShine.page;
  5. using Plugins.CxShine.Singleton;
  6. using UnityEngine;
  7. namespace UI.BattleRequest
  8. {
  9. public class BattleInviteManager : ScriptSingleton<BattleInviteManager>
  10. {
  11. // 收到向自己发起对战的玩家
  12. private HashSet<int> _invitePlayerIds = new();
  13. public bool isAlreayHasPeople(int id)
  14. {
  15. return (_invitePlayerIds.Contains(id));
  16. }
  17. public void RemoveInvitePlayerId(int id)
  18. {
  19. _invitePlayerIds.Remove(id);
  20. }
  21. private bool _isPrepareOpening;
  22. public void InviteBattle(int player,Action<ResponseSuccessData> action,Action<int,string> errrAction)
  23. {
  24. ApiComp.Instance.InviteBattleToPlayer(player,action,errrAction);
  25. }
  26. public void AddPlayerId(int invitePlayerPlayerId)
  27. {
  28. _invitePlayerIds.Add(invitePlayerPlayerId);
  29. }
  30. public bool isPrepareOpening()
  31. {
  32. return _isPrepareOpening;
  33. }
  34. public void Open(GameObject PreparePagePrefab, string battleSession, int enemyId)
  35. {
  36. _isPrepareOpening = true;
  37. _invitePlayerIds.Clear();
  38. var p = PageManagerComp.singleton.OpenPage(PreparePagePrefab);
  39. p.GetComponent<PreparePageComp>().init(battleSession, enemyId);
  40. }
  41. public void ClosePreparePage()
  42. {
  43. _isPrepareOpening = false;
  44. }
  45. }
  46. }