Parcourir la source

Merge branch 'master' of http://81.70.224.233:10080/yichael/SmartBow

slambb il y a 4 ans
Parent
commit
c0b13ada41

+ 18 - 5
Assets/BowArrow/Scenes/Game.unity

@@ -250,7 +250,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!4 &22246723
 Transform:
   m_ObjectHideFlags: 0
@@ -1089,7 +1089,7 @@ Transform:
   - {fileID: 543450653046805445}
   - {fileID: 543450653274718124}
   m_Father: {fileID: 0}
-  m_RootOrder: 2
+  m_RootOrder: 3
   m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
 --- !u!1 &133083727
 GameObject:
@@ -4051,7 +4051,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   cameraComp: {fileID: 394830266}
-  debugInEditor: 0
+  debugInEditor: 1
 --- !u!1 &403650814
 GameObject:
   m_ObjectHideFlags: 0
@@ -9403,7 +9403,6 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: e97c37446b5827f4a9f74dce82e5ff36, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  controlObj: {fileID: 1680053129}
   SetIdentityButton: {fileID: 71587487}
   MagCalibrationButton: {fileID: 358689046}
   GyrCalibrationButton: {fileID: 1486635947}
@@ -12119,6 +12118,7 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 1680053129}
+  - component: {fileID: 1680053130}
   m_Layer: 0
   m_Name: CameraToLook
   m_TagString: Untagged
@@ -12139,8 +12139,21 @@ Transform:
   m_Children:
   - {fileID: 383624205}
   m_Father: {fileID: 0}
-  m_RootOrder: 3
+  m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &1680053130
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1680053128}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 535cffd51d2f08a47817d1142453c8c8, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  isNew: 1
 --- !u!1 &1680621885
 GameObject:
   m_ObjectHideFlags: 0

+ 28 - 32
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -4,11 +4,21 @@ using System.Collections.Generic;
 using System.Linq;
 using UnityEngine.UI;
 using Newtonsoft.Json;
-using o0Aien;
 
 public class AimHandler : MonoBehaviour
 {
-    [SerializeField] Transform controlObj;
+    Transform controlObj {
+        get {
+            CameraToLook ctl = CameraToLook.ins;
+            if (ctl && ctl.isNew) 
+            {
+                ctl.isNew = false;
+                InitAutoIdentity();
+            }
+            if (ctl) return ctl.transform;
+            else return null;      
+        }
+    }
     [SerializeField] Button SetIdentityButton;
     [SerializeField] Button MagCalibrationButton;
     [SerializeField] Button GyrCalibrationButton;
@@ -285,56 +295,42 @@ public class AimHandler : MonoBehaviour
         }
         // 记录一些旋转角---end
 
-        receiveDataCount++;
-        if (!hasAutoIdentity && receiveDataCount == 5) {
-            doIdentity = true;
-        }
+        checkAutoIdentity();
     }   
 
-    void DoIdentity()
-    {
-        if (hasAutoIdentity)
-        {
-            doIdentity = true;
-            Debug.Log("reset identity");
-        }
-    }
-
     public void Update()
     {
-        if (hasAutoIdentity && controlObj)
+        if (controlObj && hasAutoIdentity)
         {
             // 最终结果进行lerp
             controlObj.localRotation = Quaternion.Lerp(controlObj.localRotation, newRotation, Time.deltaTime * 8);
             // controlObj.localRotation = newRotation;          
         }
-        if (doIdentity)
-        {
-            _9Axis.SetIdentity();
-            if (controlObj)
-            {
-                controlObj.localRotation = _9Axis.States.Last().Qua;
-            }
-            doIdentity = false;
-            hasAutoIdentity = true;
-        }
     }
 
     int receiveDataCount = 0;
-    bool doIdentity = false;
     bool hasAutoIdentity = false;
     Quaternion newRotation;
 
-    public void InitAutoIdentity() 
+    void InitAutoIdentity() 
     {
         receiveDataCount = 0;
-        doIdentity = false;
         hasAutoIdentity = false;
     }
 
