mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 02:47:12 +08:00
126 lines
4.0 KiB
C#
126 lines
4.0 KiB
C#
|
|
using System;
|
|||
|
|
using Data;
|
|||
|
|
using Entity;
|
|||
|
|
using Managers;
|
|||
|
|
using Map;
|
|||
|
|
using UI;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.SceneManagement;
|
|||
|
|
|
|||
|
|
namespace Base
|
|||
|
|
{
|
|||
|
|
public class PlayGameSceneControl:MonoBehaviour,ITick
|
|||
|
|
{
|
|||
|
|
public Dimension dimensionPrefab;
|
|||
|
|
|
|||
|
|
public WaitStartUI waitStartUI;
|
|||
|
|
|
|||
|
|
public bool AllDimensionsLoaded => OutsideDimensionsLoaded && InsideDimensionsLoaded;
|
|||
|
|
public bool OutsideDimensionsLoaded { get; private set; }
|
|||
|
|
public bool InsideDimensionsLoaded { get; private set; }
|
|||
|
|
|
|||
|
|
public DimensionDef OutsideDef{get; private set;}
|
|||
|
|
public DimensionDef InsideDef{get; private set;}
|
|||
|
|
|
|||
|
|
public Dimension OutsideDimension{get; private set;}
|
|||
|
|
public Dimension InsideDimension{get; private set;}
|
|||
|
|
|
|||
|
|
public bool TaskCompleted{get; private set;}
|
|||
|
|
private void Start()
|
|||
|
|
{
|
|||
|
|
OutsideDef = Program.Instance.OutsidePlayDimension;
|
|||
|
|
InsideDef = Program.Instance.CurrentCharacter.insideDimensionDef ??
|
|||
|
|
DefineManager.Instance.FindDefine<DimensionDef>(
|
|||
|
|
Configs.ConfigManager.Instance.GetValue<string>("InsideDimension"));
|
|||
|
|
if (OutsideDef == null || InsideDef == null)
|
|||
|
|
{
|
|||
|
|
MessageManager.Instance.DisplayMessage("初始化失败!检查XML文件完整性",PromptDisplayCategory.ScreenCenterLargeText,Color.brown);
|
|||
|
|
Invoke(nameof(ReturnMainMenu), 3);
|
|||
|
|
}
|
|||
|
|
OutsideDimension=Instantiate(dimensionPrefab);
|
|||
|
|
InsideDimension = Instantiate(dimensionPrefab);
|
|||
|
|
|
|||
|
|
OutsideDimension.transform.localPosition = new Vector3(0, 0, 1);
|
|||
|
|
InsideDimension.transform.localPosition = new Vector3(0, 1000, 1);
|
|||
|
|
|
|||
|
|
_ = OutsideDimension.ApplyDimensionDef(OutsideDef);
|
|||
|
|
_ = InsideDimension.ApplyDimensionDef(InsideDef);
|
|||
|
|
|
|||
|
|
OutsideDimension.OnDimensionLoaded += OutsideDimensionLoaded;
|
|||
|
|
OutsideDimension.OnDimensionLoaded += InsideDimensionLoaded;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Program.Instance.SetFocusedDimension(OutsideDimension.DimensionId);
|
|||
|
|
|
|||
|
|
Clock.AddTick(this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnDestroy()
|
|||
|
|
{
|
|||
|
|
Clock.RemoveTick(this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void StartGame()
|
|||
|
|
{
|
|||
|
|
if (!AllDimensionsLoaded)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
waitStartUI.Hide();
|
|||
|
|
Program.Instance.PutPlayer();
|
|||
|
|
if (OutsideDef.story != null)
|
|||
|
|
{
|
|||
|
|
EventManager.Instance.PlayStory(OutsideDef.story.defName, OutsideDimension.DimensionId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (InsideDef.story != null)
|
|||
|
|
{
|
|||
|
|
EventManager.Instance.PlayStory(InsideDef.story.defName, InsideDimension.DimensionId);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void ReturnMainMenu()
|
|||
|
|
{
|
|||
|
|
EscUI.ReturnMainMenu();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OutsideDimensionLoaded(Dimension dimension)
|
|||
|
|
{
|
|||
|
|
OutsideDimensionsLoaded = true;
|
|||
|
|
StartGame();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void InsideDimensionLoaded(Dimension dimension)
|
|||
|
|
{
|
|||
|
|
InsideDimensionsLoaded = true;
|
|||
|
|
StartGame();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Tick()
|
|||
|
|
{
|
|||
|
|
if(!AllDimensionsLoaded)
|
|||
|
|
return;
|
|||
|
|
if (EventManager.Instance.HasStoryDisplay || TaskCompleted)
|
|||
|
|
return;
|
|||
|
|
MessageManager.Instance.DisplayMessage("清理完毕!", PromptDisplayCategory.ScreenCenterLargeText,
|
|||
|
|
Color.softYellow);
|
|||
|
|
TaskCompleted = true;
|
|||
|
|
Invoke(nameof(ReturnBase), 5);
|
|||
|
|
|
|||
|
|
var player = Program.Instance.FocusedEntity as Character;
|
|||
|
|
if(!player)
|
|||
|
|
return;
|
|||
|
|
Program.Instance.CoinCount += player.Coin.Quantity;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void ReturnBase()
|
|||
|
|
{
|
|||
|
|
Program.Instance.EndPlayGame();
|
|||
|
|
SceneManager.LoadScene("Base");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|