SelectDNACondition.cs 2.8 KB

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