142 lines
3.5 KiB
C#
142 lines
3.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 FluffyUnderware.Curvy;
|
|
using Pathfinding;
|
|
using TMPro;
|
|
using TruegearSdk;
|
|
using Unity.XR.PXR;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.XR.Interaction.Toolkit;
|
|
using Random = UnityEngine.Random;
|
|
|
|
public class GameInit : MonoBehaviour
|
|
{
|
|
public static GameInit Ins { get; private set; }
|
|
|
|
public Camera playerCam;
|
|
public Transform leftHand;
|
|
public Transform rightHand;
|
|
public TruegearAndroidConnector androidConnector;
|
|
|
|
public AstarPath aiPath;
|
|
|
|
public Transform showPos;
|
|
|
|
public CurvySpline[] curvySplines;
|
|
|
|
public CurvySpline surroundSpline;
|
|
|
|
public EventSystem eventSystem;
|
|
|
|
[NonSerialized]
|
|
public GameObject HitUI;
|
|
|
|
[NonSerialized]
|
|
public GameObject DieUI;
|
|
|
|
public Transform startDoorPos;
|
|
|
|
[NonSerialized]
|
|
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.MRFishingMaster;
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
// public Transform[] GetFishPath()
|
|
// {
|
|
// int showFishIndex= Random.Range(0, showFishPos.Length);
|
|
// int targetFishIndex=showFishIndex+8;
|
|
// if (targetFishIndex >= showFishPos.Length)
|
|
// targetFishIndex = showFishIndex - 8;
|
|
// Transform showFish = showFishPos[showFishIndex];
|
|
// Transform targetFish = showFishPos[targetFishIndex];
|
|
// Transform[] fishPath = new Transform[2];
|
|
// fishPath[0] = showFish;
|
|
// fishPath[1] = targetFish;
|
|
// return fishPath;
|
|
// }
|
|
|
|
public CurvySpline GetFishPath()
|
|
{
|
|
return curvySplines[Random.Range(0, curvySplines.Length)];
|
|
}
|
|
}
|
|
|