YejiHuntGameMode_LocalPK.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class YejiHuntGameMode_LocalPK : YejiHuntGameMode, ChallengeGameModeLocalPK
  5. {
  6. public int currentPlayerIndex = 0; // 双人0和1
  7. float singleShootReadyTime = 30f;
  8. float singleShootReadyTimeMax = 30f;
  9. public YejiHuntGameMode_LocalPK(GameMgr gameMgr) : base(gameMgr) {
  10. hunterGamePlayerScoreCounter = new HunterGamePlayerScoreCounter(this);
  11. }
  12. public override void Start()
  13. {
  14. Yeji.InitPreHeights();
  15. SetLevel(5);
  16. AddHuntGameView();
  17. this.gameMgr.transform.Find("HunterGameView_LocalPK").gameObject.SetActive(true);
  18. AddReadyView();
  19. }
  20. public override bool DoNextShoot() {
  21. bool canDo = base.DoNextShoot();
  22. if (canDo) {
  23. NextPlayerFinal();
  24. }
  25. return canDo;
  26. }
  27. void AddReadyView()
  28. {
  29. GameObject view = Resources.Load<GameObject>("Prefabs/Views/PKGameReadyView_Challenge");
  30. GameObject o = GameObject.Instantiate(view);
  31. PKGameReadyView_Challenge script = o.GetComponent<PKGameReadyView_Challenge>();
  32. script.currentPlayerIndex = currentPlayerIndex;
  33. }
  34. void NextPlayerFinal() {
  35. NextPlayer();
  36. BanBowReady();
  37. AddReadyView();
  38. }
  39. void NextPlayer() {
  40. currentPlayerIndex++;
  41. currentPlayerIndex %= 2;
  42. singleShootReadyTime = singleShootReadyTimeMax;
  43. }
  44. public override void Update() {
  45. base.Update();
  46. if (gameMgr.gameOver || pauseTimeCounting) return;
  47. singleShootReadyTime -= Time.deltaTime;
  48. if (singleShootReadyTime <= 0) {
  49. //切换玩家
  50. ArmBow.ins.readyShoot();
  51. NextPlayerFinal();
  52. }
  53. }
  54. //localPK interface
  55. public int GetCurrentPlayIndex() {
  56. return currentPlayerIndex;
  57. }
  58. public (float, float) GetSingleShootReadyTime() {
  59. return (singleShootReadyTime, singleShootReadyTimeMax);
  60. }
  61. HunterGamePlayerScoreCounter hunterGamePlayerScoreCounter;
  62. public HunterGamePlayerScoreCounter getHunterGamePlayerScoreCounter() {
  63. return hunterGamePlayerScoreCounter;
  64. }
  65. }