| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.EventSystems;
 
- using UnityEngine.UI;
 
- namespace WildAttack
 
- {
 
-     /// <summary>
 
-     /// 射击类型枚举
 
-     /// </summary>
 
-     public enum ShootTypeEnum
 
-     {
 
-         FixedScreen = 1,
 
-         FixedCrossHair = 2,
 
-         moreScreen = 3,// 超出范围 调整相机
 
-     }
 
-     /// <summary>
 
-     /// 游戏管理器
 
-     /// </summary>
 
-     public class GameMananger : Singleton<GameMananger>
 
-     {
 
-         #region Members
 
-         private int hp = 0;
 
-         public int HP { get { return hp; } }
 
-         private int hpMax = 0;
 
-         public int HPMax { get { return hpMax; } }
 
-         private int totalScore = 0;
 
-         private int uploadScore = 0;
 
-         public int TotalScore { get { return totalScore; } }
 
-         public int barrelTriggerCount = 0;
 
-         private ShootTypeEnum typeEnum = ShootTypeEnum.FixedScreen;
 
-         // 原始旋转
 
-         Vector3 originalBowRotation;
 
-         // 弓箭旋转对应的对象 对弓箭的操作体现在这个obj上
 
-         Transform CrossHairTrans;
 
-         // 射箭速度
 
-         private float smartBowSpeed;
 
-         private float testSpeed;
 
-         // 语言类型 配合csv
 
-         private LanguageType languageType;
 
-         public LanguageType Language { get { return languageType; } }
 
-         // 相机初始旋转信息位置信息
 
-         private Vector3 camOriEular;
 
-         private Vector3 camOriPos;
 
-         // 游戏结束时 相机目标点
 
-         private Transform gameOverTrans;
 
-         // 弓
 
-         private Bow bow;
 
-         // 城门动画控制
 
-         private Animator wallAnim;
 
-         // 特效
 
-         private ParticleSystem addHpParticle;
 
-         private ParticleSystem failParticle;
 
-         private ParticleSystem victoryParticle;
 
-         //触摸检测器
 
-         JCUnityLib.TouchChecker touchChecker = new JCUnityLib.TouchChecker();
 
-         UserGameAnalyse1 userGameAnalyse1;
 
-         //游戏计算的分数只有射箭出来算
 
-         bool bAddCountScore = false;
 
-         #endregion
 
-         #region Function
 
-         public void Init(UserGameAnalyse1 _userGameAnalyse1)
 
-         {
 
-             userGameAnalyse1 = _userGameAnalyse1;
 
-             camOriEular = Camera.main.transform.eulerAngles;
 
-             camOriPos = Camera.main.transform.position;
 
-             gameOverTrans = GameObject.Find("GameOver").transform;
 
-             bow = GameObject.Find("Bow").GetComponent<Bow>();
 
-             languageType = LanguageType.CH;
 
-             if (TextAutoLanguage2.GetLanguage() == LanguageEnum.English) languageType = LanguageType.EN;
 
-             CrossHairTrans = GameObject.Find("CrossHairTrans").transform;
 
-             originalBowRotation = CrossHairTrans.eulerAngles;
 
-             wallAnim = GameObject.Find("Wall").GetComponent<Animator>();
 
-             hpMax = Mathf.FloorToInt(GameModule.GetInstance().GetData("wallHp"));
 
-             hp = hpMax;
 
-             totalScore = 0;
 
-             uploadScore = 0;
 
-             barrelTriggerCount = 0;
 
-             //shootSpawn = GameModule.GetInstance().GetData("downTime");
 
-             shootSpawn = 0;
 
-             smartBowSpeed = GameModule.GetInstance().GetData("speedTimes");
 
-             testSpeed = GameModule.GetInstance().GetData("testspeed");
 
-             Transform particleTrans = GameObject.Find("finalPos/ParticleTrans").transform;
 
-             addHpParticle = particleTrans.Find("addhp").GetChild(0).GetComponent<ParticleSystem>();
 
-             failParticle = particleTrans.Find("fail").GetChild(0).GetComponent<ParticleSystem>();
 
-             victoryParticle = particleTrans.Find("victory").GetChild(0).GetComponent<ParticleSystem>();
 
-             Physics.autoSyncTransforms = true;
 
-             InitForLimitBound();
 
-             InitTouchChecker();
 
-         }
 
-         /// <summary>
 
-         /// 射击类型相关接口
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public ShootTypeEnum GetShootType()
 
-         {
 
-             return typeEnum;
 
-         }
 
-         public void SetShootType(ShootTypeEnum type)
 
-         {
 
-             this.typeEnum = type;
 
-             if (this.typeEnum == ShootTypeEnum.FixedScreen)
 
-             {
 
-                 bow.transform.Find("CameraParent").DetachChildren();
 
-                 GameObject.Find("UIBoxLeft").GetComponent<CanvasGroup>().blocksRaycasts = true;
 
-             }
 
-             else if (this.typeEnum == ShootTypeEnum.FixedCrossHair)
 
-             {
 
-                 CrossHair.instance._rectTransform.anchoredPosition = new Vector2(0, 0);
 
-                 Camera.main.transform.SetParent(bow.transform.Find("CameraParent"));
 
-             }
 
-             else if (this.typeEnum == ShootTypeEnum.moreScreen)
 
-             {
 
-                 bow.transform.Find("CameraParent").DetachChildren();
 
-                 GameObject.Find("UIBoxLeft").GetComponent<CanvasGroup>().blocksRaycasts = false;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 游戏是否结束
 
-         /// </summary>
 
-         public bool isOver = false;
 
-         /// <summary>
 
-         /// 胜利失败
 
-         /// </summary>
 
-         public bool isWin;
 
-         /// <summary>
 
-         /// 游戏结束
 
-         /// </summary>
 
-         /// <param name="isWin"></param>
 
-         public void GameOver(bool isWin)
 
-         {
 
-             isOver = true;
 
-             // 血量回复
 
-             this.hp = isWin ? hp : hpMax;
 
-             this.isWin = isWin;
 
-             // 城门对应动画
 
-             wallAnim.SetBool(isWin ? "open" : "dead", true);
 
-             AddScore(StagePropertyModule.GetInstance().GetData(1).score * (6 - barrelTriggerCount));
 
-             // 特效
 
-             if (isWin)
 
-             {
 
-                 failParticle.Stop();
 
-                 victoryParticle.Play();
 
-             }
 
-             else
 
-             {
 
-                 failParticle.Play();
 
-                 victoryParticle.Stop();
 
-                 // 失败时有城门破坏音效
 
-                 AudioSource ads = GameObject.Find("ProcessAudioSource").GetComponent<AudioSource>();
 
-                 ads.clip = Resources.Load<AudioClip>("Process/Broken");
 
-                 if (UserSettings.ins.openEffect) ads.Play();
 
-             }
 
-             //关卡结束时候触发
 
-             OnUploadScore();
 
-             // 调用其他管理类的GameOver
 
-             ProcessManager.GetInstance().GameOver(false);
 
-             if (!isWin) EnemyManager.GetInstance().GameOver();
 
-             UIManager.GetInstance().HideMainPanel();
 
-         }
 
-         //荒野射击上传分数到服务器
 
-         public void OnUploadScore() {
 
-             if (uploadScore > 0)
 
-             {
 
-                 //游戏结束上传一个分数
 
-                 Debug.Log("荒野射击上传的积分为:" + uploadScore);
 
-                 RankComp.Instance.uploadSinglePlayerGameRes(uploadScore);
 
-                 uploadScore = 0;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 血量
 
-         /// </summary>
 
-         /// <param name="hp"></param>
 
-         public void SubHp(int hp)
 
-         {
 
-             this.hp -= hp;
 
-             UIManager.GetInstance().SubHp();
 
-             if (this.hp <= 0)
 
-             {
 
-                 GameOver(false);
 
-             }
 
-         }
 
-         public void AddHp(int hp)
 
-         {
 
-             this.hp += hp;
 
-             if (hp != (int)GameModule.GetInstance().GetData("wallHp"))
 
-             {
 
-                 addHpParticle.Play();
 
-             }
 
-             if (this.hp > hpMax)
 
-             {
 
-                 this.hp = hpMax;
 
-             }
 
-             // 血量重置
 
-             if (hp == hpMax)
 
-             {
 
-                 UIManager.GetInstance().ResetHpBar();
 
-             }
 
-             // ui更新血条
 
-             UIManager.GetInstance().AddHp();
 
-         }
 
-         /// <summary>
 
-         /// 计分
 
-         /// </summary>
 
-         /// <param name="score"></param>
 
-         public void AddScore(int score)
 
-         {
 
-             //在射箭状态下触发的才计算分数,手点触发射箭后不计算分数
 
-             if (!bAddCountScore) return;
 
-             totalScore += score;
 
-             //只记录一个上传的分数
 
-             uploadScore += score;
 
-         }
 
-         public void SetScore(int score)
 
-         {
 
-             totalScore = score;
 
-             barrelTriggerCount = 0;
 
-         }
 
-         // Update is called once per frame
 
-         public void Update()
 
-         {
 
-             bow.gameObject.SetActive(!isOver);
 
-             // BGM
 
-             if (!Camera.main.GetComponent<AudioSource>().isPlaying)
 
-             {
 
-                 if (UserSettings.ins.openBGM)
 
-                     Camera.main.GetComponent<AudioSource>().Play();
 
-             }
 
-             else {
 
-                 //如果正在播放
 
-                 if (!UserSettings.ins.openBGM)
 
-                     Camera.main.GetComponent<AudioSource>().Stop();
 
-             }
 
-             // 设计间隔
 
-             if (shootSpawn > 0)
 
-             {
 
-                 shootSpawn -= Time.deltaTime;
 
-             }
 
-             // unity调试用
 
- #if UNITY_EDITOR
 
-             #region pc端操作
 
-             if (Input.GetKeyDown(KeyCode.N))
 
-             {
 
-                 AddHp(5);
 
-             }
 
-             if (Input.GetKeyDown(KeyCode.M))
 
-             {
 
-                 SubHp(5);
 
-             }
 
-             if (Input.GetKeyDown(KeyCode.P))
 
-             {
 
-                 foreach (var item in EnemyManager.GetInstance().enemyList)
 
-                 {
 
-                     item.Hitted(4, false);
 
-                 }
 
-             }
 
-             UpdateBowUnityEditor();
 
-             if (Input.GetKeyDown(KeyCode.Space))
 
-             {
 
-                 ShootOut(testSpeed);
 
-             }
 
-             if (Input.GetKeyDown(KeyCode.I))
 
-             {
 
-                 GameOver(true);
 
-             }
 
-             if (Input.GetKeyDown(KeyCode.O))
 
-             {
 
-                 GameOver(false);
 
-             }
 
-             #endregion
 
- #endif
 
-             if (BowCamera.isTouchMode) touchChecker.Update();
 
-             // 游戏结束后相机移动到对应位置
 
-             if (isOver)
 
-             {
 
-                 Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, gameOverTrans.position, 2 * Time.deltaTime);
 
-                 Camera.main.transform.eulerAngles = Vector3.Lerp(Camera.main.transform.eulerAngles, gameOverTrans.eulerAngles, 2 * Time.deltaTime);
 
-                 // 到达目标点显示ui
 
-                 if (Vector3.Distance(Camera.main.transform.position, gameOverTrans.position) < 0.01f)
 
-                 {
 
-                     UIManager.GetInstance().GameOver(isWin);
 
-                     InitForLimitBound();
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// ui检测
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         //private bool CheckCrossHairOverUI()
 
-         //{
 
-         //    if (!isOver) return false;
 
-         //    EventSystem eventSystem = EventSystem.current;
 
-         //    PointerEventData pointerEventData = new PointerEventData(eventSystem);
 
-         //    // 获取准星pos 通过eventsystem检测下方是否有按钮
 
-         //    pointerEventData.position = new Vector3(UIManager.GetInstance().GetCrossHairPos().x, UIManager.GetInstance().GetCrossHairPos().y, 0);
 
-         //    //射线检测ui
 
-         //    List<RaycastResult> uiRaycastResultCache = new List<RaycastResult>();
 
-         //    eventSystem.RaycastAll(pointerEventData, uiRaycastResultCache);
 
-         //    if (uiRaycastResultCache.Count > 0)
 
-         //    {
 
-         //        // 是否有button
 
-         //        Button btn = uiRaycastResultCache[0].gameObject.GetComponent<Button>();
 
-         //        if (btn == null)
 
-         //        {
 
-         //            // 防止检测到button下的text (ui注意设置 button下text不要勾选raycast
 
-         //            btn = uiRaycastResultCache[0].gameObject.transform.GetComponentInParent<Button>();
 
-         //            if (btn == null)
 
-         //            {
 
-         //                return false;
 
-         //            }
 
-         //        }
 
-         //        btn.onClick.Invoke();
 
-         //        //Debug.Log("eventsystem 触发 + " + uiRaycastResultCache[0].gameObject.name);
 
-         //        return true;
 
-         //    }
 
-         //    else
 
-         //    {
 
-         //        return false;
 
-         //    }
 
-         //}
 
-         /// <summary>
 
-         /// 初始化相机等
 
-         /// </summary>
 
-         public void ResetMainCamera()
 
-         {
 
-             isOver = false;
 
-             InitForLimitBound();
 
-             ResetAim();
 
-             // 城门动画
 
-             wallAnim.SetBool("dead", false);
 
-             wallAnim.SetBool("open", false);
 
-             // 特效
 
-             failParticle.Stop();
 
-             failParticle.Clear();
 
-             victoryParticle.Stop();
 
-             victoryParticle.Clear();
 
-             // 相机
 
-             Camera.main.transform.position = camOriPos;
 
-             Camera.main.transform.eulerAngles = camOriEular;
 
-         }
 
-         /// <summary>
 
-         /// pc端旋转弓
 
-         /// </summary>
 
-         private void UpdateBowUnityEditor()
 
-         {
 
-             // axis控制弓箭旋转
 
-             if (shootSpawn <= GameModule.GetInstance().GetData("downTime") && shootSpawn > 0) return;
 
-             float x = Input.GetAxis("Horizontal") / 2;
 
-             float y = Input.GetAxis("Vertical") / 2;
 
-             if (x != 0 || y != 0)
 
-             {
 
-                 //CrossHairTrans.eulerAngles = LimitAngles(new Vector3(CrossHairTrans.eulerAngles.x - y, CrossHairTrans.eulerAngles.y + x, 0));
 
-                 //CrossHairTransRaycast();
 
-                 if (isOver)
 
-                 {
 
-                     CrossHairTrans.eulerAngles = LimitCrossHair(new Vector3(CrossHairTrans.eulerAngles.x - y, CrossHairTrans.eulerAngles.y + x, 0));
 
-                 }
 
-                 else
 
-                 {
 
-                     CrossHairTrans.eulerAngles = LimitAngles(new Vector3(CrossHairTrans.eulerAngles.x - y, CrossHairTrans.eulerAngles.y + x, 0));
 
-                     CrossHairTransRaycast();
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 移动端用户触屏监听
 
-         /// </summary>
 
-         private void InitTouchChecker()
 
-         {
 
-             touchChecker.onMoved += delegate (Touch t, bool isOnUI)
 
-             {
 
-                 if (isOnUI) return;
 
-                 if (shootSpawn <= GameModule.GetInstance().GetData("downTime") && shootSpawn > 0) return;
 
-                 Vector3 dis = t.rawPosition - t.deltaPosition;
 
-                 if (dis.x != 0 || dis.y != 0)
 
-                 {
 
-                     if (isOver)
 
-                     {
 
-                         CrossHairTrans.eulerAngles = LimitCrossHair(new Vector3(CrossHairTrans.eulerAngles.x - (t.deltaPosition.y * Time.deltaTime), CrossHairTrans.eulerAngles.y + (t.deltaPosition.x * Time.deltaTime), 0));
 
-                     }
 
-                     else
 
-                     {
 
-                         CrossHairTrans.eulerAngles = LimitAngles(new Vector3(CrossHairTrans.eulerAngles.x - (t.deltaPosition.y * Time.deltaTime), CrossHairTrans.eulerAngles.y + (t.deltaPosition.x * Time.deltaTime), 0));
 
-                         CrossHairTransRaycast();
 
-                     }
 
-                 }
 
-             };
 
-             touchChecker.onEnded += delegate (Touch t, bool isOnUI)
 
-             {
 
-                 if (isOnUI) return;
 
-                 ShootOut(testSpeed);
 
-             };
 
-         }
 
-         /// <summary>
 
-         /// 归位
 
-         /// </summary>
 
-         public void ResetAim()
 
-         {
 
-             // 连接了弓 调用sdk
 
-             if (SmartBowController.Instance && SmartBowController.Instance.IsBluetoothModuleInited())
 
-             {
 
-                 CrossHairTrans.localRotation = Quaternion.Euler(Vector3.zero);
 
-                 bow.transform.localRotation = CrossHairTrans.localRotation;
 
-                 if (AimHandler.ins.bRuning9Axis())
 
-                 {
 
-                     AimHandler.ins?.DoIdentity();
 
-                 }
 
-                 else
 
-                 {
 
-                     //红外设备校准偏离点
 
-                     InfraredDemo._ins?.OnClick_SetAdjustPointsOffset();
 
-                 }
 
-             
 
-             }
 
-             else
 
-             {
 
-                 if (isOver)
 
-                 {
 
-                     CrossHairTrans.localEulerAngles = Vector3.zero;
 
-                 }
 
-                 else
 
-                 {
 
-                     CrossHairTrans.localEulerAngles = Vector3.zero;
 
-                     bow.transform.eulerAngles = CrossHairTrans.eulerAngles;
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 最高分
 
-         /// </summary>
 
-         private int highScore;
 
-         public void SetHighScore(int score)
 
-         {
 
-             highScore = score;
 
-         }
 
-         public int GetHighScore()
 
-         {
 
-             return highScore;
 
-         }
 
-         #endregion
 
-         #region InfraredCamera
 
-         public void OnScreenPointUpdate(Vector2 point)
 
-         {
 
-             // 判断射击间隔
 
-             if (shootSpawn <= GameModule.GetInstance().GetData("downTime") && shootSpawn > 0) return;
 
-             Ray ray = Camera.main.ScreenPointToRay(point);
 
-             Vector3 rayEndPoint = ray.GetPoint(200);
 
-             Quaternion quat = Quaternion.LookRotation(rayEndPoint - Camera.main.transform.position);
 
-             CrossHairTrans.rotation = quat;
 
-             CrossHairTransRaycast();
 
-         }
 
-         #endregion
 
-         #region SmartBlueToothSDK
 
-         public void OnRotationUpdate(Quaternion rotation)
 
-         {
 
-             if (CrossHairTrans == null) return;
 
-             // 判断射击间隔
 
-             if (shootSpawn <= GameModule.GetInstance().GetData("downTime") && shootSpawn > 0) return;
 
-             // 旋转插值
 
-             Vector3 offset = isOver ? gameOverTrans.eulerAngles : originalBowRotation;
 
-             Vector3 newOffset = Vector3.zero;
 
-             if (offset.x != 0)
 
-             {
 
-                 newOffset.x = offset.x - 360f;
 
-             }
 
-             if (offset.y != 0)
 
-             {
 
-                 newOffset.y = offset.y - 360f;
 
-             }
 
-             //Bow.Instance.transform.localRotation = rotation;
 
-             float speed = 2f;
 
-             Vector3 offsetEular = rotation.eulerAngles;
 
-             // 真实旋转(弓箭sdk传回的参数有时为360有时为0
 
-             offsetEular.x = offsetEular.x > 180 ? offsetEular.x - 360 : offsetEular.x;
 
-             offsetEular.y = offsetEular.y > 180 ? offsetEular.y - 360 : offsetEular.y;
 
-             offsetEular = new Vector3(offsetEular.x * speed, offsetEular.y * speed, offsetEular.z * speed) + newOffset;
 
-             // 检测超出屏幕
 
-             if (isOver)
 
-             {
 
-                 CrossHairTrans.eulerAngles = LimitCrossHair(offsetEular);
 
-             }
 
-             else
 
-             {
 
-                 CrossHairTrans.eulerAngles = LimitAngles(offsetEular);
 
-                 CrossHairTransRaycast();
 
-             }
 
-         }
 
-         public Vector3 hitPoint;
 
-         /// <summary>
 
-         /// 射线检测指向点 用于同步弓旋转
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         Vector3 CrossHairTransRaycast()
 
-         {
 
-             Ray ray = new Ray(CrossHairTrans.position, CrossHairTrans.forward);
 
-             RaycastHit hitInfo;
 
-             if (Physics.Raycast(ray, out hitInfo, 100, ~1 << LayerMask.NameToLayer("Plane")))
 
-             {
 
-                 hitPoint = hitInfo.point;
 
-             }
 
-             else hitPoint = CrossHairTrans.position + CrossHairTrans.forward * 100f;
 
-             bow.transform.LookAt(hitPoint);
 
-             Physics.SyncTransforms();
 
-             return hitPoint;
 
-         }
 
-         public Vector3 LimitCrossHair(Vector3 angles)
 
-         {
 
-             Vector3 viewPos = Camera.main.WorldToViewportPoint(CrossHairTransRaycast());
 
-             if (viewPos.x > 0 && viewPos.x < 1 && viewPos.y > 0 && viewPos.y < 1)
 
-             {
 
-             }
 
-             else
 
-             {
 
-                 if (viewPos.x < 0)
 
-                 {
 
-                     angles.y += 1f;
 
-                 }
 
-                 else if (viewPos.x > 1)
 
-                 {
 
-                     angles.y -= 1f;
 
-                 }
 
-                 if (viewPos.y < 0)
 
-                 {
 
-                     angles.x -= 1f;
 
-                 }
 
-                 else if (viewPos.y > 1)
 
-                 {
 
-                     angles.x += 1f;
 
-                 }
 
-             }
 
-             return angles;
 
-         }
 
-         private float shootSpawn = 0;
 
-         /// <summary>
 
-         /// 射箭监听
 
-         /// </summary>
 
-         /// <param name="speed"></param>
 
-         public void OnModuleShooting(float speed)
 
-         {
 
-             // speed区间 7~20?
 
-             // 在这里判断是否和ui交互? 优先判断ui 不是ui再射箭
 
-             ShootOut(speed * smartBowSpeed,true);
 
-             //Debug.Log("OnModuleShooting:"+speed);
 
-             //TipText.Show((speed * smartBowSpeed).ToString());
 
-             // 角度 OnRotationUpdate
 
-         }
 
-         void ShootOut(float speed,bool bAddCount = false)
 
-         {
 
-             if (isOver) return;
 
-             //根据射箭状态赋值
 
-             bAddCountScore = bAddCount;
 
-             if (bAddCount)userGameAnalyse1.changeShootingCount(1);
 
-             bow.Shoot(speed);
 
-         }
 
-         public void SetShootSpawn(float spawn)
 
-         {
 
-             shootSpawn = spawn;
 
-         }
 
-         #endregion
 
-         #region 限制其显示范围不超出屏幕
 
-         private float _screenHeightHalf;
 
-         private float _screenNormal;
 
-         private float _rangeRotateY;
 
-         private float _rangeRotateX;
 
-         /// <summary>
 
-         /// 标记是否出界(-1:未出界;0:左边出界;1:右边出界;2:上边出界;3:下边出界;)
 
-         /// </summary>
 
-         public int outBoundIndex = -1;
 
-         void InitForLimitBound()
 
-         {
 
-             Camera camera = Camera.main;
 
-             _rangeRotateX = camera.fieldOfView / 2;
 
-             float _screenWidthHalf = Screen.width / 2f;
 
-             _screenHeightHalf = Screen.height / 2f;
 
-             _screenNormal = _screenHeightHalf / Mathf.Tan(_rangeRotateX / 180f * Mathf.PI);
 
-             _rangeRotateY = Mathf.Atan(_screenWidthHalf / _screenNormal) / Mathf.PI * 180f;
 
-         }
 
-         public Vector3 LimitAngles(Vector3 angles)
 
-         {
 
-             InitForLimitBound();
 
-             Vector3 offset = isOver ? gameOverTrans.eulerAngles : originalBowRotation;
 
-             //Unity默认范围(0,360)格式化为自定义范围(-180,180)
 
-             angles.y = angles.y > 180 ? angles.y - 360 : angles.y;
 
-             angles.x = angles.x > 180 ? angles.x - 360 : angles.x;
 
-             //记录原来的角度
 
-             float angleY = angles.y;
 
-             float angleX = angles.x;
 
-             //返回限制边界后的角度
 
-             angles.y = Mathf.Clamp(angleY, -_rangeRotateY + (offset.y - 360), _rangeRotateY + (offset.y - 360));
 
-             float rayLen = _screenNormal / Mathf.Cos(Mathf.Abs(angles.y) / 180 * Mathf.PI);
 
-             float maxRangeRotateX = Mathf.Atan(_screenHeightHalf / rayLen) / Mathf.PI * 180f - offset.x;
 
-             if (isOver)
 
-             {
 
-                 if (angleX < -15f)
 
-                 {
 
-                     angles.x = -15f;
 
-                 }
 
-                 else if (angleX > 45f)
 
-                 {
 
-                     angles.x = 45f;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (Mathf.Abs(angleX) > Mathf.Abs(30f)) angles.x = 30f * (angleX > 0 ? 1 : -1);
 
-             }
 
-             if (angles.y < -_rangeRotateY + (offset.y - 360) + 0.5f)
 
-             {
 
-                 outBoundIndex = 0;
 
-             }
 
-             else if (angles.y > _rangeRotateY + (offset.y - 360) - 0.5f)
 
-             {
 
-                 outBoundIndex = 1;
 
-             }
 
-             else if (angles.x < -30f + 0.5f)
 
-             {
 
-                 outBoundIndex = 2;
 
-             }
 
-             else if (angles.x > 30f - 0.5f)
 
-             {
 
-                 outBoundIndex = 3;
 
-             }
 
-             else
 
-             {
 
-                 outBoundIndex = -1;
 
-             }
 
-             return angles;
 
-         }
 
-         #endregion
 
-     }
 
- }
 
 
  |