101 lines
2.4 KiB
C#
101 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using Enviro;
|
|
using Fantasy;
|
|
using NBC;
|
|
using UnityEngine;
|
|
using WaveHarmonic.Crest;
|
|
|
|
namespace NBF
|
|
{
|
|
public class Map : SingletonMono<Map>
|
|
{
|
|
[Header("节点信息")] public WaterRenderer Water;
|
|
public Transform Node;
|
|
public Transform GearsNode;
|
|
[Header("角色参数")] public int MapId;
|
|
public string RoomCode;
|
|
|
|
|
|
public readonly List<MapUnitInfo> Units = new List<MapUnitInfo>();
|
|
|
|
|
|
public readonly List<Player> Players = new List<Player>();
|
|
|
|
public void SetData(int mapId, string code, List<MapUnitInfo> units)
|
|
{
|
|
MapId = mapId;
|
|
RoomCode = code;
|
|
Units.AddRange(units);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
EnviroManager.instance.Time.Settings.simulate = true;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
UpdateFPS();
|
|
UpdateTimeOfDay();
|
|
}
|
|
|
|
#region FPS
|
|
|
|
public int FPS;
|
|
|
|
public float updateInterval = 0.2f; // 更新间隔(秒)
|
|
|
|
private float accum = 0;
|
|
private int frames = 0;
|
|
private float timeleft;
|
|
|
|
void UpdateFPS()
|
|
{
|
|
timeleft -= Time.deltaTime;
|
|
accum += Time.timeScale / Time.deltaTime;
|
|
frames++;
|
|
|
|
if (timeleft <= 0.0f)
|
|
{
|
|
FPS = (int)(accum / frames);
|
|
|
|
timeleft = updateInterval;
|
|
accum = 0.0f;
|
|
frames = 0;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 场景时间
|
|
|
|
private void UpdateTimeOfDay()
|
|
{
|
|
var p = GameTimer.GetGameDayProgress();
|
|
p = 0.1f;
|
|
// Debug.Log(p);
|
|
EnviroManager.instance.Time.SetTimeOfDay(p * 24f);
|
|
// if(AzureCoreSystem)
|
|
// AzureCoreSystem.timeSystem.timeline = 24F * p;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Player
|
|
|
|
public void InstancePlayers()
|
|
{
|
|
var playerObject = PrefabsHelper.CreatePlayer(Node);
|
|
playerObject.transform.localPosition = new Vector3(484, 1, 422);
|
|
var player = playerObject.GetComponent<Player>();
|
|
Players.Add(player);
|
|
player.IsSelf = true;
|
|
if (player.IsSelf)
|
|
{
|
|
CameraManager.Instance.SetFppLook(player);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |