YejiHuntGameMode_LocalPK.cs 2.2 KB

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