SelectDNACondition.cs 3.0 KB

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