lvjincheng пре 3 година
родитељ
комит
354647e265

+ 29 - 0
Assets/BowArrow/Scripts/Components/ScreenShotTester.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+//游戏全屏截图-快捷截图
+public class ScreenShotTester : MonoBehaviour
+{
+    private string saveDir; 
+
+    public static void Init(string saveDir) {
+        if (!saveDir.EndsWith("\\")) throw new System.Exception("路径错误");
+        if (FindObjectOfType<ScreenShotTester>()) return;
+        var comp = new GameObject(typeof(ScreenShotTester).Name).AddComponent<ScreenShotTester>();
+        comp.saveDir = saveDir;
+        DontDestroyOnLoad(comp);
+    }
+
+    void Update() {
+        #if UNITY_EDITOR
+        if (Input.GetKeyDown(KeyCode.S)) {
+            TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1);
+            string fileName = ts.TotalMilliseconds + ".jpg";
+            ScreenCapture.CaptureScreenshot(saveDir + fileName);
+            Debug.LogWarning("截图成功-" + fileName);
+        }
+        #endif
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/Components/ScreenShotTester.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 75211657a1d2bf74fa0058460537dfe1
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 17 - 0
Assets/BowArrow/Scripts/GameMode/ChallengeGameMode.cs

@@ -66,6 +66,23 @@ public abstract class ChallengeGameMode : GameMode
     }
 
     public override void Update() {
+        #if UNITY_EDITOR
+        if (Input.GetKey(KeyCode.W) && !gameMgr.gameOver) { //win
+            Debug.LogWarning("debug-win");
+            gameMgr.gameOver = true;
+            animalCount = 0;
+            foreach (var item in animalSet)
+            {
+                GameObject.Destroy(item.gameObject);
+            }
+            AnnounceGameOver();
+        }
+        if (Input.GetKey(KeyCode.F) && !gameMgr.gameOver) { //fail
+            gameMgr.gameOver = true;
+            Debug.LogWarning("debug-fail");
+            AnnounceGameOver();
+        }
+        #endif
         if (gameMgr.gameOver || pauseTimeCounting) return;
         if (this.time > 0) {
             if (GlobalData.pkMatchType == PKMatchType.None && UserSettings.ins.trainMode) {

+ 12 - 0
Assets/BowArrow/Scripts/GameMode/TimeLimitGameMode.cs

@@ -73,6 +73,18 @@ public class TimeLimitGameMode : GameMode {
     }
 
     public override void Update() {
+        #if UNITY_EDITOR
+        if (Input.GetKey(KeyCode.W) && this.time > 0) { //win
+            Debug.LogWarning("debug-win");
+            this.score = 100;
+            this.time = 0;
+        }
+        if (Input.GetKey(KeyCode.F) && this.time > 0) { //fail
+            Debug.LogWarning("debug-fail");
+            this.score = 10;
+            this.time = 0;
+        }
+        #endif
         if (gameMgr.gameOver || pauseTimeCounting) return;
         if (this.time > 0) {
             if (GlobalData.pkMatchType == PKMatchType.None && UserSettings.ins.trainMode) {

+ 1 - 0
Assets/BowArrow/Scripts/Manager/HomeMgr.cs

@@ -16,6 +16,7 @@ public class HomeMgr : MonoBehaviour
     void Start() {
         ResumeCacheViews();
         UserPlayer.ConnectServer();
+        // ScreenShotTester.Init("C:\\Users\\JC\\Desktop\\弓箭截图\\");
     }
 
     void OnDestroy()