lvjincheng 4 years ago
parent
commit
3d6a6c7369

+ 35 - 0
Assets/ArtAsset/Hunter/Demo/DayToNight.cs

@@ -0,0 +1,35 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class DayToNight : MonoBehaviour
+{
+    [SerializeField] Material daySkyboxMaterial;
+    [SerializeField] Material nightSkyboxMaterial;
+    void Start()
+    {
+        EnterDay();
+    }
+
+    public void EnterDay()
+    {
+        RenderSettings.fogStartDistance = 25;
+        RenderSettings.fogColor = new Color(124f/255, 177f/255, 221f/255);
+        RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
+        RenderSettings.ambientSkyColor = Color.white;
+        RenderSettings.skybox = daySkyboxMaterial;
+        foreach (Transform item in transform) item.gameObject.SetActive(false);
+        transform.Find("DayElements").gameObject.SetActive(true);
+    }
+
+    public void EnterNight()
+    {
+        RenderSettings.fogStartDistance = 5;
+        RenderSettings.fogColor = new Color(37f/255, 52f/255, 63f/255);
+        RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
+        RenderSettings.ambientSkyColor = new Color(160f/255, 90f/255, 90f/255);
+        RenderSettings.skybox = nightSkyboxMaterial;
+        foreach (Transform item in transform) item.gameObject.SetActive(false);
+        transform.Find("NightElements").gameObject.SetActive(true);
+    }
+}

+ 11 - 0
Assets/ArtAsset/Hunter/Demo/DayToNight.cs.meta

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

File diff suppressed because it is too large
+ 467 - 450
Assets/ArtAsset/Hunter/Demo/Demo_Day.unity


BIN
Assets/ArtAsset/Hunter/Demo/Demo_Day/NavMesh.asset


+ 8 - 0
Assets/ArtAsset/Hunter/Demo/Demo_Night.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 84609a1640f05774485e80827771730c
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

File diff suppressed because it is too large
+ 699 - 518
Assets/ArtAsset/Hunter/Demo/Demo_Night.unity


BIN
Assets/ArtAsset/Hunter/Demo/Demo_Night/NavMesh.asset


+ 8 - 0
Assets/ArtAsset/Hunter/Demo/Demo_Night/NavMesh.asset.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: aa3b69cfda2abda45bee23b2fe4af4f6
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 23800000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
Assets/ArtAsset/Hunter/Models/Rabbit/Rabbit.cs

@@ -77,14 +77,14 @@ public class Rabbit : TargetAnimal
         this.agent.enabled = false;
         PuaseAutoStrategy();
         onDie?.Invoke(this);
-        AudioMgr.ins.PlayAnimalEffect("RabbitDie", AudioMgr.GetAudioSource(this.gameObject));
+        AudioMgr.ins.PlayAnimalEffect("rabbit_die", AudioMgr.GetAudioSource(this.gameObject));
     }
 
     void Hurt() {
         RunAwayFromHunter();
         PuaseAutoStrategy();
         addHurtFlag();
-        AudioMgr.ins.PlayAnimalEffect("RabbitHurt", AudioMgr.GetAudioSource(this.gameObject));
+        AudioMgr.ins.PlayAnimalEffect("rabbit_injured", AudioMgr.GetAudioSource(this.gameObject));
     }
     Queue<int> hurtFlagList = new Queue<int>();
     void addHurtFlag() {

+ 2 - 1
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -52,6 +52,7 @@ public class BluetoothAim : MonoBehaviour
         hasData = false;
         canConnect = true;
         SetStatus(BluetoothStatusEnum.ConnectFail);
+        BowCamera.isTouchMode = false;
     }
 
     void Update()
