|
|
@@ -12,9 +12,12 @@ public class GameAssistUI : MonoBehaviour
|
|
|
[SerializeField] Text text2;
|
|
|
public static GameAssistUI ins;
|
|
|
|
|
|
+ void Awake() {
|
|
|
+ ins = this;
|
|
|
+ }
|
|
|
+
|
|
|
void Start()
|
|
|
{
|
|
|
- ins = this;
|
|
|
this.transform.Find("Button0").GetComponent<Button>().onClick.AddListener(delegate(){
|
|
|
AudioMgr.ins.PlayBtn();
|
|
|
SceneManager.LoadScene("Home", LoadSceneMode.Single);
|
|
|
@@ -64,6 +67,8 @@ public class GameAssistUI : MonoBehaviour
|
|
|
targetView.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 30);
|
|
|
btnViewTarget.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 195);
|
|
|
}
|
|
|
+ //看看是不是双人游戏的再次对战
|
|
|
+ applyPlayerRecordsWhenGameTryAgain();
|
|
|
}
|
|
|
|
|
|
// ------ 开镜瞄准功能 ------
|
|
|
@@ -72,6 +77,7 @@ public class GameAssistUI : MonoBehaviour
|
|
|
float[] scaleAimFieldOfViews = {30, 20, 12, 6, 3};
|
|
|
float[] scaleAimScopeScales = {150, 98, 58, 29, 14.5f};
|
|
|
Sequence seq1 = null;
|
|
|
+ bool scaleAimOn = false; //该功能是否处于打开状态
|
|
|
bool openScaleAim()
|
|
|
{
|
|
|
int scaleValue = GetPropScaleAimValue();
|
|
|
@@ -87,6 +93,8 @@ public class GameAssistUI : MonoBehaviour
|
|
|
scope = bowCamera.transform.Find("Scope");
|
|
|
float scopeScale = scaleAimScopeScales[scaleValue - 1];
|
|
|
scope.localScale = new Vector3(scopeScale, scopeScale, scopeScale);
|
|
|
+ scaleAimOn = true;
|
|
|
+ onOpenScaleAimSuccess();
|
|
|
return true;
|
|
|
}
|
|
|
if (seq1 != null && !seq1.IsComplete()) {
|
|
|
@@ -109,6 +117,8 @@ public class GameAssistUI : MonoBehaviour
|
|
|
ArmBow.ins.transform.localPosition = localPosition;
|
|
|
scope.localScale = new Vector3(0, 0, 0);
|
|
|
scope = null;
|
|
|
+ scaleAimOn = false;
|
|
|
+ onCloseScaleAimSuccess();
|
|
|
}
|
|
|
|
|
|
int GetPropScaleAimValue()
|
|
|
@@ -128,6 +138,7 @@ public class GameAssistUI : MonoBehaviour
|
|
|
|
|
|
public int shootScaleValue = 1;
|
|
|
Sequence seq2 = null;
|
|
|
+ bool scaleShootOn = false; //该功能是否处于打开状态
|
|
|
|
|
|
bool openScaleShoot()
|
|
|
{
|
|
|
@@ -138,6 +149,8 @@ public class GameAssistUI : MonoBehaviour
|
|
|
PropScaleShoot config = prop.config as PropScaleShoot;
|
|
|
shootScaleValue = config.scaleValue;
|
|
|
if (GameDebug.ins) GameDebug.ins.caluculateAbsoluteAngle();
|
|
|
+ scaleShootOn = true;
|
|
|
+ onOpenScaleShootSuccess();
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
@@ -154,5 +167,93 @@ public class GameAssistUI : MonoBehaviour
|
|
|
{
|
|
|
shootScaleValue = 1;
|
|
|
if (GameDebug.ins) GameDebug.ins.caluculateAbsoluteAngle();
|
|
|
+ scaleShootOn = false;
|
|
|
+ onCloseScaleShootSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ //------ 以下给双人模式分别记录提供的接口 ------
|
|
|
+
|
|
|
+ //两位玩家的开镜情况
|
|
|
+ bool[] playerScaleAimRecords = {false, false};
|
|
|
+ //两位玩家的加速情况
|
|
|
+ bool[] playerScaleShootRecords = {false, false};
|
|
|
+
|
|
|
+ private void onOpenScaleAimSuccess() {
|
|
|
+ if (GameMgr.gameType == 2) {
|
|
|
+ playerScaleAimRecords[getPlayerIndex()] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onCloseScaleAimSuccess() {
|
|
|
+ if (GameMgr.gameType == 2) {
|
|
|
+ playerScaleAimRecords[getPlayerIndex()] = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onOpenScaleShootSuccess() {
|
|
|
+ if (GameMgr.gameType == 2) {
|
|
|
+ playerScaleShootRecords[getPlayerIndex()] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onCloseScaleShootSuccess() {
|
|
|
+ if (GameMgr.gameType == 2) {
|
|
|
+ playerScaleShootRecords[getPlayerIndex()] = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int getPlayerIndex() {
|
|
|
+ return ((PKGameMode) GameMgr.ins.gameMode).currentPlayerIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateFunctionByPlayerRecords() {
|
|
|
+ if (GameMgr.gameType != 2) return;
|
|
|
+ int playerIndex = getPlayerIndex();
|
|
|
+ if (scaleAimOn != playerScaleAimRecords[playerIndex]) {
|
|
|
+ Button btnScaleAim = this.transform.Find("Button2").GetComponent<Button>();
|
|
|
+ if (playerScaleAimRecords[playerIndex]) {
|
|
|
+ if (openScaleAim()) {
|
|
|
+ btnScaleAim.GetComponentInChildren<Image>().material = outlight;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ btnScaleAim.GetComponentInChildren<Image>().material = null;
|
|
|
+ closeScaleAim();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (scaleShootOn != playerScaleShootRecords[playerIndex]) {
|
|
|
+ Button btnScaleShoot = this.transform.Find("Button3").GetComponent<Button>();
|
|
|
+ if (playerScaleShootRecords[playerIndex]) {
|
|
|
+ if (openScaleShoot()) {
|
|
|
+ btnScaleShoot.GetComponentInChildren<Image>().material = outlight;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ btnScaleShoot.GetComponentInChildren<Image>().material = null;
|
|
|
+ closeScaleShoot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static bool[] playerRecords = null;
|
|
|
+
|
|
|
+ public void recordPlayerRecordsWhenGameTryAgain() {
|
|
|
+ if (GameMgr.gameType != 2) return;
|
|
|
+ playerRecords = new bool[] {
|
|
|
+ playerScaleAimRecords[0], playerScaleAimRecords[1],
|
|
|
+ playerScaleShootRecords[0], playerScaleShootRecords[1]
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ private void applyPlayerRecordsWhenGameTryAgain() {
|
|
|
+ if (playerRecords != null) {
|
|
|
+ playerScaleAimRecords[0] = playerRecords[0];
|
|
|
+ playerScaleAimRecords[1] = playerRecords[1];
|
|
|
+ playerScaleShootRecords[0] = playerRecords[2];
|
|
|
+ playerScaleShootRecords[1] = playerRecords[3];
|
|
|
+ playerRecords = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void Update() {
|
|
|
+ updateFunctionByPlayerRecords();
|
|
|
}
|
|
|
}
|