GamePendingState.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. var localCockActionComp = localCock.GetComponent<CockActionComp>();
  42. localCockActionComp.cockId = _gameCore.localPlayer.cockId;
  43. var antiCockActionComp = antiCock.GetComponent<CockActionComp>();
  44. antiCockActionComp.cockId = _gameCore.antiPlayer.cockId;
  45. localCockActionComp.playerId = _gameCore.localPlayer.playerId;
  46. antiCockActionComp.playerId = _gameCore.antiPlayer.playerId;
  47. _gameCore.cockDict.Add(_gameCore.localPlayer.playerId, localCockActionComp);
  48. _gameCore.cockDict.Add(_gameCore.antiPlayer.playerId, antiCockActionComp);
  49. localCock.GetComponent<SoundCtrl>().Tag = "player-" + _gameCore.localPlayer.playerId;
  50. antiCock.GetComponent<SoundCtrl>().Tag = "player-" + _gameCore.antiPlayer.playerId;
  51. localCock.transform.eulerAngles = new Vector3(0, 90, 0);
  52. antiCock.transform.eulerAngles = new Vector3(0, -90, 0);
  53. localCock.transform.position = new Vector3(-CockInitialX - StaticOffset, localCock.transform.position.y,
  54. localCock.transform.position.z);
  55. antiCock.transform.position =
  56. new Vector3(CockInitialX - StaticOffset, antiCock.transform.position.y, antiCock.transform.position.z);
  57. localCock.transform.parent = _gameCore.parent.transform;
  58. antiCock.transform.parent = _gameCore.parent.transform;
  59. // 处理主人模型
  60. var masterPrefab = Resources.Load<GameObject>("Human/prefab_master");
  61. var localMaster = Object.Instantiate(masterPrefab);
  62. var antiMaster = Object.Instantiate(masterPrefab);
  63. localMaster.transform.position = new Vector3(-MastInitialX - StaticOffset, localMaster.transform.position.y,
  64. localMaster.transform.position.z);
  65. antiMaster.transform.position =
  66. new Vector3(MastInitialX - StaticOffset, antiMaster.transform.position.y,
  67. antiMaster.transform.position.z);
  68. antiMaster.transform.eulerAngles = new Vector3(0, -90f, 0);
  69. localMaster.transform.parent = _gameCore.parent.transform;
  70. antiMaster.transform.parent = _gameCore.parent.transform;
  71. var localMasterActionComp = localMaster.GetComponent<MasterActionComp>();
  72. localMasterActionComp.playerId = _gameCore.localPlayer.playerId;
  73. var antiMasterActionComp = antiMaster.GetComponent<MasterActionComp>();
  74. antiMasterActionComp.playerId = _gameCore.antiPlayer.playerId;
  75. _gameCore.masterDict.Add(_gameCore.localPlayer.playerId, localMasterActionComp);
  76. _gameCore.masterDict.Add(_gameCore.antiPlayer.playerId, antiMasterActionComp);
  77. SoundCore.Instance.PlaySound(SoundType.BattleBgmStart, SoundCtrl.BattleEnvPlayer);
  78. Debug.Log("enter pending state finish");
  79. }
  80. public override void ExitState()
  81. {
  82. // 啥都不做
  83. }
  84. public GamePendingState(GameCore gameCore) : base(gameCore)
  85. {
  86. }
  87. }
  88. }