SelectDNACondition.cs 3.0 KB

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