-    public void SetControlObject(Transform obj)
+    void checkAutoIdentity() 
+    {
+        receiveDataCount++;
+        if (!hasAutoIdentity && receiveDataCount == 5) {
+            hasAutoIdentity = true;
+            DoIdentity();
+        }
+    }
+
+    void DoIdentity()
     {
-        controlObj = obj;
-        if (controlObj) InitAutoIdentity();
+        if (!hasAutoIdentity) return;
+        _9Axis.SetIdentity();
+        if (controlObj) controlObj.localRotation = _9Axis.States.Last().Qua;
     }
 }

+ 5 - 166
Assets/BowArrow/Scripts/Game/ArmBow.cs

@@ -97,6 +97,7 @@ public class ArmBow : MonoBehaviour
     }
 
     public void ADS_fire() {
+        if (!canShoot) return;
         this.pulling = false;
         this.canShoot = false;
         this.readying = false;
@@ -155,7 +156,9 @@ public class ArmBow : MonoBehaviour
         // Arrow.speed = BaseSpeedSlider.ins.getValue();
         // Arrow.speed = Mathf.Pow(ShootCheck.ins.shootSpeed, ShootCheck.ins.shootSpeed < 13 ? 2f: (ShootCheck.ins.shootSpeed < 15 ? 2.5f : 3.0f));
 
-        Arrow.speed = ShootCheck.ins.shootSpeed/16*80; 
+        if (ShootCheck.ins) {
+            Arrow.speed = ShootCheck.ins.shootSpeed / 16 * 80; 
+        }   
 
         arrowCopy.SetActive(true);  
         arrow.SetActive(false);
@@ -186,168 +189,4 @@ public class ArmBow : MonoBehaviour
             this.ADS_fire();
         }
     }
