SelectDNACondition.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Photon.Pun;
  5. using System;
  6. public class SelectDNACondition : MonoBehaviourPunCallbacks
  7. {
  8. public void SetUp
  9. (Player SelectPlayer,
  10. CardSource targetDNA,
  11. Func<int, IEnumerator> SelectDNACoroutine,
  12. bool IsLocal = false)
  13. {
  14. _selectPlayer = SelectPlayer;
  15. _targetDNA = targetDNA;
  16. _selectDNACoroutine = SelectDNACoroutine;
  17. _notDoSync = false;
  18. _isLocal = IsLocal;
  19. }
  20. Player _selectPlayer = null;
  21. CardSource _targetDNA = null;
  22. Func<int, IEnumerator> _selectDNACoroutine = null;
  23. List<int> _candidates = new List<int>();
  24. public int _selectedCount = 0;
  25. bool _notDoSync = false;
  26. bool _isLocal = false;
  27. public void ResetSelectDNAConditionClass()
  28. {
  29. _selectedCount = 0;
  30. }
  31. public IEnumerator Activate()
  32. {
  33. if (!_notDoSync)
  34. {
  35. //yield return GManager.instance.photonWaitController.StartWait("SelectDNACondition");
  36. }
  37. if (_targetDNA.jogressCondition.Count > 1)
  38. {
  39. if (_targetDNA.jogressCondition.Count == 1)
  40. {
  41. _selectedCount = 0;
  42. }
  43. else
  44. {
  45. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  46. for (int i = 0; i < _targetDNA.jogressCondition.Count; i++)
  47. {
  48. string message = $"";
  49. for (int e = 0; e < _targetDNA.jogressCondition[i].elements.Length; e++)
  50. {
  51. message += $"{_targetDNA.jogressCondition[i].elements[e].SelectMessage}";
  52. if (e < _targetDNA.jogressCondition[i].elements.Length - 1)
  53. message += " + ";
  54. }
  55. selectionElements.Add(new(message: $"{message}", value: i, spriteIndex: 0));
  56. }
  57. string selectPlayerMessage = "Which DNA do you want?";
  58. string notSelectPlayerMessage = "The opponent is choosing from which DNA to do.";
  59. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: _targetDNA.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage, _isLocal);
  60. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  61. _selectedCount = GManager.instance.userSelectionManager.SelectedIntValue;
  62. }
  63. }
  64. GManager.instance.commandText.CloseCommandText();
  65. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  66. if (_selectDNACoroutine != null)
  67. {
  68. yield return ContinuousController.instance.StartCoroutine(_selectDNACoroutine(_selectedCount));
  69. }
  70. }
  71. }