SelectDNACondition.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. {
  14. _selectPlayer = SelectPlayer;
  15. _targetDNA = targetDNA;
  16. _selectDNACoroutine = SelectDNACoroutine;
  17. _notDoSync = false;
  18. _isDigivolutionCost = false;
  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. public bool _endSelect = false;
  26. bool _notDoSync = false;
  27. bool _isDigivolutionCost = false;
  28. public void ResetSelectDNAConditionClass()
  29. {
  30. _selectedCount = 0;
  31. _endSelect = false;
  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. SetDNACondition(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);
  62. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  63. GManager.instance.photonView.RPC("SetDNACondition", RpcTarget.All, GManager.instance.userSelectionManager.SelectedIntValue);
  64. }
  65. }
  66. yield return new WaitWhile(() => !_endSelect);
  67. _endSelect = false;
  68. GManager.instance.commandText.CloseCommandText();
  69. yield return new WaitWhile(() => GManager.instance.commandText.gameObject.activeSelf);
  70. if (_selectDNACoroutine != null)
  71. {
  72. yield return ContinuousController.instance.StartCoroutine(_selectDNACoroutine(_selectedCount));
  73. }
  74. }
  75. [PunRPC]
  76. public void SetDNACondition(int selectedCount)
  77. {
  78. _selectedCount = selectedCount;
  79. _endSelect = true;
  80. }
  81. }