-}
-
-// public class ArmBow : MonoBehaviour
-// {
-//     [SerializeField] AnimationPlayer AP_arm;
-//     [SerializeField] Animator AP_bow;
-//     [SerializeField] AnimationPlayer AP_bowForArrow;
-//     [SerializeField] GameObject arrow;
-//     [SerializeField] BowCamera bowCamera;
-//     public HashSet<TargetBody> validTargets = new HashSet<TargetBody>();
-//     private bool canShoot = false;
-//     private bool pulling = false;
-//     private bool readying = false;
-
-//     public static ArmBow ins;
-
-//     void Start()
-//     {
-//         ins = this;
-//         this.readyShoot();
-//     }
-
-//     void OnDestroy() 
-//     {
-//         ins = null;
-//     }
-
-//     void FixedUpdate()
-//     {
-//         // if (this.canShoot)
-//         // {
-//         //     DebugBowPower.ins.DoUpdate();
-//         // }
-//     }
-
-//     void Update()
-//     {
-//         if (Input.GetKeyDown(KeyCode.Q)) 
-//         {
-//             this.ADS_fire();
-//         }
-//         if (this.pulling) {
-//             this.bowCamera.updateFollowPullBow();
-//         } else if (!this.canShoot)
-//         {
-//             this.bowCamera.updateGiveUpPullBow();
-//         }
-//         CrossHair.ins.gameObject.SetActive(this.canShoot);
-//     }
-
-//     void onComplete(AnimationPlayerCompleteResult res) {
-//         if (res.index == 1) {
-//             this.ADS_idle();
-//         } else if (res.index == 3) {
-//             this.idle();
-//         }
-//     }
-
-//     void idle() {
-//         this.arrow.SetActive(false);
-//         AP_arm.play(0, WrapMode.Loop);
-//         AP_bowForArrow.play(0, WrapMode.Loop);
-//         // AP_bow.SetBool("ads", false);
-//         // AP_bow.SetBool("fire", false);
-//         AP_bow.Play("gong_daiji");
-//         AP_arm.completeCallback = null;
-//         this.pulling = false;
-//         this.canShoot = false;
-//         // DebugBowPower.ins.Init();
-//     }
-
-//     public void idleToADS() {
-//         this.arrow.SetActive(true);
-//         AP_arm.play(1, WrapMode.Once);
-//         AP_bowForArrow.play(1, WrapMode.Once);
-//         // AP_bow.SetBool("ads", true);
-//         // AP_bow.SetBool("idle", false);
-//         AP_bow.Play("gong_lagong");
-//         AP_arm.completeCallback = onComplete;
-//         this.pulling = true;
-//         this.canShoot = false;
-//     }
-
-//     void ADS_idle() {
-//         AP_arm.play(2, WrapMode.Loop);
-//         AP_bowForArrow.play(2, WrapMode.Loop);
-//         AP_bow.Play("gong_lagongdaiji");
-//         AP_arm.completeCallback = null;
-//         this.canShoot = true;
-//         this.pulling = false;
-//         // DebugBowPower.ins.PullFinish();
-//     }
-
-//     public void ADS_fire() {
-//         if (!this.canShoot)
-//         {
-//             return;
-//         } 
-//         this.pulling = false;
-//         this.canShoot = false;
-//         this.readying = false;
-//         AP_arm.play(3, WrapMode.Once);
-//         AP_bowForArrow.play(3, WrapMode.Once);
-//         // AP_bow.SetBool("fire", true);
-//         AP_bow.Play("gong_songshou");
-//         AP_arm.completeCallback = onComplete;
-//         this.Invoke("shoot", 0.1f);
-//     }
-
-//     public void readyShoot() {
-//         this.readying = true;
-//         this.bowCamera.setFieldOfView(60, false);
-//         this.idle();
-//         this.gameObject.SetActive(true);
-//         this.Invoke("idleToADS", 0.5f);
-//     }
-
-//     public void shoot() {
-//         Vector3 rayHitPoint = CrossHair.ins.getRayHitPoint();
-
-//         GameObject arrowCopy = GameObject.Instantiate(this.arrow, this.bowCamera.transform.position, this.bowCamera.transform.rotation);
-
-//         Vector3 s1 = arrowCopy.transform.localScale;
-//         Vector3 s2 = bowCamera.transform.localScale;
-//         arrowCopy.transform.localScale = new Vector3(s1.x * s2.x, s1.y * s2.y, s1.z * s2.z);
-
-//         arrowCopy.transform.LookAt(rayHitPoint);
-
-//         Arrow arrowComp = arrowCopy.AddComponent<Arrow>();
-//         arrowComp.armBow = this;
-//         // arrowComp.calculateSpeed(rayHitPoint);
-//         // Arrow.speed = BaseSpeedSlider.ins.getValue() * DebugBowPower.ins.getPowerPercent();
-//         // Arrow.speed = BaseSpeedSlider.ins.getValue();
-//         Arrow.speed = Mathf.Pow(ShootCheck.ins.shootSpeed, ShootCheck.ins.shootSpeed < 13 ? 2f: (ShootCheck.ins.shootSpeed < 15 ? 2.5f : 3.0f));
-
-//         arrowCopy.SetActive(true);  
-//         arrow.SetActive(false);
-
-//         AudioMgr.ins.PlayShoot(AudioMgr.GetAudioSource(arrowCopy));
-//         this.gameObject.SetActive(false);
-//     }
-
-//     public void OnEnable() 
-//     {
-//         AudioMgr.GetAudioSource(this.gameObject).clip = null;
-//     }
-
-//     //debug
-//     public void mouseDown() 
-//     {
-//         if (!this.readying) return;
-//         if (this.pulling || this.canShoot) return;
-//         this.idleToADS();
-//     }
-
-//     public void mouseUp() 
-//     {
-//         if (!this.readying) return;
-//         if (this.pulling) {
-//             this.idle();
-//         } else if (this.canShoot) {
-//             this.ADS_fire();
-//         }
-//     }
-// }
+}

+ 3 - 3
Assets/BowArrow/Scripts/Game/Arrow.cs

@@ -44,7 +44,7 @@ public class Arrow : MonoBehaviour
             this.rotation = this.transform.rotation;
             if (flyTime > 6.0) {
                 Destroy(gameObject);
-                GameMgr.ins.hitTarget(0);
+                GameMgr.ins.gameMode.HitTarget(0);
                 AudioMgr.ins.PlayCheer(false);
                 nextShoot();
             }
