using System.Collections; using System.Collections.Generic; using UnityEngine; /* 野兔关卡-本地pk模式 */ public class RabbitHuntGameMode_LocalPK : RabbitHuntGameMode, ChallengeGameModeLocalPK { public int currentPlayerIndex = 0; // 双人0和1 float singleShootReadyTime = 30f; float singleShootReadyTimeMax = 30f; public RabbitHuntGameMode_LocalPK(GameMgr gameMgr) : base(gameMgr) { hunterGamePlayerScoreCounter = new HunterGamePlayerScoreCounter(this); } public override void Start() { SetLevel(5); AddHuntGameView(); this.gameMgr.transform.Find("HunterGameView_LocalPK").gameObject.SetActive(true); AddReadyView(); } public override bool DoNextShoot() { bool canDo = base.DoNextShoot(); if (canDo) { NextPlayerFinal(); } return canDo; } void AddReadyView() { GameObject view = Resources.Load("Prefabs/Views/PKGameReadyView_Challenge"); GameObject o = GameObject.Instantiate(view); PKGameReadyView_Challenge script = o.GetComponent(); script.currentPlayerIndex = currentPlayerIndex; } void NextPlayerFinal() { NextPlayer(); BanBowReady(); AddReadyView(); } void NextPlayer() { currentPlayerIndex++; currentPlayerIndex %= 2; singleShootReadyTime = singleShootReadyTimeMax; } public override void Update() { base.Update(); if (gameMgr.gameOver || pauseTimeCounting) return; singleShootReadyTime -= Time.deltaTime; if (singleShootReadyTime <= 0) { //切换玩家 ArmBow.ins.readyShoot(); NextPlayerFinal(); } } //localPK interface public int GetCurrentPlayIndex() { return currentPlayerIndex; } public (float, float) GetSingleShootReadyTime() { return (singleShootReadyTime, singleShootReadyTimeMax); } HunterGamePlayerScoreCounter hunterGamePlayerScoreCounter; public HunterGamePlayerScoreCounter getHunterGamePlayerScoreCounter() { return hunterGamePlayerScoreCounter; } } public interface ChallengeGameModeLocalPK { public int GetCurrentPlayIndex(); //获取单次射击的准备时间/准备时间上限(就是当前玩家的操作倒计时) public (float, float) GetSingleShootReadyTime(); public HunterGamePlayerScoreCounter getHunterGamePlayerScoreCounter(); }