RabbitHuntGameMode_LocalPK.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class RabbitHuntGameMode_LocalPK : RabbitHuntGameMode, ChallengeGameModeLocalPK
  5. {
  6. int currentPlayerIndex = 0; // 双人0和1
  7. public RabbitHuntGameMode_LocalPK(GameMgr gameMgr) : base(gameMgr) {
  8. }
  9. public override void Start()
  10. {
  11. SetLevel(5);
  12. AddHuntGameView();
  13. this.gameMgr.transform.Find("HunterGameView_LocalPK").gameObject.SetActive(true);
  14. AddReadyView();
  15. }
  16. public override bool DoNextShoot() {
  17. bool canDo = base.DoNextShoot();
  18. if (canDo) {
  19. NextPlayer();
  20. BanBowReady();
  21. AddReadyView();
  22. }
  23. return canDo;
  24. }
  25. void AddReadyView()
  26. {
  27. GameObject view = Resources.Load<GameObject>("Prefabs/Views/PKGameReadyView_Challenge");
  28. GameObject o = GameObject.Instantiate(view);
  29. PKGameReadyView_Challenge script = o.GetComponent<PKGameReadyView_Challenge>();
  30. script.currentPlayerIndex = currentPlayerIndex;
  31. }
  32. void NextPlayer() {
  33. currentPlayerIndex++;
  34. currentPlayerIndex %= 2;
  35. }
  36. //localPK interface
  37. public int GetCurrentPlayIndex() {
  38. return currentPlayerIndex;
  39. }
  40. }
  41. public interface ChallengeGameModeLocalPK {
  42. public int GetCurrentPlayIndex();
  43. }