@@ -101,6 +102,7 @@ public class BluetoothAim : MonoBehaviour
             {
                 Log("连接成功\n" + helper.getDeviceName());
                 SetStatus(BluetoothStatusEnum.ConnectSuccess);
+                BowCamera.isTouchMode = false;
                 foreach (BluetoothHelperService service in helper.getGattServices())
                 {
                 
@@ -129,7 +131,6 @@ public class BluetoothAim : MonoBehaviour
                 CallDelay(3, delegate() {
                     WriteData(SceneManager.GetActiveScene().name == "Game" ? "b" :"B");
                 });
-                BowCamera.isTouchMode = false;
             };
             bluetoothHelper.OnConnectionFailed += (BluetoothHelper helper) =>
             {

+ 2 - 2
Assets/BowArrow/Scripts/Game/ArmBow.cs

@@ -133,7 +133,7 @@ public class ArmBow : MonoBehaviour
     }
 
     public void readyShoot() {
-        this.bowCamera.SetCameraFieldOfView(60);
+        this.bowCamera.SetCameraFieldOfViewRecord(60);
         this.ready();
     }
 
@@ -191,7 +191,7 @@ public class ArmBow : MonoBehaviour
             GameDebug.ins.GetOffsetAngle() : 
             FormatAngle(Quaternion.Angle(absolute_rotation, final_rotation));
 
-        if (ShootCheck.ins && !GameMgr.debugInEditor) 
+        if (ShootCheck.ins && !GameMgr.debugInEditor && !BowCamera.isTouchMode) 
         {
             Arrow.speed = GameMgr.RealSizeToGameSize(ShootCheck.ins.shootSpeed);
         }

+ 48 - 31
Assets/BowArrow/Scripts/Game/BowCamera.cs

@@ -48,47 +48,61 @@ public class BowCamera : MonoBehaviour
             this.localEulerAngles.x = Mathf.Clamp(this.localEulerAngles.x - 2f * Input.GetAxis("Mouse Y"), -36, 36);
             this.localEulerAngles.y = Mathf.Clamp(this.localEulerAngles.y + 2f * Input.GetAxis("Mouse X"), -180, 180);   
             this.transform.localEulerAngles = this.localEulerAngles; 
-            if (EventSystem.current.IsPointerOverGameObject())
-            {
-                return;
-            }
+            if (EventSystem.current.IsPointerOverGameObject()) return;
             if (Input.GetMouseButtonDown(0)) {
-                armBow.mouseDown();
-            }
-            else if (Input.GetMouseButtonUp(0)) {
-                armBow.mouseUp();
+                armBow.ADS_fire();
             }
-        } else {
-            if (isTouchMode) {
-                //触摸控制镜头和拉弓射箭
-                if (Input.touches.Length == 1 && Input.touches[0].phase == TouchPhase.Moved)
-                {
-                    if (!EventSystem.current.IsPointerOverGameObject(Input.touches[0].fingerId))
-                    {
-                        this.localEulerAngles.x = Mathf.Clamp(this.localEulerAngles.x - Input.touches[0].deltaPosition.y * Time.deltaTime * 5, -36, 36);
-                        this.localEulerAngles.y = Mathf.Clamp(this.localEulerAngles.y + Input.touches[0].deltaPosition.x * Time.deltaTime * 5, -180, 180);   
-                        this.transform.localEulerAngles = this.localEulerAngles; 
+        }
+        else if (isTouchMode) {
+            if (Input.touchCount > 0) {
+                if (!hasTouch) {
+                    Touch touch = Input.GetTouch(0);
+                    if (touch.phase == TouchPhase.Began) {
+                        hasTouch = true;
+                        touchID = touch.fingerId;
                     }
                 }
-                if (Input.touches.Length > 0)
-                {
-                    foreach (Touch touch in Input.touches)
+                if (hasTouch) {
+                    Touch touch = default;
+                    foreach (var t in Input.touches)
                     {
-                        if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) return;
+                        if (t.fingerId == touchID) touch = t;
+                    }
+                    bool isOverUI = EventSystem.current.IsPointerOverGameObject(touchID);
+                    if (touch.phase == TouchPhase.Began) {
+                        touchOnUI = isOverUI;
+                    }
+                    else if (touch.phase == TouchPhase.Moved) {
+                        touchOnUI = isOverUI;
+                        if (!isOverUI) {
+                            //触摸控制镜头和拉弓射箭
+                            this.localEulerAngles.x = Mathf.Clamp(this.localEulerAngles.x - Input.touches[0].deltaPosition.y * Time.deltaTime * 5, -36, 36);
+                            this.localEulerAngles.y = Mathf.Clamp(this.localEulerAngles.y + Input.touches[0].deltaPosition.x * Time.deltaTime * 5, -180, 180);   
+                            this.transform.localEulerAngles = this.localEulerAngles; 
+                        }
+                    }
+                    else if (touch.phase == TouchPhase.Ended) {
+                        hasTouch = false;
+                        //UnityBug,Ended阶段isOverUI总是返回false,因此通过新增变量touchOnUI来辅助识别触点是否在UI上
+                        if (touchOnUI) touchOnUI = false;
+                        else armBow.ADS_fire();
                     }
-                    armBow.mouseDown();
-                } 
-                if (Input.touches.Length == 0)
-                {
-                    armBow.mouseUp();
                 }
             } else {
-                //镜头看向九轴姿态虚拟节点
-                this.transform.LookAt(CameraToLook.ins.point);
+                hasTouch = false;
             }
+        } else {
+            hasTouch = false;
+            //镜头看向九轴姿态虚拟节点
+            this.transform.LookAt(CameraToLook.ins.point);
         }
     }
 
+    //触摸模式下的有效触点信息记录
+    int touchID;
+    bool hasTouch;
+    bool touchOnUI;
+
     //---------------相机视野的相关操作---------------------
 
     //视野值记录
@@ -96,9 +110,12 @@ public class BowCamera : MonoBehaviour
     //禁止相机视野改变
     [NonSerialized] public bool banCameraFieldOfView = false;
     
-    //立马改变相机视野值
     public void SetCameraFieldOfView(float value) {
-        cameraComp.fieldOfView = cameraFieldOfView = value;
+        cameraComp.fieldOfView = value;
+    }
+
+    public void SetCameraFieldOfViewRecord(float value) {
+        cameraFieldOfView = value;
     }
 
     //拉弓时的相机视野值变化

+ 1 - 1
Assets/BowArrow/Scripts/Manager/GameMgr.cs

@@ -8,7 +8,7 @@ using UnityEngine.SceneManagement;
 public class GameMgr : MonoBehaviour
 {
     public static bool debugInEditor = false;
-    public static int gameType = 3;
+    public static int gameType = 4;
     public GameMode gameMode;
     [System.NonSerialized] public bool gameOver = false;
     public static GameMgr ins;

Some files were not shown because too many files changed in this diff