GamePendingState.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Comp;
  2. using Sound;
  3. using UnityEngine;
  4. namespace Game
  5. {
  6. public class GamePendingState : GameState
  7. {
  8. private const float CockInitialX = 2f;
  9. private const float StaticOffset = -2.534481f;
  10. private const float MastInitialX = 6f;
  11. public override void PlayBattle()
  12. {
  13. Debug.Log("play battle");
  14. _gameCore.GetController(_gameCore.localPlayer).Run();
  15. _gameCore.GetController(_gameCore.antiPlayer).Run();
  16. }
  17. public override void BattleStart()
  18. {
  19. _gameCore.TransitionToState(_gameCore.battleState);
  20. _gameCore.GetCurState().BattleStart();
  21. }
  22. public override void LiftCock()
  23. {
  24. // 啥都不做
  25. }
  26. public override void ExitBattle()
  27. {
  28. }
  29. public override void EndBattle()
  30. {
  31. // 啥都不做
  32. }
  33. public override void EnterState()
  34. {
  35. Debug.Log("enter pending state");
  36. // 处理鸡模型
  37. var localCockPrefab = CockFactory.Instance.GenerateCockPrefab(_gameCore.localPlayer.cockId);
  38. var antiCockPrefab = CockFactory.Instance.GenerateCockPrefab(_gameCore.antiPlayer.cockId);
  39. var localCock = Object.Instantiate(localCockPrefab);
  40. var antiCock = Object.Instantiate(antiCockPrefab);
  41. // 处理鸡组件
  42. var localCockActionComp = localCock.GetComponent<CockActionComp>();
  43. var antiCockActionComp = antiCock.GetComponent<CockActionComp>();
  44. localCockActionComp.cockId = _gameCore.localPlayer.cockId;
  45. antiCockActionComp.cockId = _gameCore.antiPlayer.cockId;
  46. localCockActionComp.playerId = _gameCore.localPlayer.playerId;
  47. antiCockActionComp.playerId = _gameCore.antiPlayer.playerId;
  48. localCockActionComp.MaxHp = _gameCore.localPlayer.hp;
  49. antiCockActionComp.MaxHp = _gameCore.antiPlayer.hp;
  50. _gameCore.cockDict.Add(_gameCore.localPlayer.playerId, localCockActionComp);
  51. _gameCore.cockDict.Add(_gameCore.antiPlayer.playerId, antiCockActionComp);
  52. localCock.GetComponent<SoundCtrl>().Tag = "player-" + _gameCore.localPlayer.playerId;
  53. antiCock.GetComponent<SoundCtrl>().Tag = "player-" + _gameCore.antiPlayer.playerId;
  54. localCock.transform.eulerAngles = new Vector3(0, 90, 0);
  55. antiCock.transform.eulerAngles = new Vector3(0, -90, 0);
  56. localCock.transform.position = new Vector3(-CockInitialX - StaticOffset, localCock.transform.position.y,
  57. localCock.transform.position.z);
  58. antiCock.transform.position =
  59. new Vector3(CockInitialX - StaticOffset, antiCock.transform.position.y, antiCock.transform.position.z);
  60. localCock.transform.parent = _gameCore.parent.transform;
  61. antiCock.transform.parent = _gameCore.parent.transform;
  62. // 处理主人模型
  63. var masterPrefab = Resources.Load<GameObject>("Human/prefab_master");
  64. var localMaster = Object.Instantiate(masterPrefab);
  65. var antiMaster = Object.Instantiate(masterPrefab);
  66. localMaster.transform.position = new Vector3(-MastInitialX - StaticOffset, localMaster.transform.position.y,
  67. localMaster.transform.position.z);
  68. antiMaster.transform.position =
  69. new Vector3(MastInitialX - StaticOffset, antiMaster.transform.position.y,
  70. antiMaster.transform.position.z);
  71. antiMaster.transform.eulerAngles = new Vector3(0, -90f, 0);
  72. localMaster.transform.parent = _gameCore.parent.transform;
  73. antiMaster.transform.parent = _gameCore.parent.transform;
  74. var localMasterActionComp = localMaster.GetComponent<MasterActionComp>();
  75. localMasterActionComp.playerId = _gameCore.localPlayer.playerId;
  76. var antiMasterActionComp = antiMaster.GetComponent<MasterActionComp>();
  77. antiMasterActionComp.playerId = _gameCore.antiPlayer.playerId;
  78. _gameCore.masterDict.Add(_gameCore.localPlayer.playerId, localMasterActionComp);
  79. _gameCore.masterDict.Add(_gameCore.antiPlayer.playerId, antiMasterActionComp);
  80. SoundCore.Instance.PlaySound(SoundType.BattleBgmStart, SoundCtrl.BattleEnvPlayer);
  81. Debug.Log("enter pending state finish");
  82. }
  83. public override void ExitState()
  84. {
  85. // 啥都不做
  86. }
  87. public GamePendingState(GameCore gameCore) : base(gameCore)
  88. {
  89. }
  90. }
  91. }