110 lines
2.5 KiB
C#
110 lines
2.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Net.WebSockets;
|
|
using DarkTonic.MasterAudio;
|
|
using TMPro;
|
|
using TruegearSdk;
|
|
using Unity.XR.PXR;
|
|
using UnityEngine.XR.Interaction.Toolkit;
|
|
|
|
public class GameInit : MonoBehaviour
|
|
{
|
|
public static GameInit Ins { get; private set; }
|
|
|
|
public Camera playerCam;
|
|
public Transform leftHand;
|
|
public Transform rightHand;
|
|
public TruegearAndroidConnector androidConnector;
|
|
|
|
public Transform[] allBossPos;
|
|
|
|
[NonSerialized]
|
|
public GameObject HitUI;
|
|
|
|
[NonSerialized]
|
|
public GameObject DieUI;
|
|
|
|
public Transform startDoorPos;
|
|
|
|
public int gameTime = 60 * 15;
|
|
|
|
public float curGameTime;
|
|
|
|
/// <summary>
|
|
/// 游戏场地
|
|
/// </summary>
|
|
public GamePlace gamePlace;
|
|
|
|
public GameKey gameId;
|
|
|
|
[NonSerialized]
|
|
public Player self;
|
|
|
|
private void Awake()
|
|
{
|
|
Ins = this;
|
|
Application.targetFrameRate = 60;
|
|
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
|
|
PXR_MixedReality.EnableVideoSeeThroughEffect(true);
|
|
#endif
|
|
}
|
|
|
|
public void CloseLine()
|
|
{
|
|
// leftHand.GetComponent<XRRayInteractor>().enabled = false;
|
|
// rightHand.GetComponent<XRRayInteractor>().enabled = false;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
gameId = GameKey.XMen2;
|
|
curGameTime = 0;
|
|
CloseLine();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
{
|
|
//GameManager.Ins.CreateEnemy(0, Vector3.zero,Vector3.zero);
|
|
}
|
|
if (GameManager.Ins.isGamePlay)
|
|
{
|
|
curGameTime+=Time.deltaTime;
|
|
}
|
|
}
|
|
|
|
public int GetNowTime()
|
|
{
|
|
return Mathf.RoundToInt(curGameTime);
|
|
}
|
|
|
|
public void PlayAudio(string audioName, Transform tran,bool isAllStop,Action cb=null)
|
|
{
|
|
StartCoroutine(PlayAudioTro(audioName, tran, isAllStop, cb));
|
|
}
|
|
|
|
public IEnumerator PlayAudioTro(string audioName, Transform tran,bool isAllStop,Action cb=null)
|
|
{
|
|
if(isAllStop)
|
|
MasterAudio.StopAllSoundsOfTransform(tran);
|
|
if (audioName != "")
|
|
{
|
|
MasterAudio.PlaySound3DAtTransform(audioName, tran);
|
|
MasterAudioGroup audioGroup = MasterAudio.GrabGroup(audioName);
|
|
if (cb != null)
|
|
{
|
|
while (audioGroup.ActiveVoices>0)
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
}
|
|
cb?.Invoke();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|