| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- namespace WildAttack
- {
- public class SmartBowController : MonoBehaviour
- {
- public static SmartBowController Instance;
- void Start()
- {
- Instance = this;
- SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
- StartCoroutine(SetOutBoundChecker());
- }
- public void onInit() {
- if (GameMananger.GetInstance().CurrentGameType == GameTypeEnum.SinglePlayer)
- InfraredDemo.infraredCameraHelper.OnPositionUpdate += OnScreenPointUpdate;
- else
- InfraredDemo.infraredCameraHelper.OnPositionUpdate2 += OnScreenPointsUpdate;
- }
- IEnumerator SetOutBoundChecker()
- {
- yield return null;
- CrossHairOutBoundChecker1 outBoundChecker = Instantiate(Resources.Load<GameObject>("Prefabs/CrossHairOutBoundChecker1")).GetComponent<CrossHairOutBoundChecker1>();
- outBoundChecker.FetchOutBoundIndex = () => GameMananger.GetInstance().outBoundIndex;
- }
- void OnDestroy()
- {
- if (Instance == this) Instance = null;
- if (GameMananger.GetInstance().CurrentGameType == GameTypeEnum.SinglePlayer)
- InfraredDemo.infraredCameraHelper.OnPositionUpdate -= OnScreenPointUpdate;
- else
- InfraredDemo.infraredCameraHelper.OnPositionUpdate2 -= OnScreenPointsUpdate;
- }
- public void OnRotationUpdate(Quaternion rotation)
- {
- if (SB_EventSystem.ins.simulateMouseIsAwaked) return;
- GameMananger.GetInstance()?.OnRotationUpdate(rotation);
- }
- public void OnScreenPointUpdate(Vector2 point, Vector2 cameraLocation)
- {
- if (SB_EventSystem.ins.simulateMouseIsAwaked) return;
- GameMananger.GetInstance()?.OnScreenPointUpdate(point);
- }
- public void OnScreenPointsUpdate(Vector2[] points, Vector2[] cameraLocations)
- {
- if (points == null || cameraLocations == null) return;
- if (SB_EventSystem.ins.simulateMouseIsAwaked) return;
- for (int i = 0; i < points.Length; i++)
- {
- Vector2 point = points[i];
- PlayerTypeEnum playerType = (i == 0) ? PlayerTypeEnum.First : PlayerTypeEnum.Second;
- // 传给 GameManager 逻辑(准星控制)
- GameMananger.GetInstance()?.OnScreenPointUpdate(point, playerType);
- }
- }
- float _lastShootTime = 0;
- public void OnShooting(float speed)
- {
- if (Time.time == 0) return;
- if (Time.realtimeSinceStartup - _lastShootTime < 1) return;
- _lastShootTime = Time.realtimeSinceStartup;
- GameMananger.GetInstance().OnModuleShooting(speed);
- }
- float _lastShootTime_2P = 0;
- public void OnShooting2P(float speed)
- {
- if (Time.time == 0) return;
- if (Time.realtimeSinceStartup - _lastShootTime_2P < 1) return;
- _lastShootTime_2P = Time.realtimeSinceStartup;
- GameMananger.GetInstance().OnModuleShooting(speed,PlayerTypeEnum.Second);
- }
- public bool IsBluetoothModuleInited()
- {
- return BluetoothAim.ins && BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
- }
- }
- }
|