@@ -162,7 +162,7 @@ public class Arrow : MonoBehaviour
 
     /**延时方法 */
     public void nextShoot() {
-        if (GameMgr.ins.checkFinish()) return;
+        if (GameMgr.ins.gameOver) return;
         this.armBow.readyShoot();
         this.Invoke("destroySelf", 0.05f);
         // CrossHair.ins.gameObject.SetActive(true);
@@ -177,7 +177,7 @@ public class Arrow : MonoBehaviour
         if ((1 << collision.gameObject.layer) != LayerMask.GetMask("Target")) 
         {
             this.Hit();
-            GameMgr.ins.hitTarget(0);
+            GameMgr.ins.gameMode.HitTarget(0);
             AudioMgr.ins.PlayCheer(false);
         }
         this.transform.SetParent(collision.transform.parent);

+ 19 - 0
Assets/BowArrow/Scripts/Game/CameraToLook.cs

@@ -0,0 +1,19 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class CameraToLook : MonoBehaviour
+{
+    public bool isNew = true;
+    public static CameraToLook ins = null;
+
+    void Start()
+    {
+        ins = this;
+    }
+
+    void OnDestroy() 
+    {
+        ins = null;
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/Game/CameraToLook.cs.meta

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

+ 4 - 4
Assets/BowArrow/Scripts/Game/TargetBody.cs

@@ -13,15 +13,15 @@ public class TargetBody : MonoBehaviour
             if (arrow.armBow.validTargets.Contains(this)) {
                 float maxSize = Vector3.Distance(this.transform.Find("CenterPoint").position, this.transform.Find("SidePoint").position);
                 float radius = this.measureRadius(collision.contacts[0].point);
-                int score = 10 - Mathf.FloorToInt(radius / maxSize * 5);
-                if (score > 5) {
-                    GameMgr.ins.hitTarget(score);
+                int score = 10 - Mathf.FloorToInt(radius / maxSize * 10);
+                if (score > 0) {
+                    GameMgr.ins.gameMode.HitTarget(score);
                     AudioMgr.ins.PlayCheer(true);
                     hitTarget = true;
                 }
             }
             if (!hitTarget) {
-                GameMgr.ins.hitTarget(0);
+                GameMgr.ins.gameMode.HitTarget(0);
                 AudioMgr.ins.PlayCheer(false);
             }
         }

+ 1 - 3
Assets/BowArrow/Scripts/Manager/AudioMgr.cs

@@ -13,17 +13,15 @@ public class AudioMgr : MonoBehaviour
     {
         if (GameObject.Find("AudioMgr") == null) {
             GameObject audioMgr = new GameObject("AudioMgr");
-            audioMgr.AddComponent<AudioSource>();
             audioMgr.AddComponent<AudioMgr>();
             DontDestroyOnLoad(audioMgr);
         }
-        
     }
 
     void Start() {
         ins = this;
 
-        this.audioSource = this.GetComponent<AudioSource>();
+        this.audioSource = this.gameObject.AddComponent<AudioSource>();
     }
 
     private void Play(string path, AudioSource audioSource) {

+ 53 - 180
Assets/BowArrow/Scripts/Manager/GameMgr.cs

@@ -2,9 +2,8 @@
 
 public class GameMgr : MonoBehaviour
 {
-    public static int gameMode = 1;
-    public GameMode1 gameMode1;
-    public GameMode2 gameMode2;
+    public static int gameType = 0;
+    public GameMode gameMode;
     public bool gameOver = false;
     
     public static GameMgr ins;
@@ -12,75 +11,18 @@ public class GameMgr : MonoBehaviour
     void Start() 
     {
         ins = this;
-
         AudioMgr.init();
-
-        this.initGameMode();
+        this.InitGameMode();
     }
 
     void FixedUpdate()
     {
-        if (this.gameMode2 != null)
-        {
-            this.gameMode2.UpdateTime(this);
-        }
-    }
-
-    void initGameMode() {
-        if (gameMode == 1) 
-        {
-            this.gameMode1 = new GameMode1();
-            this.gameMode1.init(this);
-        }
-        else if (gameMode == 2)
-        {
-            this.gameMode2 = new GameMode2();
-            this.gameMode2.init(this);
-        }
-    }
-
-    public void hitTarget(int score) {
-        if (gameMode == 1)
-        {
-            this.gameMode1.hitTarget(this, score);
-        }
-        else if (gameMode == 2)
-        {
-            this.gameMode2.hitTarget(this, score);
-        }
-    }
-
-    public bool checkFinish() {
-        if (gameMode == 1) 
-        {
-            return this.gameMode1.checkFinish(this);
-        }
-        else if (gameMode == 2)
-        {
-            return this.gameMode2.checkFinish(this);
-        }
-        return false;
-    }
-
-    public GameWinResult GetGameWinResult() 
-    {
-        if (gameMode == 1)
-        {
-            return gameMode1.getWinResult();
-        }
-        else if (gameMode == 2)
-        {
-            return gameMode2.getWinResult();
-        }
-        return null;
-    }
-
-    public void Pause() {
-        Time.timeScale = 0;
+        gameMode.Update();
     }
 
-    public void Resume() {
-        Time.timeScale = 1;
+    void InitGameMode() {
+        if (gameType == 0) gameMode = new GameModeTest(this);
+        if (gameType == 1) gameMode = new GameMode1(this);
     }
 
     public void StopGame() {
@@ -97,137 +39,74 @@ public class GameMgr : MonoBehaviour
     }
 }
 
-/**闯关模式 */
-public class GameMode1 {
-    public static int level;
-    public int arrowCount = 3;
-    public int arrowCountMax = 3;
-    public int score = 0;
-    public int oneStarScore = 8;
-    public bool finish;
-
-    public void init(GameMgr gameMgr) {
-        GameObject gv1 = Resources.Load<GameObject>("Prefabs/Views/ChallengeGameView");
-        GameObject.Instantiate(gv1, Vector3.zero, new Quaternion());
-
-        //debug
-        TargetBody tb = GameObject.Find("GameArea/010/TargetBody").GetComponent<TargetBody>();
-        // TargetBody tb1 = GameObject.Find("GameArea/010 (1)/TargetBody").GetComponent<TargetBody>();
-        // TargetBody tb2 = GameObject.Find("GameArea/010 (2)/TargetBody").GetComponent<TargetBody>();
-        GameObject.Find("Main Camera/ArmBow").GetComponent<ArmBow>().validTargets.Add(tb);
-        // GameObject.Find("Main Camera/ArmBow").GetComponent<ArmBow>().validTargets.Add(tb1);
-        // GameObject.Find("Main Camera/ArmBow").GetComponent<ArmBow>().validTargets.Add(tb2);
-    }
-
-    public void hitTarget(GameMgr gameMgr, int score) {
-        // this.score += score;
-        // this.arrowCount -= 1;
-    }
-
-    public bool checkFinish(GameMgr gameMgr) {
-        if (this.finish) return true;
-        if (this.arrowCount <= 0) {
-            this.finish = true;
-            gameMgr.gameOver = true;
-            gameMgr.StopGame();
-            GameObject gwv1 = Resources.Load<GameObject>("Prefabs/Views/GameResultView");
-            GameObject.Instantiate(gwv1, Vector3.zero, new Quaternion());
-            return true;
-        }
-        return false;
+public abstract class GameMode 
+{
+    public GameMgr gameMgr;
+    public GameMode(GameMgr gameMgr) {
+        this.gameMgr = gameMgr;
     }
+    public abstract void HitTarget(int score);
+    public abstract object[] Settle();
+    public virtual void Update() {}
+}
 
-    public GameWinResult getWinResult() {
-        GameWinResult result = new GameWinResult();
-        result.starCount = this.score / this.oneStarScore;
-        result.score = this.score;
-        string key = "Challenge_Star_";
-        int star = PlayerPrefs.GetInt(key + level, 0);
-        if (result.starCount > star)
-        {
-            PlayerPrefs.SetInt(key + level, result.starCount);
-        }
-        return result;
-    }
+public class GameModeTest : GameMode {
+    public GameModeTest(GameMgr gameMgr) : base(gameMgr) {}
+    public override void HitTarget(int score) {}
+    public override object[] Settle() { return null; }
 }
 
-/**限时模式 */
-public class GameMode2 {
-    public int hitCount = 0;
+/**单人限时模式 */
+public class GameMode1 : GameMode {
     public int score = 0;
-    public int oneStarScore = 10;
-    public float time = 60;
-    public bool finish;
-
-    public void init(GameMgr gameMgr) {
-        GameObject gv1 = Resources.Load<GameObject>("Prefabs/Views/TimeLimitGameView");
-        GameObject.Instantiate(gv1, Vector3.zero, new Quaternion());
+    int oneStarScore = 10;
+    float time = 60;
 
-        TargetBody tb = GameObject.Find("GameArea/010/TargetBody").GetComponent<TargetBody>();
-        GameObject.Find("Main Camera/ArmBow").GetComponent<ArmBow>().validTargets.Add(tb);
+    public GameMode1(GameMgr gameMgr) : base(gameMgr)
+    {
+        //添加游戏界面
+        GameObject view = Resources.Load<GameObject>("Prefabs/Views/TimeLimitGameView");
+        GameObject.Instantiate(view);
+        //记录可射击的靶子
+        TargetBody targetBody = GameObject.Find("GameArea/010/TargetBody").GetComponent<TargetBody>();
+        GameObject.Find("Main Camera/ArmBow").GetComponent<ArmBow>().validTargets.Add(targetBody);
     }
 
-    public void hitTarget(GameMgr gameMgr, int score) {
+    public override void HitTarget(int score) {
         this.score += score;
-        this.hitCount++;
-    }
-
-    public bool checkFinish(GameMgr gameMgr) {
-        return this.finish;
     }
 
-    public GameWinResult getWinResult() {
-        GameWinResult result = new GameWinResult();
-        result.starCount = this.score / this.oneStarScore;
-        result.score = this.score;
-        string keyLowest = "TimeLimitGameLowestScore";
-        string keyHighest = "TimeLimitGameHighestScore";
-        string keyLowestHitCount = "TimeLimitGameLowestHitCount";
-        string keyHighestHitCount = "TimeLimitGameHighestHitCount";
-        int lowestScore = PlayerPrefs.GetInt(keyLowest, -1);
-        int highestScore = PlayerPrefs.GetInt(keyHighest, -1);
-        if (lowestScore == -1 || result.score < lowestScore) {
-            PlayerPrefs.SetInt(keyLowest, result.score);
-            PlayerPrefs.SetInt(keyLowestHitCount, hitCount);
-        }
-        if (highestScore == -1 || result.score > highestScore) {
-            PlayerPrefs.SetInt(keyHighest, result.score);
-            PlayerPrefs.SetInt(keyHighestHitCount, hitCount);
+    public override object[] Settle() {
+        int starCount = this.score / this.oneStarScore;
+        string highestScoreKey = "TimeLimitGameHighestScore";
+        int highestScore = PlayerPrefs.GetInt(highestScoreKey, 0);
+        if (this.score > highestScore) {
+            PlayerPrefs.SetInt(highestScoreKey, this.score);
         }
-        return result;
+        return new object[]{starCount, this.score};
     }
 
-    public int[] GetScores() 
-    {
-        int[] scores = new int[4];
-        string keyLowest = "TimeLimitGameLowestScore";
-        string keyHighest = "TimeLimitGameHighestScore";
-        string keyLowestHitCount = "TimeLimitGameLowestHitCount";
-        string keyHighestHitCount = "TimeLimitGameHighestHitCount";
-        scores[0] = PlayerPrefs.GetInt(keyHighestHitCount, 0);
-        scores[1] = PlayerPrefs.GetInt(keyHighest, 0);
-        scores[2] = PlayerPrefs.GetInt(keyLowestHitCount, 0);
-        scores[3] = PlayerPrefs.GetInt(keyLowest, 0);
-        return scores;
-    }
-
-    public void UpdateTime(GameMgr gameMgr) {
-        if (this.finish) return;
+    public override void Update() {
+        if (gameMgr.gameOver) return;
         if (this.time > 0) {
             this.time -= Time.deltaTime;
-        }
-        else
-        {
+        } else {
             this.time = 0;
-            this.finish = true;
             gameMgr.gameOver = true;
             gameMgr.StopGame();
-            GameObject gwv1 = Resources.Load<GameObject>("Prefabs/Views/GameResultView");
-            GameObject.Instantiate(gwv1, Vector3.zero, new Quaternion());
+            //添加结算界面
+            GameObject view = Resources.Load<GameObject>("Prefabs/Views/GameSettleView1");
+            GameObject.Instantiate(view);
         }
     }
 
-    public string getTimeStr()
+    public int GetHighestScore() 
+    {
+        string highestScoreKey = "TimeLimitGameHighestScore";
+        return PlayerPrefs.GetInt(highestScoreKey, 0);
+    }
+
+    public string GetTimeStr()
     {
         int seconds = Mathf.FloorToInt(this.time);
         string str = "";
@@ -245,10 +124,4 @@ public class GameMode2 {
         str += s;
         return str;
     }
-}
-
-
-public class GameWinResult {
-    public int starCount;
-    public int score;
 }

+ 1 - 2
Assets/BowArrow/Scripts/View/ChallengeReadyView.cs

@@ -48,8 +48,7 @@ public class ChallengeReadyView : MonoBehaviour
 
     public void GoTo(int level) {
         AudioMgr.ins.PlayBtn();
-        GameMgr.gameMode = 1;
-        GameMode1.level = level;
+        GameMgr.gameType = 1;
         SceneManager.LoadScene("Game", LoadSceneMode.Single);
     }
 

+ 8 - 6
Assets/BowArrow/Scripts/View/GameResultView.cs

@@ -5,7 +5,7 @@ using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 using DG.Tweening;
 
-public class GameResultView : MonoBehaviour
+public class GameSettleView1 : MonoBehaviour
 {
     [SerializeField] Sprite starLight;
 
@@ -19,14 +19,16 @@ public class GameResultView : MonoBehaviour
         {
             TimeLimitGameView.ins.gameObject.SetActive(false);
         }
-        GameWinResult result = GameMgr.ins.GetGameWinResult();
-        
-        if (result.starCount == 3)
+        object[] results = GameMgr.ins.gameMode.Settle();
+        int starCount = (int) results[0];
+        int score = (int) results[1];
+
+        if (starCount == 3)
             this.transform.Find("Result1").gameObject.SetActive(true);
         else 
             this.transform.Find("Result2").gameObject.SetActive(true);
 
-        for (int i = 1; i <= result.starCount; i++) {
+        for (int i = 1; i <= starCount; i++) {
             Transform tsf = this.transform.Find("Star" + i);
             tsf.DOMoveZ(0, (float) i * 0.3f).OnComplete(() => {
                 tsf.GetComponent<Image>().sprite = starLight;
@@ -35,7 +37,7 @@ public class GameResultView : MonoBehaviour
         }
         DOTween.To(() => 0, value => {
             this.transform.Find("ScoreBG/Text").GetComponent<Text>().text = "得分: " + value;
-        }, result.score, 1);
+        }, score, 1);
 
         AudioMgr.ins.PlayWin();
     }

+ 1 - 1
Assets/BowArrow/Scripts/View/GameResultView.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: e8e6e87dc1d613e4db9d69c3a2dd123c
+guid: 3ce9a1ee2477e584b9bb9d138e4de818
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 52 - 0
Assets/BowArrow/Scripts/View/GameSettleView1.cs

@@ -0,0 +1,52 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using UnityEngine.SceneManagement;
+using DG.Tweening;
+
+public class GameResultView : MonoBehaviour
+{
+    [SerializeField] Sprite starLight;
+
+    void Start()
+    {
+        if (ChallengeGameView.ins)
+        {
+            ChallengeGameView.ins.gameObject.SetActive(false);
+        }
+        if (TimeLimitGameView.ins)
+        {
+            TimeLimitGameView.ins.gameObject.SetActive(false);
+        }
+        // GameWinResult result = GameMgr.ins.gaemmo.GetGameWinResult();
+        
+        // if (result.starCount == 3)
+        //     this.transform.Find("Result1").gameObject.SetActive(true);
+        // else 
+        //     this.transform.Find("Result2").gameObject.SetActive(true);
+
+        // for (int i = 1; i <= result.starCount; i++) {
+        //     Transform tsf = this.transform.Find("Star" + i);
+        //     tsf.DOMoveZ(0, (float) i * 0.3f).OnComplete(() => {
+        //         tsf.GetComponent<Image>().sprite = starLight;
+        //         tsf.DOPunchScale(new Vector3(0.3f, 0.3f, 0.3f), 0.3f);
+        //     });
+        // }
+        // DOTween.To(() => 0, value => {
+        //     this.transform.Find("ScoreBG/Text").GetComponent<Text>().text = "得分: " + value;
+        // }, result.score, 1);
+
+        // AudioMgr.ins.PlayWin();
+    }
+
+    public void GoHome() {
+        AudioMgr.ins.PlayBtn();
+        SceneManager.LoadScene("Home", LoadSceneMode.Single);
+    }
+
+    public void TryAgain() {
+        AudioMgr.ins.PlayBtn();
+        SceneManager.LoadScene("Game", LoadSceneMode.Single);
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/View/GameSettleView1.cs.meta

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

+ 1 - 1
Assets/BowArrow/Scripts/View/HomeView.cs

@@ -40,7 +40,7 @@ public class HomeView : MonoBehaviour
                 GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/ChallengeReadyView"), Vector3.zero, new Quaternion());
                 break;
             case "限时":
-                GameMgr.gameMode = 2;
+                GameMgr.gameType = 2;
                 SceneManager.LoadScene("Game", LoadSceneMode.Single);
                 break;
             case "对战":

+ 7 - 12
Assets/BowArrow/Scripts/View/TimeLimitGameView.cs

@@ -6,35 +6,30 @@ using UnityEngine.SceneManagement;
 
 public class TimeLimitGameView : MonoBehaviour
 {
-    public Text[] scoreUIs;
+    public Text highestScoreTxt;
+    public Text currentScoreTxt;
     public Text timeTxt;
+    GameMode1 gameMode;
 
     public static TimeLimitGameView ins;
 
     void Start()
     {
         ins = this; 
-        int[] scores = GameMgr.ins.gameMode2.GetScores();
-        for (int i = 0; i < scoreUIs.Length; i++)
-        {
-            scoreUIs[i].text = scores[i].ToString();
-        }
-    }
 
-    void OnDestroy()
-    {
-        ins = null;    
+        gameMode = (GameMode1) GameMgr.ins.gameMode;
+        highestScoreTxt.text = gameMode.GetHighestScore().ToString();
     }
 
     void FixedUpdate()
     {
-        timeTxt.text = GameMgr.ins.gameMode2.getTimeStr();
+        timeTxt.text = gameMode.GetTimeStr();
+        currentScoreTxt.text = gameMode.score.ToString();
     }
 
     public void Back() 
     {
         AudioMgr.ins.PlayBtn();
         SceneManager.LoadScene("Home", LoadSceneMode.Single);
-        // Application.Quit();
     }
 }

+ 1 - 1
Assets/Resources/Prefabs/Views/GameResultView.prefab → Assets/Resources/Prefabs/Views/GameSettleView1.prefab

@@ -371,7 +371,7 @@ GameObject:
   - component: {fileID: 7513718634091623890}
   - component: {fileID: 8733985199888835723}
   m_Layer: 5
-  m_Name: GameResultView
+  m_Name: GameSettleView1
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0

+ 0 - 0
Assets/Resources/Prefabs/Views/GameResultView.prefab.meta → Assets/Resources/Prefabs/Views/GameSettleView1.prefab.meta


+ 4 - 5
Assets/Resources/Prefabs/Views/TimeLimitGameView.prefab

@@ -162,6 +162,7 @@ MonoBehaviour:
   m_FallbackScreenDPI: 96
   m_DefaultSpriteDPI: 96
   m_DynamicPixelsPerUnit: 1
+  m_PresetInfoIsWorld: 0
 --- !u!114 &8253119065230897572
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -203,11 +204,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 3683f28c60f27194ca348c2a1d2e8253, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
-  scoreUIs:
-  - {fileID: 8253119066285781420}
-  - {fileID: 8253119066088320492}
-  - {fileID: 8253119066065479281}
-  - {fileID: 8253119066555619634}
+  highestScoreTxt: {fileID: 8253119066285781420}
+  currentScoreTxt: {fileID: 8253119066065479281}
   timeTxt: {fileID: 8253119065852609745}
 --- !u!1 &8253119065575480668
 GameObject:
@@ -911,6 +909,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   m_Navigation:
     m_Mode: 3
+    m_WrapAround: 0
     m_SelectOnUp: {fileID: 0}
     m_SelectOnDown: {fileID: 0}
     m_SelectOnLeft: {fileID: 0}

+ 2 - 2
ProjectSettings/EditorBuildSettings.asset

@@ -8,10 +8,10 @@ EditorBuildSettings:
   - enabled: 1
     path: Assets/BowArrow/Scenes/Game.unity
     guid: 3a346723748889946bfbc85eb35f7879
-  - enabled: 0
+  - enabled: 1
     path: Assets/BowArrow/Scenes/Login.unity
     guid: 200a793b1fc5aac438c87e1b342a939a
-  - enabled: 0
+  - enabled: 1
     path: Assets/BowArrow/Scenes/Home.unity
     guid: 8aa5affa1b256294a8c908dbab6122d0
   m_configObjects: {}