forked from zxl/Frame
1
0
Fork 0
Frame/Assets/Scripts/Procedure/Logic/GameSceneLogicProcedure.cs

77 lines
2.8 KiB
C#
Raw Normal View History

2024-04-04 23:51:14 +08:00
using System.Collections.Generic;
using Game.Pathfinding;
using JetBrains.Annotations;
using UnityEngine;
using System.Linq;
namespace Game
2024-04-03 18:07:05 +08:00
{
2024-04-04 23:51:14 +08:00
[Procedure(ProcedureType.GameSceneLogicProcedure)]
2024-04-03 18:07:05 +08:00
class GameSceneLogicProcedure : ProcedureBase
{
public override void OnEnter()
{
base.OnEnter();
// UniTask.Create(async () =>
// {
// await ResourceManager.Instance.LoadSceneAsync(SceneType.Game.ToString());
// EventManager.Instance.FireNow(this,new LoadingGameSceneFinishEventArgs(true));
// });
2024-04-04 23:51:14 +08:00
2024-04-06 11:59:18 +08:00
// var gameGlobalConfig = GameObject.FindObjectOfType<GameGlobalConfig>();
// BFS<WayPoint> bfs = new BFS<WayPoint>(CreateGraph(gameGlobalConfig));
// var beginNode = GetNode(bfs, new Vector2(-29f,-16.5f));
// var endNode = GetNode(bfs, new Vector2(-15.8f,44.3f));
// var findPath = bfs.FindPath(beginNode, endNode);
// var wayPoints = new List<WayPoint>();
// findPath.GetDatas(wayPoints);
// Debug.Log($"Indices:{string.Join(',',findPath.GetNodes().Select(x=> x.index))}");
// Debug.Log($"Positions:{string.Join(',',findPath.GetNodes().Select(x=> x.data.position))}");
// player.MoveAsync()
2024-04-05 18:12:04 +08:00
// var findPath = Game.bfsManager.FindPath(new Vector2(-29f, -16.5f), new Vector3(-15.8f, 44.3f));
// var wayPoints = new List<WayPoint>();
// findPath.GetDatas(wayPoints);
// Debug.Log($"Indices:{string.Join(',',findPath.GetNodes().Select(x=> x.index))}");
// Debug.Log($"Positions:{string.Join(',',findPath.GetNodes().Select(x=> x.data.position))}");
2024-04-04 23:51:14 +08:00
}
2024-04-04 23:51:14 +08:00
2024-04-06 11:59:18 +08:00
// [CanBeNull]
// private static Node<WayPoint> GetNode(BFS<WayPoint> bfs, Vector2 position)
// {
// float distance = float.MaxValue;
// Node<WayPoint> targetStartNode = null;
// bfs.GetNode(node =>
// {
// var magnitude = ((Vector2)node.data.position - position).magnitude;
// if (magnitude < distance)
// {
// distance = magnitude;
// targetStartNode = node;
// }
//
// return false;
// });
// return targetStartNode;
// }
//
// private Graph<WayPoint> CreateGraph(GameGlobalConfig gameGlobalConfig)
// {
// var graph = new WayPointGraph();
// graph.Initialize(gameGlobalConfig.nodeMaps);
// return graph;
// }
2024-04-03 18:07:05 +08:00
public override void OnLeave()
{
base.OnLeave();
// UIManager.Instance.ShowUI(UIType.GameSceneMainUI);
// ProcedureManager.Instance.ChangeProcedure(ProcedureType.GameSceneLogicProcedure);
}
}
}