unity版本切换为2021.3.22;修复所有语法报错问题
parent
839c9af9e1
commit
64be62f6be
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: boss_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: role_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -4,215 +4,215 @@ using Cysharp.Threading.Tasks;
|
|||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Pathfinding;
|
||||
|
||||
public class Node<T>
|
||||
namespace Game.Pathfinding
|
||||
{
|
||||
public int index { get; private set; }
|
||||
public T data { get; private set; }
|
||||
|
||||
public Node(int index, T data)
|
||||
public class Node<T>
|
||||
{
|
||||
this.index = index;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
public int index { get; private set; }
|
||||
public T data { get; private set; }
|
||||
|
||||
class Edge<T>
|
||||
{
|
||||
public Node<T> from { get; private set; }
|
||||
public Node<T> to { get; private set; }
|
||||
public bool canTranslate { get; private set; }
|
||||
|
||||
public Edge(Node<T> from, Node<T> to, bool canTranslate = true)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.canTranslate = canTranslate;
|
||||
}
|
||||
|
||||
public Node<T> GetAnotherNode(Node<T> node)
|
||||
{
|
||||
return node == this.from ? to : to == node ? from : throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
public class WayPointGraph : Graph<WayPoint>
|
||||
{
|
||||
readonly struct UniqueWayPoint : IEquatable<UniqueWayPoint>
|
||||
{
|
||||
private readonly WayPoint _wayPoint;
|
||||
|
||||
public UniqueWayPoint(WayPoint wayPoint)
|
||||
public Node(int index, T data)
|
||||
{
|
||||
this._wayPoint = wayPoint;
|
||||
}
|
||||
|
||||
public bool Equals(UniqueWayPoint other)
|
||||
{
|
||||
return _wayPoint.position == other._wayPoint.position;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is UniqueWayPoint other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _wayPoint.position.GetHashCode();
|
||||
}
|
||||
|
||||
public static implicit operator WayPoint(UniqueWayPoint uniqueWayPoint)
|
||||
{
|
||||
return uniqueWayPoint._wayPoint;
|
||||
}
|
||||
|
||||
public static implicit operator UniqueWayPoint(WayPoint wayPoint)
|
||||
{
|
||||
return new UniqueWayPoint(wayPoint);
|
||||
this.index = index;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(GameGlobalConfig.NodeMap[] nodeMaps)
|
||||
class Edge<T>
|
||||
{
|
||||
HashSet<UniqueWayPoint> wayPoints = new HashSet<UniqueWayPoint>();
|
||||
foreach (var nodeMap in nodeMaps)
|
||||
public Node<T> from { get; private set; }
|
||||
public Node<T> to { get; private set; }
|
||||
public bool canTranslate { get; private set; }
|
||||
|
||||
public Edge(Node<T> from, Node<T> to, bool canTranslate = true)
|
||||
{
|
||||
wayPoints.Add(new WayPoint(nodeMap.node1));
|
||||
wayPoints.Add(new WayPoint(nodeMap.node2));
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.canTranslate = canTranslate;
|
||||
}
|
||||
|
||||
Dictionary<Vector3, Node<WayPoint>> position2NodeMap = new Dictionary<Vector3, Node<WayPoint>>();
|
||||
_nodes = new Node<WayPoint>[wayPoints.Count];
|
||||
using var enumerator = wayPoints.GetEnumerator();
|
||||
int index = 0;
|
||||
while (enumerator.MoveNext())
|
||||
public Node<T> GetAnotherNode(Node<T> node)
|
||||
{
|
||||
var enumeratorCurrent = (WayPoint)enumerator.Current;
|
||||
var node = new Node<WayPoint>(index, enumeratorCurrent);
|
||||
this._nodes[index] = node;
|
||||
position2NodeMap[enumeratorCurrent.position] = node;
|
||||
index++;
|
||||
return node == this.from ? to : to == node ? from : throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
_edges = new List<Edge<WayPoint>>(nodeMaps.Length);
|
||||
this._connection = new Dictionary<Node<WayPoint>, List<Edge<WayPoint>>>(_edges.Count);
|
||||
|
||||
foreach (var nodeMap in nodeMaps)
|
||||
public class WayPointGraph : Graph<WayPoint>
|
||||
{
|
||||
readonly struct UniqueWayPoint : IEquatable<UniqueWayPoint>
|
||||
{
|
||||
if (position2NodeMap.TryGetValue(nodeMap.node1, out var node1))
|
||||
private readonly WayPoint _wayPoint;
|
||||
|
||||
public UniqueWayPoint(WayPoint wayPoint)
|
||||
{
|
||||
if (position2NodeMap.TryGetValue(nodeMap.node2, out var node2))
|
||||
this._wayPoint = wayPoint;
|
||||
}
|
||||
|
||||
public bool Equals(UniqueWayPoint other)
|
||||
{
|
||||
return _wayPoint.position == other._wayPoint.position;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is UniqueWayPoint other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _wayPoint.position.GetHashCode();
|
||||
}
|
||||
|
||||
public static implicit operator WayPoint(UniqueWayPoint uniqueWayPoint)
|
||||
{
|
||||
return uniqueWayPoint._wayPoint;
|
||||
}
|
||||
|
||||
public static implicit operator UniqueWayPoint(WayPoint wayPoint)
|
||||
{
|
||||
return new UniqueWayPoint(wayPoint);
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(GameGlobalConfig.NodeMap[] nodeMaps)
|
||||
{
|
||||
HashSet<UniqueWayPoint> wayPoints = new HashSet<UniqueWayPoint>();
|
||||
foreach (var nodeMap in nodeMaps)
|
||||
{
|
||||
wayPoints.Add(new WayPoint(nodeMap.node1));
|
||||
wayPoints.Add(new WayPoint(nodeMap.node2));
|
||||
}
|
||||
|
||||
Dictionary<Vector3, Node<WayPoint>> position2NodeMap = new Dictionary<Vector3, Node<WayPoint>>();
|
||||
_nodes = new Node<WayPoint>[wayPoints.Count];
|
||||
using var enumerator = wayPoints.GetEnumerator();
|
||||
int index = 0;
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
var enumeratorCurrent = (WayPoint)enumerator.Current;
|
||||
var node = new Node<WayPoint>(index, enumeratorCurrent);
|
||||
this._nodes[index] = node;
|
||||
position2NodeMap[enumeratorCurrent.position] = node;
|
||||
index++;
|
||||
}
|
||||
|
||||
_edges = new List<Edge<WayPoint>>(nodeMaps.Length);
|
||||
this._connection = new Dictionary<Node<WayPoint>, List<Edge<WayPoint>>>(_edges.Count);
|
||||
|
||||
foreach (var nodeMap in nodeMaps)
|
||||
{
|
||||
if (position2NodeMap.TryGetValue(nodeMap.node1, out var node1))
|
||||
{
|
||||
var edge = new Edge<WayPoint>(node1, node2);
|
||||
_edges.Add(edge);
|
||||
if (!this._connection.TryGetValue(node1, out var list1))
|
||||
if (position2NodeMap.TryGetValue(nodeMap.node2, out var node2))
|
||||
{
|
||||
this._connection[node1] = list1 = new List<Edge<WayPoint>>();
|
||||
}
|
||||
var edge = new Edge<WayPoint>(node1, node2);
|
||||
_edges.Add(edge);
|
||||
if (!this._connection.TryGetValue(node1, out var list1))
|
||||
{
|
||||
this._connection[node1] = list1 = new List<Edge<WayPoint>>();
|
||||
}
|
||||
|
||||
list1.Add(edge);
|
||||
if (!this._connection.TryGetValue(node2, out var list2))
|
||||
{
|
||||
this._connection[node2] = list2 = new List<Edge<WayPoint>>();
|
||||
}
|
||||
list1.Add(edge);
|
||||
if (!this._connection.TryGetValue(node2, out var list2))
|
||||
{
|
||||
this._connection[node2] = list2 = new List<Edge<WayPoint>>();
|
||||
}
|
||||
|
||||
list2.Add(edge);
|
||||
list2.Add(edge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Graph<T>
|
||||
{
|
||||
private protected Node<T>[] _nodes;
|
||||
private protected List<Edge<T>> _edges;
|
||||
private protected Dictionary<Node<T>, List<Edge<T>>> _connection;
|
||||
|
||||
internal Node<T> GetNode(int index)
|
||||
public class Graph<T>
|
||||
{
|
||||
if (index < 0 || index >= this._nodes.Length)
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Index is {index}");
|
||||
}
|
||||
private protected Node<T>[] _nodes;
|
||||
private protected List<Edge<T>> _edges;
|
||||
private protected Dictionary<Node<T>, List<Edge<T>>> _connection;
|
||||
|
||||
return this._nodes[index];
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
internal Node<T> GetNode(Predicate<Node<T>> predicate)
|
||||
{
|
||||
foreach (var node in this._nodes)
|
||||
internal Node<T> GetNode(int index)
|
||||
{
|
||||
if (predicate(node))
|
||||
if (index < 0 || index >= this._nodes.Length)
|
||||
{
|
||||
return node;
|
||||
throw new IndexOutOfRangeException($"Index is {index}");
|
||||
}
|
||||
|
||||
return this._nodes[index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
internal IReadOnlyList<Edge<T>> GetNeighbours(Node<T> node)
|
||||
{
|
||||
if (this._connection.TryGetValue(node, out var edges))
|
||||
[CanBeNull]
|
||||
internal Node<T> GetNode(Predicate<Node<T>> predicate)
|
||||
{
|
||||
return edges;
|
||||
foreach (var node in this._nodes)
|
||||
{
|
||||
if (predicate(node))
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
throw new ArgumentException($"GetNeighbours have error ! the id is {node.index}");
|
||||
}
|
||||
}
|
||||
|
||||
public class BFS<T>
|
||||
{
|
||||
private Graph<T> _graph;
|
||||
private List<int> _closeList = new List<int>();
|
||||
private Queue<int> _openList = new Queue<int>();
|
||||
private Dictionary<Node<T>, Node<T>> _nodeMap = new Dictionary<Node<T>, Node<T>>();
|
||||
private List<int> ids = new List<int>();
|
||||
|
||||
public BFS(Graph<T> graph)
|
||||
{
|
||||
this._graph = graph;
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
public Node<T> GetNode(Predicate<Node<T>> predicate)
|
||||
{
|
||||
return _graph.GetNode(predicate);
|
||||
}
|
||||
|
||||
public Path<T> FindPath(Node<T> begin, Node<T> end)
|
||||
{
|
||||
Debug.Log($"begin is {begin.index}, end is {end.index}");
|
||||
if (begin == null)
|
||||
throw new NullReferenceException("begin");
|
||||
if (end == null)
|
||||
throw new NullReferenceException("end");
|
||||
_openList.Clear();
|
||||
_closeList.Clear();
|
||||
_nodeMap.Clear();
|
||||
this.ids.Clear();
|
||||
|
||||
_openList.Enqueue(begin.index);
|
||||
while (this._openList.Count > 0)
|
||||
internal IReadOnlyList<Edge<T>> GetNeighbours(Node<T> node)
|
||||
{
|
||||
var nodeIndex = this._openList.Dequeue();
|
||||
var currNode = this._graph.GetNode(nodeIndex);
|
||||
if (currNode.index == end.index)
|
||||
break;
|
||||
_closeList.Add(currNode.index);
|
||||
Search(currNode);
|
||||
if (this._connection.TryGetValue(node, out var edges))
|
||||
{
|
||||
return edges;
|
||||
}
|
||||
|
||||
throw new ArgumentException($"GetNeighbours have error ! the id is {node.index}");
|
||||
}
|
||||
}
|
||||
|
||||
public class BFS<T>
|
||||
{
|
||||
private Graph<T> _graph;
|
||||
private List<int> _closeList = new List<int>();
|
||||
private Queue<int> _openList = new Queue<int>();
|
||||
private Dictionary<Node<T>, Node<T>> _nodeMap = new Dictionary<Node<T>, Node<T>>();
|
||||
private List<int> ids = new List<int>();
|
||||
|
||||
public BFS(Graph<T> graph)
|
||||
{
|
||||
this._graph = graph;
|
||||
}
|
||||
|
||||
Path<T> path = new Path<T>();
|
||||
path.AddNode(new PathNode<T>(end.index, end.data));
|
||||
this.ids.Clear();
|
||||
[CanBeNull]
|
||||
public Node<T> GetNode(Predicate<Node<T>> predicate)
|
||||
{
|
||||
return _graph.GetNode(predicate);
|
||||
}
|
||||
|
||||
bool isTrue = true;
|
||||
public Path<T> FindPath(Node<T> begin, Node<T> end)
|
||||
{
|
||||
Debug.Log($"begin is {begin.index}, end is {end.index}");
|
||||
if (begin == null)
|
||||
throw new NullReferenceException("begin");
|
||||
if (end == null)
|
||||
throw new NullReferenceException("end");
|
||||
_openList.Clear();
|
||||
_closeList.Clear();
|
||||
_nodeMap.Clear();
|
||||
this.ids.Clear();
|
||||
|
||||
_openList.Enqueue(begin.index);
|
||||
while (this._openList.Count > 0)
|
||||
{
|
||||
var nodeIndex = this._openList.Dequeue();
|
||||
var currNode = this._graph.GetNode(nodeIndex);
|
||||
if (currNode.index == end.index)
|
||||
break;
|
||||
_closeList.Add(currNode.index);
|
||||
Search(currNode);
|
||||
}
|
||||
|
||||
Path<T> path = new Path<T>();
|
||||
path.AddNode(new PathNode<T>(end.index, end.data));
|
||||
this.ids.Clear();
|
||||
|
||||
bool isTrue = true;
|
||||
// UniTask.Create(async () =>
|
||||
// {
|
||||
// await UniTask.Delay(5000);
|
||||
|
@ -222,94 +222,95 @@ public class BFS<T>
|
|||
// Debug.LogError("没找到路径卡死了,强制跳出的");
|
||||
// }
|
||||
// }).Forget();
|
||||
Node<T> node = end;
|
||||
while (isTrue)
|
||||
{
|
||||
if (this._nodeMap.TryGetValue(node, out node))
|
||||
Node<T> node = end;
|
||||
while (isTrue)
|
||||
{
|
||||
if (!this.ids.Contains(node.index))
|
||||
if (this._nodeMap.TryGetValue(node, out node))
|
||||
{
|
||||
this.ids.Add(node.index);
|
||||
path.AddNode(new PathNode<T>(node.index, node.data));
|
||||
if (!this.ids.Contains(node.index))
|
||||
{
|
||||
this.ids.Add(node.index);
|
||||
path.AddNode(new PathNode<T>(node.index, node.data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node == null || node == begin)
|
||||
{
|
||||
if (node == null || node == begin)
|
||||
{
|
||||
// Debug.Log("结束了");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
path.Reverse();
|
||||
return path;
|
||||
}
|
||||
|
||||
path.Reverse();
|
||||
return path;
|
||||
}
|
||||
|
||||
private void Search(Node<T> node)
|
||||
{
|
||||
var readOnlyList = this._graph.GetNeighbours(node);
|
||||
foreach (var edge in readOnlyList)
|
||||
private void Search(Node<T> node)
|
||||
{
|
||||
if (!edge.canTranslate)
|
||||
continue;
|
||||
Node<T> another = edge.GetAnotherNode(node);
|
||||
if (!this._nodeMap.ContainsKey(another))
|
||||
var readOnlyList = this._graph.GetNeighbours(node);
|
||||
foreach (var edge in readOnlyList)
|
||||
{
|
||||
_nodeMap[another] = node;
|
||||
}
|
||||
|
||||
if (!this._closeList.Contains(another.index))
|
||||
{
|
||||
if (!this._openList.Contains(another.index))
|
||||
if (!edge.canTranslate)
|
||||
continue;
|
||||
Node<T> another = edge.GetAnotherNode(node);
|
||||
if (!this._nodeMap.ContainsKey(another))
|
||||
{
|
||||
_openList.Enqueue(another.index);
|
||||
_nodeMap[another] = node;
|
||||
}
|
||||
|
||||
if (!this._closeList.Contains(another.index))
|
||||
{
|
||||
if (!this._openList.Contains(another.index))
|
||||
{
|
||||
_openList.Enqueue(another.index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Path<T>
|
||||
{
|
||||
private readonly List<PathNode<T>> _pathNodes = new List<PathNode<T>>();
|
||||
|
||||
public void Reverse()
|
||||
public class Path<T>
|
||||
{
|
||||
this._pathNodes.Reverse();
|
||||
}
|
||||
private readonly List<PathNode<T>> _pathNodes = new List<PathNode<T>>();
|
||||
|
||||
public void AddNode(PathNode<T> node)
|
||||
{
|
||||
if (this._pathNodes.Contains(node))
|
||||
public void Reverse()
|
||||
{
|
||||
throw new ArgumentException($"{node.index}");
|
||||
this._pathNodes.Reverse();
|
||||
}
|
||||
|
||||
this._pathNodes.Add(node);
|
||||
}
|
||||
|
||||
public IReadOnlyList<PathNode<T>> GetNodes()
|
||||
{
|
||||
return this._pathNodes;
|
||||
}
|
||||
|
||||
public void GetDatas(IList<T> result)
|
||||
{
|
||||
foreach (var pathNode in this._pathNodes)
|
||||
public void AddNode(PathNode<T> node)
|
||||
{
|
||||
result.Add(pathNode.data);
|
||||
if (this._pathNodes.Contains(node))
|
||||
{
|
||||
throw new ArgumentException($"{node.index}");
|
||||
}
|
||||
|
||||
this._pathNodes.Add(node);
|
||||
}
|
||||
|
||||
public IReadOnlyList<PathNode<T>> GetNodes()
|
||||
{
|
||||
return this._pathNodes;
|
||||
}
|
||||
|
||||
public void GetDatas(IList<T> result)
|
||||
{
|
||||
foreach (var pathNode in this._pathNodes)
|
||||
{
|
||||
result.Add(pathNode.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PathNode<T>
|
||||
{
|
||||
public int index { get; private set; }
|
||||
public T data { get; private set; }
|
||||
|
||||
public PathNode(int index, T data)
|
||||
public class PathNode<T>
|
||||
{
|
||||
this.index = index;
|
||||
this.data = data;
|
||||
public int index { get; private set; }
|
||||
public T data { get; private set; }
|
||||
|
||||
public PathNode(int index, T data)
|
||||
{
|
||||
this.index = index;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,25 +4,25 @@ using Game.Player;
|
|||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Pathfinding;
|
||||
|
||||
public interface IBFSManager
|
||||
namespace Game.Pathfinding
|
||||
{
|
||||
List<WayPoint> FindPath(Vector2 startPos, Vector2 endPos);
|
||||
List<WayPoint> FindPath(Vector2 endPos);
|
||||
|
||||
Node<WayPoint> GetNode(Vector2 position);
|
||||
// void Test(Vector2 position);
|
||||
}
|
||||
|
||||
public class BFSManager : ManagerBase, IBFSManager
|
||||
{
|
||||
private BFS<WayPoint> bfs;
|
||||
private IPlayerManager _playerManager;
|
||||
|
||||
protected override void OnInit()
|
||||
public interface IBFSManager
|
||||
{
|
||||
base.OnInit();
|
||||
List<WayPoint> FindPath(Vector2 startPos, Vector2 endPos);
|
||||
List<WayPoint> FindPath(Vector2 endPos);
|
||||
|
||||
Node<WayPoint> GetNode(Vector2 position);
|
||||
// void Test(Vector2 position);
|
||||
}
|
||||
|
||||
public class BFSManager : ManagerBase, IBFSManager
|
||||
{
|
||||
private BFS<WayPoint> bfs;
|
||||
private IPlayerManager _playerManager;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
|
||||
// var gameGlobalConfig = GameObject.FindObjectOfType<GameGlobalConfig>();
|
||||
// bfs = new BFS<WayPoint>(this.CreateGraph(gameGlobalConfig));
|
||||
|
@ -34,42 +34,42 @@ public class BFSManager : ManagerBase, IBFSManager
|
|||
// Debug.Log($"Indices:{string.Join(',', findPath.GetNodes().Select(x => x.index))}");
|
||||
// Debug.Log($"Positions:{string.Join(',', findPath.GetNodes().Select(x => x.data.position))}");
|
||||
|
||||
this._playerManager = Game.playerManager;
|
||||
}
|
||||
|
||||
protected override void OnUpdate(float dateTime)
|
||||
{
|
||||
base.OnUpdate(dateTime);
|
||||
if (this.bfs == null)
|
||||
{
|
||||
var gameGlobalConfig = GameObject.FindObjectOfType<GameGlobalConfig>();
|
||||
bfs = new BFS<WayPoint>(this.CreateGraph(gameGlobalConfig));
|
||||
this._playerManager = Game.playerManager;
|
||||
}
|
||||
}
|
||||
|
||||
public List<WayPoint> FindPath(Vector2 startPos, Vector2 endPos)
|
||||
{
|
||||
var beginNode = GetNode(bfs, startPos);
|
||||
var endNode = GetNode(bfs, endPos);
|
||||
var findPath = bfs.FindPath(beginNode, endNode);
|
||||
var wayPoints = new List<WayPoint>();
|
||||
findPath.GetDatas(wayPoints);
|
||||
return wayPoints;
|
||||
}
|
||||
protected override void OnUpdate(float dateTime)
|
||||
{
|
||||
base.OnUpdate(dateTime);
|
||||
if (this.bfs == null)
|
||||
{
|
||||
var gameGlobalConfig = GameObject.FindObjectOfType<GameGlobalConfig>();
|
||||
bfs = new BFS<WayPoint>(this.CreateGraph(gameGlobalConfig));
|
||||
}
|
||||
}
|
||||
|
||||
public List<WayPoint> FindPath(Vector2 endPos)
|
||||
{
|
||||
var player = this._playerManager.currentPlayer;
|
||||
var pos = player.self.transform.position;
|
||||
var startPos = new Vector2(pos.x, pos.y);
|
||||
var beginNode = GetNode(bfs, startPos);
|
||||
var endNode = GetNode(bfs, endPos);
|
||||
public List<WayPoint> FindPath(Vector2 startPos, Vector2 endPos)
|
||||
{
|
||||
var beginNode = GetNode(bfs, startPos);
|
||||
var endNode = GetNode(bfs, endPos);
|
||||
var findPath = bfs.FindPath(beginNode, endNode);
|
||||
var wayPoints = new List<WayPoint>();
|
||||
findPath.GetDatas(wayPoints);
|
||||
return wayPoints;
|
||||
}
|
||||
|
||||
public List<WayPoint> FindPath(Vector2 endPos)
|
||||
{
|
||||
var player = this._playerManager.currentPlayer;
|
||||
var pos = player.self.transform.position;
|
||||
var startPos = new Vector2(pos.x, pos.y);
|
||||
var beginNode = GetNode(bfs, startPos);
|
||||
var endNode = GetNode(bfs, endPos);
|
||||
// UnityEngine.Debug.Log($"frome {beginNode.index} to {endNode.index} ");
|
||||
var findPath = bfs.FindPath(beginNode, endNode);
|
||||
var wayPoints = new List<WayPoint>();
|
||||
findPath.GetDatas(wayPoints);
|
||||
return wayPoints;
|
||||
}
|
||||
var findPath = bfs.FindPath(beginNode, endNode);
|
||||
var wayPoints = new List<WayPoint>();
|
||||
findPath.GetDatas(wayPoints);
|
||||
return wayPoints;
|
||||
}
|
||||
|
||||
// public void Test(Vector2 endPos)
|
||||
// {
|
||||
|
@ -81,48 +81,49 @@ public class BFSManager : ManagerBase, IBFSManager
|
|||
//// UnityEngine.Debug.Log($"frome {beginNode.index} to {endNode.index} ");
|
||||
// }
|
||||
|
||||
[CanBeNull]
|
||||
public Node<WayPoint> GetNode(Vector2 position)
|
||||
{
|
||||
float distance = float.MaxValue;
|
||||
Node<WayPoint> targetStartNode = null;
|
||||
bfs.GetNode(node =>
|
||||
[CanBeNull]
|
||||
public Node<WayPoint> GetNode(Vector2 position)
|
||||
{
|
||||
var magnitude = ((Vector2)node.data.position - position).magnitude;
|
||||
if (magnitude < distance)
|
||||
float distance = float.MaxValue;
|
||||
Node<WayPoint> targetStartNode = null;
|
||||
bfs.GetNode(node =>
|
||||
{
|
||||
distance = magnitude;
|
||||
targetStartNode = node;
|
||||
}
|
||||
var magnitude = ((Vector2)node.data.position - position).magnitude;
|
||||
if (magnitude < distance)
|
||||
{
|
||||
distance = magnitude;
|
||||
targetStartNode = node;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
return targetStartNode;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return targetStartNode;
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
private static Node<WayPoint> GetNode(BFS<WayPoint> bfs, Vector2 position)
|
||||
{
|
||||
float distance = float.MaxValue;
|
||||
Node<WayPoint> targetStartNode = null;
|
||||
bfs.GetNode(node =>
|
||||
[CanBeNull]
|
||||
private static Node<WayPoint> GetNode(BFS<WayPoint> bfs, Vector2 position)
|
||||
{
|
||||
var magnitude = ((Vector2)node.data.position - position).magnitude;
|
||||
if (magnitude < distance)
|
||||
float distance = float.MaxValue;
|
||||
Node<WayPoint> targetStartNode = null;
|
||||
bfs.GetNode(node =>
|
||||
{
|
||||
distance = magnitude;
|
||||
targetStartNode = node;
|
||||
}
|
||||
var magnitude = ((Vector2)node.data.position - position).magnitude;
|
||||
if (magnitude < distance)
|
||||
{
|
||||
distance = magnitude;
|
||||
targetStartNode = node;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
return targetStartNode;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return targetStartNode;
|
||||
}
|
||||
|
||||
private Graph<WayPoint> CreateGraph(GameGlobalConfig gameGlobalConfig)
|
||||
{
|
||||
var graph = new WayPointGraph();
|
||||
graph.Initialize(gameGlobalConfig.nodeMaps);
|
||||
return graph;
|
||||
private Graph<WayPoint> CreateGraph(GameGlobalConfig gameGlobalConfig)
|
||||
{
|
||||
var graph = new WayPointGraph();
|
||||
graph.Initialize(gameGlobalConfig.nodeMaps);
|
||||
return graph;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Game.Pathfinding;
|
||||
|
||||
public class WayPoint
|
||||
namespace Game.Pathfinding
|
||||
{
|
||||
public Vector3 position { get; private set; }
|
||||
|
||||
public WayPoint(Vector3 position)
|
||||
public class WayPoint
|
||||
{
|
||||
this.position = position;
|
||||
public Vector3 position { get; private set; }
|
||||
|
||||
public WayPoint(Vector3 position)
|
||||
{
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,31 +8,31 @@ using Game.Spine;
|
|||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Boss;
|
||||
|
||||
[RequireComponent(typeof(SpineAnimator))]
|
||||
public class BossInfo : MonoBehaviour
|
||||
namespace Game.Boss
|
||||
{
|
||||
[SerializeField] [ReadOnly] private IBoss _boss;
|
||||
[SerializeField] private float speed = 1f;
|
||||
private static readonly int _kill = Animator.StringToHash("Kill");
|
||||
[SerializeField] private Vector2 _birthPoint;
|
||||
|
||||
private SpineAnimator _animator;
|
||||
|
||||
public Vector2 birthPoint => this._birthPoint;
|
||||
|
||||
private void Awake()
|
||||
[RequireComponent(typeof(SpineAnimator))]
|
||||
public class BossInfo : MonoBehaviour
|
||||
{
|
||||
this._animator = this.GetComponent<SpineAnimator>();
|
||||
}
|
||||
[SerializeField] [ReadOnly] private IBoss _boss;
|
||||
[SerializeField] private float speed = 1f;
|
||||
private static readonly int _kill = Animator.StringToHash("Kill");
|
||||
[SerializeField] private Vector2 _birthPoint;
|
||||
|
||||
public void SetBoss(IBoss boss)
|
||||
{
|
||||
this._boss = boss;
|
||||
this.gameObject.name = this._boss.name;
|
||||
transform.position = _birthPoint;
|
||||
}
|
||||
private SpineAnimator _animator;
|
||||
|
||||
public Vector2 birthPoint => this._birthPoint;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this._animator = this.GetComponent<SpineAnimator>();
|
||||
}
|
||||
|
||||
public void SetBoss(IBoss boss)
|
||||
{
|
||||
this._boss = boss;
|
||||
this.gameObject.name = this._boss.name;
|
||||
transform.position = _birthPoint;
|
||||
}
|
||||
|
||||
// public async UniTask<bool> MoveAsync(List<WayPoint> wayPoint, Vector2 endPos, CancellationToken token)
|
||||
// {
|
||||
|
@ -48,61 +48,62 @@ public class BossInfo : MonoBehaviour
|
|||
// return true;
|
||||
// }
|
||||
|
||||
public async UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token)
|
||||
{
|
||||
this._animator.PlayAni("walk", true);
|
||||
// enter this room
|
||||
foreach (var point in wayPoint)
|
||||
public async UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token)
|
||||
{
|
||||
await this.MoveAsync(point.position, token);
|
||||
}
|
||||
this._animator.PlayAni("walk", true);
|
||||
// enter this room
|
||||
foreach (var point in wayPoint)
|
||||
{
|
||||
await this.MoveAsync(point.position, token);
|
||||
}
|
||||
|
||||
this._animator.PlayAni("idle", true);
|
||||
this._animator.PlayAni("idle", true);
|
||||
|
||||
// enter room a point
|
||||
// enter room a point
|
||||
// await this.MoveAsync(endPos, token);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async UniTask MoveAsync(Vector2 endPos, CancellationToken token)
|
||||
{
|
||||
var position = this.transform.position;
|
||||
var distance = Vector3.Distance(position, endPos);
|
||||
var time = distance / this.speed;
|
||||
|
||||
CheckIsNeedTurn(position, endPos);
|
||||
async UniTask MoveAsync(Vector2 endPos, CancellationToken token)
|
||||
{
|
||||
var position = this.transform.position;
|
||||
var distance = Vector3.Distance(position, endPos);
|
||||
var time = distance / this.speed;
|
||||
|
||||
this.transform.DOMove(endPos, time).SetEase(Ease.Linear);
|
||||
float delayTimeSpan = time * 1000;
|
||||
await UniTask.Delay((int)delayTimeSpan); // (int)delayTimeSpan
|
||||
CheckIsNeedTurn(position, endPos);
|
||||
|
||||
this.transform.DOMove(endPos, time).SetEase(Ease.Linear);
|
||||
float delayTimeSpan = time * 1000;
|
||||
await UniTask.Delay((int)delayTimeSpan); // (int)delayTimeSpan
|
||||
|
||||
// Debug.Log($"time is {time}, await time is {delayTimeSpan}");
|
||||
}
|
||||
|
||||
public async UniTask Kill(CancellationToken token)
|
||||
{
|
||||
this._animator.PlayAni("atk");
|
||||
await UniTask.Delay(500);
|
||||
this._animator.PlayAni("idle", true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this._animator = null;
|
||||
this._boss = null;
|
||||
GameObject.DestroyImmediate(this.gameObject);
|
||||
}
|
||||
|
||||
void CheckIsNeedTurn(Vector2 str, Vector2 end)
|
||||
{
|
||||
if (str.x > end.x)
|
||||
{
|
||||
transform.localEulerAngles = new Vector3(0, 180, 0);
|
||||
}
|
||||
else if (str.x < end.x)
|
||||
|
||||
public async UniTask Kill(CancellationToken token)
|
||||
{
|
||||
transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
this._animator.PlayAni("atk");
|
||||
await UniTask.Delay(500);
|
||||
this._animator.PlayAni("idle", true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this._animator = null;
|
||||
this._boss = null;
|
||||
GameObject.DestroyImmediate(this.gameObject);
|
||||
}
|
||||
|
||||
void CheckIsNeedTurn(Vector2 str, Vector2 end)
|
||||
{
|
||||
if (str.x > end.x)
|
||||
{
|
||||
transform.localEulerAngles = new Vector3(0, 180, 0);
|
||||
}
|
||||
else if (str.x < end.x)
|
||||
{
|
||||
transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,87 +6,88 @@ using Game.Player;
|
|||
using Game.Room;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Boss;
|
||||
|
||||
public interface IBoss
|
||||
namespace Game.Boss
|
||||
{
|
||||
string name { get; }
|
||||
GameObject self { get; }
|
||||
BossData data { get; }
|
||||
BossInfo info { get; }
|
||||
IRoom room { get; }
|
||||
bool isMoving { get; }
|
||||
void SetGameObject(GameObject gameObject, IRoom room);
|
||||
public interface IBoss
|
||||
{
|
||||
string name { get; }
|
||||
GameObject self { get; }
|
||||
BossData data { get; }
|
||||
BossInfo info { get; }
|
||||
IRoom room { get; }
|
||||
bool isMoving { get; }
|
||||
void SetGameObject(GameObject gameObject, IRoom room);
|
||||
|
||||
UniTask<float> WaitMoveRoomAndKillAsync(CancellationToken token);
|
||||
UniTask<float> WaitMoveRoomAndKillAsync(CancellationToken token);
|
||||
|
||||
// UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token);
|
||||
void Init();
|
||||
void Dispose();
|
||||
}
|
||||
|
||||
public class BossData
|
||||
{
|
||||
}
|
||||
|
||||
public class Boss : IBoss
|
||||
{
|
||||
private string _name;
|
||||
private GameObject _self;
|
||||
private IRoom _room;
|
||||
private bool _isMoving;
|
||||
private BossInfo _info;
|
||||
|
||||
public string name => this._name;
|
||||
|
||||
public GameObject self => this._self;
|
||||
|
||||
public BossData data { get; }
|
||||
|
||||
public BossInfo info => this._info;
|
||||
|
||||
public IRoom room => this._room;
|
||||
|
||||
public bool isMoving => this._isMoving;
|
||||
|
||||
public void SetGameObject(GameObject gameObject, IRoom room)
|
||||
{
|
||||
this._self = gameObject;
|
||||
this._name = room.roomName;
|
||||
this._room = room;
|
||||
this._info = gameObject.GetComponent<BossInfo>();
|
||||
this._info.SetBoss(this);
|
||||
this._isMoving = true;
|
||||
void Init();
|
||||
void Dispose();
|
||||
}
|
||||
|
||||
public async UniTask<float> WaitMoveRoomAndKillAsync(CancellationToken token)
|
||||
public class BossData
|
||||
{
|
||||
var wayPoints = Game.bfsManager.FindPath(this._info.birthPoint, _room.roomInfo.room_Center);
|
||||
await this.MoveAsync(wayPoints, token);
|
||||
Debug.Log("Move finish !!!");
|
||||
await this._info.Kill(token);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private async UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token)
|
||||
public class Boss : IBoss
|
||||
{
|
||||
if (!this._isMoving) return false;
|
||||
private string _name;
|
||||
private GameObject _self;
|
||||
private IRoom _room;
|
||||
private bool _isMoving;
|
||||
private BossInfo _info;
|
||||
|
||||
_isMoving = false;
|
||||
public string name => this._name;
|
||||
|
||||
public GameObject self => this._self;
|
||||
|
||||
public BossData data { get; }
|
||||
|
||||
public BossInfo info => this._info;
|
||||
|
||||
public IRoom room => this._room;
|
||||
|
||||
public bool isMoving => this._isMoving;
|
||||
|
||||
public void SetGameObject(GameObject gameObject, IRoom room)
|
||||
{
|
||||
this._self = gameObject;
|
||||
this._name = room.roomName;
|
||||
this._room = room;
|
||||
this._info = gameObject.GetComponent<BossInfo>();
|
||||
this._info.SetBoss(this);
|
||||
this._isMoving = true;
|
||||
}
|
||||
|
||||
public async UniTask<float> WaitMoveRoomAndKillAsync(CancellationToken token)
|
||||
{
|
||||
var wayPoints = Game.bfsManager.FindPath(this._info.birthPoint, _room.roomInfo.room_Center);
|
||||
await this.MoveAsync(wayPoints, token);
|
||||
Debug.Log("Move finish !!!");
|
||||
await this._info.Kill(token);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private async UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token)
|
||||
{
|
||||
if (!this._isMoving) return false;
|
||||
|
||||
_isMoving = false;
|
||||
// var endPos = this._room.roomInfo.GetJoinPosition();
|
||||
// await this._info.MoveAsync(wayPoint, endPos, token);
|
||||
|
||||
await this._info.MoveAsync(wayPoint, token);
|
||||
this._isMoving = true;
|
||||
return true;
|
||||
}
|
||||
await this._info.MoveAsync(wayPoint, token);
|
||||
this._isMoving = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
}
|
||||
public virtual void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
this._info.Dispose();
|
||||
public virtual void Dispose()
|
||||
{
|
||||
this._info.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,53 +4,54 @@ using Cysharp.Threading.Tasks;
|
|||
using Game.Room;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Boss;
|
||||
|
||||
public interface IBossManager
|
||||
namespace Game.Boss
|
||||
{
|
||||
IReadOnlyList<IBoss> bosses { get; }
|
||||
|
||||
UniTask MoveToKillPlayerAsync(IReadOnlyList<IRoom> rooms, CancellationToken token);
|
||||
void DeleteBoss();
|
||||
}
|
||||
|
||||
public class BossManager : ManagerBase, IBossManager
|
||||
{
|
||||
private List<IBoss> _bosses;
|
||||
|
||||
public IReadOnlyList<IBoss> bosses => this._bosses;
|
||||
|
||||
public async UniTask MoveToKillPlayerAsync(IReadOnlyList<IRoom> rooms, CancellationToken token)
|
||||
public interface IBossManager
|
||||
{
|
||||
this._bosses = new List<IBoss>();
|
||||
foreach (var room in rooms)
|
||||
{
|
||||
IBoss boss = new Boss();
|
||||
var gameObject = Game.resourceManager.LoadGameObjectSync("boss1");
|
||||
boss.SetGameObject(gameObject, room);
|
||||
boss.Init();
|
||||
_bosses.Add(boss);
|
||||
}
|
||||
IReadOnlyList<IBoss> bosses { get; }
|
||||
|
||||
List<UniTask> uniTasks = new List<UniTask>();
|
||||
foreach (var boss in this._bosses)
|
||||
{
|
||||
var uniTask = boss.WaitMoveRoomAndKillAsync(token);
|
||||
uniTasks.Add(uniTask);
|
||||
await UniTask.Delay(100);
|
||||
}
|
||||
|
||||
await UniTask.WhenAll(uniTasks);
|
||||
UniTask MoveToKillPlayerAsync(IReadOnlyList<IRoom> rooms, CancellationToken token);
|
||||
void DeleteBoss();
|
||||
}
|
||||
|
||||
|
||||
public void DeleteBoss()
|
||||
public class BossManager : ManagerBase, IBossManager
|
||||
{
|
||||
foreach (var boss in this._bosses)
|
||||
private List<IBoss> _bosses;
|
||||
|
||||
public IReadOnlyList<IBoss> bosses => this._bosses;
|
||||
|
||||
public async UniTask MoveToKillPlayerAsync(IReadOnlyList<IRoom> rooms, CancellationToken token)
|
||||
{
|
||||
boss.Dispose();
|
||||
this._bosses = new List<IBoss>();
|
||||
foreach (var room in rooms)
|
||||
{
|
||||
IBoss boss = new Boss();
|
||||
var gameObject = Game.resourceManager.LoadGameObjectSync("boss1");
|
||||
boss.SetGameObject(gameObject, room);
|
||||
boss.Init();
|
||||
_bosses.Add(boss);
|
||||
}
|
||||
|
||||
List<UniTask> uniTasks = new List<UniTask>();
|
||||
foreach (var boss in this._bosses)
|
||||
{
|
||||
var uniTask = boss.WaitMoveRoomAndKillAsync(token);
|
||||
uniTasks.Add(uniTask);
|
||||
await UniTask.Delay(100);
|
||||
}
|
||||
|
||||
await UniTask.WhenAll(uniTasks);
|
||||
}
|
||||
|
||||
this._bosses.Clear();
|
||||
|
||||
public void DeleteBoss()
|
||||
{
|
||||
foreach (var boss in this._bosses)
|
||||
{
|
||||
boss.Dispose();
|
||||
}
|
||||
|
||||
this._bosses.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,18 @@
|
|||
namespace Game;
|
||||
|
||||
/// <summary>
|
||||
/// boss开始行动了
|
||||
/// </summary>
|
||||
public class BossStartMoveEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(BossStartMoveEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public bool isMoveing { get; }
|
||||
|
||||
public BossStartMoveEventArgs(bool isMoveing)
|
||||
/// <summary>
|
||||
/// boss开始行动了
|
||||
/// </summary>
|
||||
public class BossStartMoveEventArgs : GameEventArgs
|
||||
{
|
||||
this.isMoveing = isMoveing;
|
||||
public static readonly int EventId = typeof(BossStartMoveEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public bool isMoveing { get; }
|
||||
|
||||
public BossStartMoveEventArgs(bool isMoveing)
|
||||
{
|
||||
this.isMoveing = isMoveing;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,17 @@
|
|||
using Game.Player;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class InitCurrentPlayerDataEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(InitCurrentPlayerDataEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
|
||||
public InitCurrentPlayerDataEventArgs(IPlayer player)
|
||||
public class InitCurrentPlayerDataEventArgs : GameEventArgs
|
||||
{
|
||||
this.player = player;
|
||||
public static readonly int EventId = typeof(InitCurrentPlayerDataEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
|
||||
public InitCurrentPlayerDataEventArgs(IPlayer player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
namespace Game;
|
||||
|
||||
public class InputNameFinishEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(InputNameFinishEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public string playerName { get; }
|
||||
|
||||
public InputNameFinishEventArgs(string name)
|
||||
public class InputNameFinishEventArgs : GameEventArgs
|
||||
{
|
||||
this.playerName = name;
|
||||
public static readonly int EventId = typeof(InputNameFinishEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public string playerName { get; }
|
||||
|
||||
public InputNameFinishEventArgs(string name)
|
||||
{
|
||||
this.playerName = name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
namespace Game;
|
||||
|
||||
public class InputObjectFinishEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(InputObjectFinishEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public object data { get; }
|
||||
|
||||
public InputObjectFinishEventArgs(object data)
|
||||
public class InputObjectFinishEventArgs : GameEventArgs
|
||||
{
|
||||
this.data = data;
|
||||
public static readonly int EventId = typeof(InputObjectFinishEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public object data { get; }
|
||||
|
||||
public InputObjectFinishEventArgs(object data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,20 @@
|
|||
using System.Collections.Generic;
|
||||
using Game.Player;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class JinBeiSettlementEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(JinBeiSettlementEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public List<IPlayer> players { get; }
|
||||
public float jinbei { get; }
|
||||
|
||||
public JinBeiSettlementEventArgs(List<IPlayer> players, float jinbei)
|
||||
public class JinBeiSettlementEventArgs : GameEventArgs
|
||||
{
|
||||
this.players = players;
|
||||
this.jinbei = jinbei;
|
||||
public static readonly int EventId = typeof(JinBeiSettlementEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public List<IPlayer> players { get; }
|
||||
public float jinbei { get; }
|
||||
|
||||
public JinBeiSettlementEventArgs(List<IPlayer> players, float jinbei)
|
||||
{
|
||||
this.players = players;
|
||||
this.jinbei = jinbei;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,17 @@
|
|||
using Game.Player;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class PlayerJinBeiChange_ToMainUIEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(PlayerJinBeiChange_ToMainUIEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
|
||||
public PlayerJinBeiChange_ToMainUIEventArgs(IPlayer player)
|
||||
public class PlayerJinBeiChange_ToMainUIEventArgs : GameEventArgs
|
||||
{
|
||||
this.player = player;
|
||||
public static readonly int EventId = typeof(PlayerJinBeiChange_ToMainUIEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
|
||||
public PlayerJinBeiChange_ToMainUIEventArgs(IPlayer player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,21 +2,22 @@
|
|||
using Game.Player;
|
||||
using Game.Room;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class PlayerJinBeiChange_ToPlayerEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(PlayerJinBeiChange_ToPlayerEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
public float jinbei { get; }
|
||||
public Action<bool> callback { get; }
|
||||
|
||||
public PlayerJinBeiChange_ToPlayerEventArgs(IPlayer player, float jinbei, Action<bool> callback)
|
||||
public class PlayerJinBeiChange_ToPlayerEventArgs : GameEventArgs
|
||||
{
|
||||
this.player = player;
|
||||
this.jinbei = jinbei;
|
||||
this.callback = callback;
|
||||
public static readonly int EventId = typeof(PlayerJinBeiChange_ToPlayerEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
public float jinbei { get; }
|
||||
public Action<bool> callback { get; }
|
||||
|
||||
public PlayerJinBeiChange_ToPlayerEventArgs(IPlayer player, float jinbei, Action<bool> callback)
|
||||
{
|
||||
this.player = player;
|
||||
this.jinbei = jinbei;
|
||||
this.callback = callback;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,20 @@
|
|||
using Game.Player;
|
||||
using Game.Room;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class PlayerMoveToRoomEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(PlayerMoveToRoomEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
public IRoom room { get; }
|
||||
|
||||
public PlayerMoveToRoomEventArgs(IPlayer player, IRoom room)
|
||||
public class PlayerMoveToRoomEventArgs : GameEventArgs
|
||||
{
|
||||
this.player = player;
|
||||
this.room = room;
|
||||
public static readonly int EventId = typeof(PlayerMoveToRoomEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
public IRoom room { get; }
|
||||
|
||||
public PlayerMoveToRoomEventArgs(IPlayer player, IRoom room)
|
||||
{
|
||||
this.player = player;
|
||||
this.room = room;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,17 @@
|
|||
using Game.Player;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class PlayerUpdateDataEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(PlayerUpdateDataEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
|
||||
public PlayerUpdateDataEventArgs(IPlayer player)
|
||||
public class PlayerUpdateDataEventArgs : GameEventArgs
|
||||
{
|
||||
this.player = player;
|
||||
public static readonly int EventId = typeof(PlayerUpdateDataEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
|
||||
public PlayerUpdateDataEventArgs(IPlayer player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +1,19 @@
|
|||
using Game.Player;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class ReturnPlayerJinBeiEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(ReturnPlayerJinBeiEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
public float jinBei { get; }
|
||||
|
||||
public ReturnPlayerJinBeiEventArgs(IPlayer player, float jinBei)
|
||||
public class ReturnPlayerJinBeiEventArgs : GameEventArgs
|
||||
{
|
||||
this.player = player;
|
||||
this.jinBei = jinBei;
|
||||
public static readonly int EventId = typeof(ReturnPlayerJinBeiEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IPlayer player { get; }
|
||||
public float jinBei { get; }
|
||||
|
||||
public ReturnPlayerJinBeiEventArgs(IPlayer player, float jinBei)
|
||||
{
|
||||
this.player = player;
|
||||
this.jinBei = jinBei;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,22 @@
|
|||
using Game.Player;
|
||||
using Game.Room;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class RoomJinBeiChangeEventArgs : GameEventArgs
|
||||
namespace Game
|
||||
{
|
||||
public static readonly int EventId = typeof(RoomJinBeiChangeEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IRoom room { get; }
|
||||
public IPlayer player { get; }
|
||||
public float jinBei { get; }
|
||||
|
||||
public RoomJinBeiChangeEventArgs(IRoom room, IPlayer player, float jinBei)
|
||||
public class RoomJinBeiChangeEventArgs : GameEventArgs
|
||||
{
|
||||
this.room = room;
|
||||
this.player = player;
|
||||
this.jinBei = jinBei;
|
||||
public static readonly int EventId = typeof(RoomJinBeiChangeEventArgs).GetHashCode();
|
||||
public override int Id => EventId;
|
||||
|
||||
public IRoom room { get; }
|
||||
public IPlayer player { get; }
|
||||
public float jinBei { get; }
|
||||
|
||||
public RoomJinBeiChangeEventArgs(IRoom room, IPlayer player, float jinBei)
|
||||
{
|
||||
this.room = room;
|
||||
this.player = player;
|
||||
this.jinBei = jinBei;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,23 @@
|
|||
namespace Game.Log;
|
||||
|
||||
/// <summary>
|
||||
/// 便于真机上取消log
|
||||
/// </summary>
|
||||
public static class Log
|
||||
namespace Game.Log
|
||||
{
|
||||
public static void Debug(object message)
|
||||
/// <summary>
|
||||
/// 便于真机上取消log
|
||||
/// </summary>
|
||||
public static class Log
|
||||
{
|
||||
UnityEngine.Debug.Log(message);
|
||||
}
|
||||
public static void Debug(object message)
|
||||
{
|
||||
UnityEngine.Debug.Log(message);
|
||||
}
|
||||
|
||||
public static void LogWarning(object message)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning(message);
|
||||
}
|
||||
public static void LogWarning(object message)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning(message);
|
||||
}
|
||||
|
||||
public static void LogError(object message)
|
||||
{
|
||||
UnityEngine.Debug.LogError(message);
|
||||
public static void LogError(object message)
|
||||
{
|
||||
UnityEngine.Debug.LogError(message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,120 +5,121 @@ using Game.Pathfinding;
|
|||
using Game.Room;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Player;
|
||||
|
||||
public interface IPlayer
|
||||
namespace Game.Player
|
||||
{
|
||||
string playerName { get; }
|
||||
GameObject self { get; }
|
||||
PlayerData playerData { get; }
|
||||
IRoom room { get; }
|
||||
bool isMoving { get; }
|
||||
void SetGameObject(GameObject gameObject, string name, float jinbei);
|
||||
void SetRoom(IRoom roo);
|
||||
UniTask<bool> WaitMoveRoomAsync(IRoom roo, CancellationToken token);
|
||||
UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token);
|
||||
void Init();
|
||||
void Dispose();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
internal class Player : IPlayer
|
||||
{
|
||||
private GameObject _self;
|
||||
private PlayerData _playerData;
|
||||
private IRoom _room;
|
||||
PlayerInfo playerInfo;
|
||||
private bool _isMoving;
|
||||
|
||||
public string playerName => this._playerData.playerName;
|
||||
|
||||
public GameObject self => this._self;
|
||||
|
||||
public PlayerData playerData => this._playerData;
|
||||
|
||||
public IRoom room => this._room;
|
||||
|
||||
public bool isMoving => this._isMoving;
|
||||
|
||||
|
||||
public void SetGameObject(GameObject gameObject, string name, float jinbei)
|
||||
public interface IPlayer
|
||||
{
|
||||
this._self = gameObject;
|
||||
this._playerData = new PlayerData(name, jinbei, 100);
|
||||
|
||||
// view
|
||||
playerInfo = this._self.GetComponent<PlayerInfo>();
|
||||
playerInfo.SetPlayer(this);
|
||||
this._isMoving = true;
|
||||
string playerName { get; }
|
||||
GameObject self { get; }
|
||||
PlayerData playerData { get; }
|
||||
IRoom room { get; }
|
||||
bool isMoving { get; }
|
||||
void SetGameObject(GameObject gameObject, string name, float jinbei);
|
||||
void SetRoom(IRoom roo);
|
||||
UniTask<bool> WaitMoveRoomAsync(IRoom roo, CancellationToken token);
|
||||
UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token);
|
||||
void Init();
|
||||
void Dispose();
|
||||
}
|
||||
|
||||
public void SetRoom(IRoom roo)
|
||||
[System.Serializable]
|
||||
internal class Player : IPlayer
|
||||
{
|
||||
this._room?.Quit(this);
|
||||
this._room = roo;
|
||||
// EventManager.Instance.FireNow(this, new PlayerMoveToRoomEventArgs(this, this._room));
|
||||
}
|
||||
private GameObject _self;
|
||||
private PlayerData _playerData;
|
||||
private IRoom _room;
|
||||
PlayerInfo playerInfo;
|
||||
private bool _isMoving;
|
||||
|
||||
public async UniTask<bool> WaitMoveRoomAsync(IRoom roo, CancellationToken token)
|
||||
{
|
||||
this._room?.Quit(this);
|
||||
this._room = roo;
|
||||
public string playerName => this._playerData.playerName;
|
||||
|
||||
public GameObject self => this._self;
|
||||
|
||||
public PlayerData playerData => this._playerData;
|
||||
|
||||
public IRoom room => this._room;
|
||||
|
||||
public bool isMoving => this._isMoving;
|
||||
|
||||
|
||||
public void SetGameObject(GameObject gameObject, string name, float jinbei)
|
||||
{
|
||||
this._self = gameObject;
|
||||
this._playerData = new PlayerData(name, jinbei, 100);
|
||||
|
||||
// view
|
||||
playerInfo = this._self.GetComponent<PlayerInfo>();
|
||||
playerInfo.SetPlayer(this);
|
||||
this._isMoving = true;
|
||||
}
|
||||
|
||||
public void SetRoom(IRoom roo)
|
||||
{
|
||||
this._room?.Quit(this);
|
||||
this._room = roo;
|
||||
// EventManager.Instance.FireNow(this, new PlayerMoveToRoomEventArgs(this, this._room));
|
||||
}
|
||||
|
||||
public async UniTask<bool> WaitMoveRoomAsync(IRoom roo, CancellationToken token)
|
||||
{
|
||||
this._room?.Quit(this);
|
||||
this._room = roo;
|
||||
// EventManager.Instance.FireNow(this, new PlayerMoveToRoomEventArgs(this, this._room));
|
||||
|
||||
var wayPoints = Game.bfsManager.FindPath(_room.roomInfo.room_Center);
|
||||
var wayPoints = Game.bfsManager.FindPath(_room.roomInfo.room_Center);
|
||||
|
||||
await UniTask.Yield();
|
||||
var moveAsync = await this.MoveAsync(wayPoints, token);
|
||||
await UniTask.Yield();
|
||||
var moveAsync = await this.MoveAsync(wayPoints, token);
|
||||
// Debug.Log("Move finish !!!");
|
||||
return moveAsync;
|
||||
}
|
||||
|
||||
public async UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token)
|
||||
{
|
||||
if (!this._isMoving) return false;
|
||||
|
||||
_isMoving = false;
|
||||
var endPos = this._room.roomInfo.GetJoinPosition();
|
||||
|
||||
await playerInfo.MoveAsync(wayPoint, endPos, token);
|
||||
this._isMoving = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
EventManager.Instance.Subscribe(PlayerJinBeiChange_ToPlayerEventArgs.EventId, PlayerJinbeiChangeEvent);
|
||||
EventManager.Instance.Subscribe(ReturnPlayerJinBeiEventArgs.EventId, ReturnPlayerJinBeiEvent);
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
EventManager.Instance.Unsubscribe(PlayerJinBeiChange_ToPlayerEventArgs.EventId, PlayerJinbeiChangeEvent);
|
||||
EventManager.Instance.Unsubscribe(ReturnPlayerJinBeiEventArgs.EventId, ReturnPlayerJinBeiEvent);
|
||||
GameObject.DestroyImmediate(this.self);
|
||||
}
|
||||
|
||||
private void ReturnPlayerJinBeiEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as ReturnPlayerJinBeiEventArgs;
|
||||
if (args.player == this)
|
||||
{
|
||||
this._playerData.ReturnJinBei(args.jinBei);
|
||||
EventManager.Instance.FireNow(this, new PlayerJinBeiChange_ToMainUIEventArgs(this));
|
||||
return moveAsync;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayerJinbeiChangeEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as PlayerJinBeiChange_ToPlayerEventArgs;
|
||||
var jinbei = this._playerData.jinbei - args.jinbei;
|
||||
if (jinbei >= 0)
|
||||
public async UniTask<bool> MoveAsync(List<WayPoint> wayPoint, CancellationToken token)
|
||||
{
|
||||
this._playerData.jinbei = jinbei;
|
||||
args.callback?.Invoke(true);
|
||||
if (!this._isMoving) return false;
|
||||
|
||||
_isMoving = false;
|
||||
var endPos = this._room.roomInfo.GetJoinPosition();
|
||||
|
||||
await playerInfo.MoveAsync(wayPoint, endPos, token);
|
||||
this._isMoving = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
EventManager.Instance.Subscribe(PlayerJinBeiChange_ToPlayerEventArgs.EventId, PlayerJinbeiChangeEvent);
|
||||
EventManager.Instance.Subscribe(ReturnPlayerJinBeiEventArgs.EventId, ReturnPlayerJinBeiEvent);
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
EventManager.Instance.Unsubscribe(PlayerJinBeiChange_ToPlayerEventArgs.EventId, PlayerJinbeiChangeEvent);
|
||||
EventManager.Instance.Unsubscribe(ReturnPlayerJinBeiEventArgs.EventId, ReturnPlayerJinBeiEvent);
|
||||
GameObject.DestroyImmediate(this.self);
|
||||
}
|
||||
|
||||
private void ReturnPlayerJinBeiEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as ReturnPlayerJinBeiEventArgs;
|
||||
if (args.player == this)
|
||||
{
|
||||
this._playerData.ReturnJinBei(args.jinBei);
|
||||
EventManager.Instance.FireNow(this, new PlayerJinBeiChange_ToMainUIEventArgs(this));
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayerJinbeiChangeEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as PlayerJinBeiChange_ToPlayerEventArgs;
|
||||
var jinbei = this._playerData.jinbei - args.jinbei;
|
||||
if (jinbei >= 0)
|
||||
{
|
||||
this._playerData.jinbei = jinbei;
|
||||
args.callback?.Invoke(true);
|
||||
}
|
||||
else
|
||||
args.callback?.Invoke(false);
|
||||
}
|
||||
else
|
||||
args.callback?.Invoke(false);
|
||||
}
|
||||
}
|
|
@ -1,60 +1,61 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Game.Player;
|
||||
|
||||
public class PlayerManager : ManagerBase, IPlayerManager
|
||||
namespace Game.Player
|
||||
{
|
||||
private Dictionary<string, IPlayer> _players = new Dictionary<string, IPlayer>();
|
||||
private IPlayer _currentPlayer;
|
||||
|
||||
public IPlayer currentPlayer => this._currentPlayer;
|
||||
|
||||
protected override void OnInit()
|
||||
public class PlayerManager : ManagerBase, IPlayerManager
|
||||
{
|
||||
base.OnInit();
|
||||
_players = new Dictionary<string, IPlayer>();
|
||||
this._currentPlayer = null;
|
||||
}
|
||||
private Dictionary<string, IPlayer> _players = new Dictionary<string, IPlayer>();
|
||||
private IPlayer _currentPlayer;
|
||||
|
||||
public void SetCurrentPlayer(IPlayer player)
|
||||
{
|
||||
this._currentPlayer ??= player;
|
||||
}
|
||||
public IPlayer currentPlayer => this._currentPlayer;
|
||||
|
||||
public IPlayer CreatePlayer(string playerName, string assetName, float jinbei)
|
||||
{
|
||||
var gameObject = Game.resourceManager.LoadGameObjectSync(assetName);
|
||||
IPlayer player = new Player();
|
||||
player.SetGameObject(gameObject, playerName, jinbei);
|
||||
this._players.Add(playerName, player);
|
||||
player.Init();
|
||||
return player;
|
||||
}
|
||||
|
||||
public IPlayer GetPlayer(string playerName)
|
||||
{
|
||||
return this._players.GetValueOrDefault(playerName);
|
||||
}
|
||||
|
||||
public void DeletePlayer(string playerName)
|
||||
{
|
||||
if (this._players.TryGetValue(playerName, out var player))
|
||||
protected override void OnInit()
|
||||
{
|
||||
player.Dispose();
|
||||
base.OnInit();
|
||||
_players = new Dictionary<string, IPlayer>();
|
||||
this._currentPlayer = null;
|
||||
}
|
||||
|
||||
public void SetCurrentPlayer(IPlayer player)
|
||||
{
|
||||
this._currentPlayer ??= player;
|
||||
}
|
||||
|
||||
public IPlayer CreatePlayer(string playerName, string assetName, float jinbei)
|
||||
{
|
||||
var gameObject = Game.resourceManager.LoadGameObjectSync(assetName);
|
||||
IPlayer player = new Player();
|
||||
player.SetGameObject(gameObject, playerName, jinbei);
|
||||
this._players.Add(playerName, player);
|
||||
player.Init();
|
||||
return player;
|
||||
}
|
||||
|
||||
public IPlayer GetPlayer(string playerName)
|
||||
{
|
||||
return this._players.GetValueOrDefault(playerName);
|
||||
}
|
||||
|
||||
public void DeletePlayer(string playerName)
|
||||
{
|
||||
if (this._players.TryGetValue(playerName, out var player))
|
||||
{
|
||||
player.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IPlayerManager
|
||||
{
|
||||
IPlayer currentPlayer { get; }
|
||||
public interface IPlayerManager
|
||||
{
|
||||
IPlayer currentPlayer { get; }
|
||||
|
||||
void SetCurrentPlayer(IPlayer player);
|
||||
void SetCurrentPlayer(IPlayer player);
|
||||
|
||||
//
|
||||
IPlayer CreatePlayer(string playerName, string assetName, float jinbei);
|
||||
//
|
||||
IPlayer CreatePlayer(string playerName, string assetName, float jinbei);
|
||||
|
||||
IPlayer GetPlayer(string playerName);
|
||||
IPlayer GetPlayer(string playerName);
|
||||
|
||||
void DeletePlayer(string playerName);
|
||||
void DeletePlayer(string playerName);
|
||||
}
|
||||
}
|
|
@ -2,40 +2,41 @@
|
|||
using Cysharp.Threading.Tasks;
|
||||
using Game.Room;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[Procedure(ProcedureType.EnterGameSceneProcedure)]
|
||||
class EnterGameSceneProcedure : ProcedureBase
|
||||
namespace Game
|
||||
{
|
||||
public override void OnEnter()
|
||||
[Procedure(ProcedureType.EnterGameSceneProcedure)]
|
||||
class EnterGameSceneProcedure : ProcedureBase
|
||||
{
|
||||
base.OnEnter();
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
|
||||
var room = Game.roomManager.CreateRoom(RoomType.出生点);
|
||||
Game.roomManager.CreateRoom(RoomType.伏龙阁);
|
||||
Game.roomManager.CreateRoom(RoomType.杂物室);
|
||||
Game.roomManager.CreateRoom(RoomType.训练堂);
|
||||
Game.roomManager.CreateRoom(RoomType.先祖大厅);
|
||||
Game.roomManager.CreateRoom(RoomType.圣龙残骸);
|
||||
Game.roomManager.CreateRoom(RoomType.天池遗址);
|
||||
Game.roomManager.CreateRoom(RoomType.沙慕龙阁);
|
||||
Game.roomManager.CreateRoom(RoomType.英雄圣殿);
|
||||
var room = Game.roomManager.CreateRoom(RoomType.出生点);
|
||||
Game.roomManager.CreateRoom(RoomType.伏龙阁);
|
||||
Game.roomManager.CreateRoom(RoomType.杂物室);
|
||||
Game.roomManager.CreateRoom(RoomType.训练堂);
|
||||
Game.roomManager.CreateRoom(RoomType.先祖大厅);
|
||||
Game.roomManager.CreateRoom(RoomType.圣龙残骸);
|
||||
Game.roomManager.CreateRoom(RoomType.天池遗址);
|
||||
Game.roomManager.CreateRoom(RoomType.沙慕龙阁);
|
||||
Game.roomManager.CreateRoom(RoomType.英雄圣殿);
|
||||
|
||||
var player = Game.playerManager.currentPlayer;
|
||||
var joinPosition = room.roomInfo.GetJoinPosition();
|
||||
var player = Game.playerManager.currentPlayer;
|
||||
var joinPosition = room.roomInfo.GetJoinPosition();
|
||||
// var wayPoints = Game.bfsManager.FindPath(joinPosition);
|
||||
|
||||
UniTask.Create(async () =>
|
||||
{
|
||||
await player.WaitMoveRoomAsync(room, new CancellationToken());
|
||||
UniTask.Create(async () =>
|
||||
{
|
||||
await player.WaitMoveRoomAsync(room, new CancellationToken());
|
||||
// await player.MoveAsync(wayPoints, new CancellationToken());
|
||||
|
||||
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneLogicProcedure);
|
||||
});
|
||||
}
|
||||
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneLogicProcedure);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnLeave()
|
||||
{
|
||||
base.OnLeave();
|
||||
public override void OnLeave()
|
||||
{
|
||||
base.OnLeave();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,97 +7,98 @@ using Game.Room;
|
|||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[Procedure(ProcedureType.GameSceneKillPlayerProcedure)]
|
||||
class GameSceneKillPlayerProcedure : ProcedureBase
|
||||
namespace Game
|
||||
{
|
||||
private float maxTime = 10f;
|
||||
GameSceneMainUI sceneMainUI;
|
||||
|
||||
public override void OnEnter()
|
||||
[Procedure(ProcedureType.GameSceneKillPlayerProcedure)]
|
||||
class GameSceneKillPlayerProcedure : ProcedureBase
|
||||
{
|
||||
base.OnEnter();
|
||||
private float maxTime = 10f;
|
||||
GameSceneMainUI sceneMainUI;
|
||||
|
||||
EventManager.Instance.Subscribe(InputObjectFinishEventArgs.EventId, this.InputObjectFinishEvent);
|
||||
EventManager.Instance.FireNow(this, new BossStartMoveEventArgs(true));
|
||||
UniTask.Create(this.OpenWarningTips);
|
||||
}
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
|
||||
async UniTask OpenWarningTips()
|
||||
{
|
||||
sceneMainUI = Game.uiManager.GetUI<GameSceneMainUI>(UIType.GameSceneMainUI);
|
||||
await this.sceneMainUI.WaitTimeCloseTips();
|
||||
EventManager.Instance.Subscribe(InputObjectFinishEventArgs.EventId, this.InputObjectFinishEvent);
|
||||
EventManager.Instance.FireNow(this, new BossStartMoveEventArgs(true));
|
||||
UniTask.Create(this.OpenWarningTips);
|
||||
}
|
||||
|
||||
UniTask.Create(this.WaitKillFinish);
|
||||
async UniTask OpenWarningTips()
|
||||
{
|
||||
sceneMainUI = Game.uiManager.GetUI<GameSceneMainUI>(UIType.GameSceneMainUI);
|
||||
await this.sceneMainUI.WaitTimeCloseTips();
|
||||
|
||||
UniTask.Create(this.WaitKillFinish);
|
||||
// UniTask.Create(this.WaitTimeGoNext);
|
||||
isFinish = false;
|
||||
}
|
||||
|
||||
async UniTask WaitKillFinish()
|
||||
{
|
||||
string content = $"恐龙出没!";
|
||||
sceneMainUI.UpdateMessage(content);
|
||||
|
||||
var roomData = Game.roomManager.GetAllRandomRoom();
|
||||
await Game.bossManager.MoveToKillPlayerAsync(roomData.killRoom, default);
|
||||
|
||||
Game.bossManager.DeleteBoss();
|
||||
isFinish = true;
|
||||
|
||||
float jinBei = 0;
|
||||
foreach (var room in roomData.killRoom)
|
||||
{
|
||||
jinBei += room.roomData.jinBeiCount;
|
||||
isFinish = false;
|
||||
}
|
||||
|
||||
Debug.Log($"杀掉了随机房间玩家,金贝数量总和为:{jinBei}");
|
||||
|
||||
List<IPlayer> players = new List<IPlayer>();
|
||||
foreach (var room in roomData.survivorRoom)
|
||||
async UniTask WaitKillFinish()
|
||||
{
|
||||
foreach (var roomPlayer in room.players)
|
||||
string content = $"恐龙出没!";
|
||||
sceneMainUI.UpdateMessage(content);
|
||||
|
||||
var roomData = Game.roomManager.GetAllRandomRoom();
|
||||
await Game.bossManager.MoveToKillPlayerAsync(roomData.killRoom, default);
|
||||
|
||||
Game.bossManager.DeleteBoss();
|
||||
isFinish = true;
|
||||
|
||||
float jinBei = 0;
|
||||
foreach (var room in roomData.killRoom)
|
||||
{
|
||||
Debug.Log($"幸存者:{roomPlayer.playerName}");
|
||||
players.Add(roomPlayer);
|
||||
jinBei += room.roomData.jinBeiCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (players.Count > 0)
|
||||
jinBei /= players.Count;
|
||||
Debug.Log($"杀掉了随机房间玩家,金贝数量总和为:{jinBei}");
|
||||
|
||||
Debug.Log($"胜利总金贝: is {jinBei}");
|
||||
EventManager.Instance.FireNow(this, new JinBeiSettlementEventArgs(players, jinBei));
|
||||
List<IPlayer> players = new List<IPlayer>();
|
||||
foreach (var room in roomData.survivorRoom)
|
||||
{
|
||||
foreach (var roomPlayer in room.players)
|
||||
{
|
||||
Debug.Log($"幸存者:{roomPlayer.playerName}");
|
||||
players.Add(roomPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
var resultUI = Game.uiManager.GetUI<GameSceneResultUI>(UIType.GameSceneResultUI);
|
||||
if (players.Contains(Game.playerManager.currentPlayer))
|
||||
resultUI.SetResult($"恭喜你躲避成功,胜利总金贝:{jinBei},你得到的金贝:{jinBei}", true);
|
||||
else
|
||||
resultUI.SetResult($"躲避失败,胜利总金贝:{jinBei},你得到的金贝:0", false);
|
||||
if (players.Count > 0)
|
||||
jinBei /= players.Count;
|
||||
|
||||
//TODO:
|
||||
UniTask.Create(async () => { await Game.roomManager.QuitAllRoomAsync(default); });
|
||||
Debug.Log($"胜利总金贝: is {jinBei}");
|
||||
EventManager.Instance.FireNow(this, new JinBeiSettlementEventArgs(players, jinBei));
|
||||
|
||||
var resultUI = Game.uiManager.GetUI<GameSceneResultUI>(UIType.GameSceneResultUI);
|
||||
if (players.Contains(Game.playerManager.currentPlayer))
|
||||
resultUI.SetResult($"恭喜你躲避成功,胜利总金贝:{jinBei},你得到的金贝:{jinBei}", true);
|
||||
else
|
||||
resultUI.SetResult($"躲避失败,胜利总金贝:{jinBei},你得到的金贝:0", false);
|
||||
|
||||
//TODO:
|
||||
UniTask.Create(async () => { await Game.roomManager.QuitAllRoomAsync(default); });
|
||||
// await this.sceneMainUI.WaitTimeCloseTips();
|
||||
|
||||
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneSettlementProcedure);
|
||||
}
|
||||
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneSettlementProcedure);
|
||||
}
|
||||
|
||||
private bool isFinish;
|
||||
private bool isFinish;
|
||||
|
||||
private void InputObjectFinishEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as InputObjectFinishEventArgs;
|
||||
private void InputObjectFinishEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as InputObjectFinishEventArgs;
|
||||
// var inputData = args.data as MouseInputData;
|
||||
// var roomInfo = inputData.go.GetComponent<RoomInfo>();
|
||||
|
||||
Debug.Log("未到选择房间时间!");
|
||||
Debug.Log("未到选择房间时间!");
|
||||
// UniTask.Create(async () => { await Game.roomManager.JoinRoomAsync(roomInfo.roomType, Game.playerManager.currentPlayer, new CancellationToken()); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OnLeave()
|
||||
{
|
||||
base.OnLeave();
|
||||
EventManager.Instance.Unsubscribe(InputObjectFinishEventArgs.EventId, this.InputObjectFinishEvent);
|
||||
public override void OnLeave()
|
||||
{
|
||||
base.OnLeave();
|
||||
EventManager.Instance.Unsubscribe(InputObjectFinishEventArgs.EventId, this.InputObjectFinishEvent);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +1,26 @@
|
|||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[Procedure(ProcedureType.GameSceneSettlementProcedure)]
|
||||
class GameSceneSettlementProcedure : ProcedureBase
|
||||
namespace Game
|
||||
{
|
||||
public override void OnEnter()
|
||||
[Procedure(ProcedureType.GameSceneSettlementProcedure)]
|
||||
class GameSceneSettlementProcedure : ProcedureBase
|
||||
{
|
||||
base.OnEnter();
|
||||
var showUI = Game.uiManager.ShowUI(UIType.GameSceneResultUI);
|
||||
var resultUI = showUI as GameSceneResultUI;
|
||||
UniTask.Create(async () =>
|
||||
public override void OnEnter()
|
||||
{
|
||||
await resultUI.WaitShowAndCloseResultAsync(default);
|
||||
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneLogicProcedure);
|
||||
});
|
||||
}
|
||||
base.OnEnter();
|
||||
var showUI = Game.uiManager.ShowUI(UIType.GameSceneResultUI);
|
||||
var resultUI = showUI as GameSceneResultUI;
|
||||
UniTask.Create(async () =>
|
||||
{
|
||||
await resultUI.WaitShowAndCloseResultAsync(default);
|
||||
Game.procedureManager.ChangeProcedure(ProcedureType.GameSceneLogicProcedure);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnLeave()
|
||||
{
|
||||
base.OnLeave();
|
||||
public override void OnLeave()
|
||||
{
|
||||
base.OnLeave();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
class ProcedureAttribute: Attribute
|
||||
namespace Game
|
||||
{
|
||||
public ProcedureType ProcedureType { get; set; }
|
||||
|
||||
public ProcedureAttribute(ProcedureType type)
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
class ProcedureAttribute: Attribute
|
||||
{
|
||||
this.ProcedureType = type;
|
||||
public ProcedureType ProcedureType { get; set; }
|
||||
|
||||
public ProcedureAttribute(ProcedureType type)
|
||||
{
|
||||
this.ProcedureType = type;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,105 +3,106 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Game.RayCast;
|
||||
|
||||
public class MouseInput : MonoBehaviour
|
||||
namespace Game.RayCast
|
||||
{
|
||||
public RayCastType rayCastType = RayCastType._2D;
|
||||
public class MouseInput : MonoBehaviour
|
||||
{
|
||||
public RayCastType rayCastType = RayCastType._2D;
|
||||
|
||||
MouseInputData mouseInputData = new MouseInputData();
|
||||
MouseInputData mouseInputData = new MouseInputData();
|
||||
|
||||
// public event MouseInputEventHandle ev;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (this.IsMouseOverUI()) return;
|
||||
|
||||
switch (rayCastType)
|
||||
private void Update()
|
||||
{
|
||||
case RayCastType._3D:
|
||||
// 3d
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
if (hit.collider != null)
|
||||
{
|
||||
Debug.Log(hit.collider.name);
|
||||
}
|
||||
}
|
||||
if (this.IsMouseOverUI()) return;
|
||||
|
||||
break;
|
||||
case RayCastType._2D:
|
||||
//2d
|
||||
var point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
var hit2D = Physics2D.Raycast(point, -Vector2.up);
|
||||
if (hit2D.collider != null)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
UnityEngine.Debug.Log(hit2D.collider.name);
|
||||
mouseInputData.rayCastType = this.rayCastType;
|
||||
mouseInputData.point = hit2D.point;
|
||||
mouseInputData.isPressDown = true;
|
||||
mouseInputData.go = hit2D.collider.gameObject;
|
||||
EventManager.Instance.FireNow(this, new InputObjectFinishEventArgs(mouseInputData));
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(2))
|
||||
{
|
||||
// Game.bfsManager.Test(hit2D.point);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsMouseOverUI()
|
||||
{
|
||||
PointerEventData eventData = new PointerEventData(EventSystem.current)
|
||||
{
|
||||
position = Input.mousePosition
|
||||
};
|
||||
|
||||
List<RaycastResult> results = new List<RaycastResult>();
|
||||
EventSystem.current.RaycastAll(eventData, results);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
// 检查射线检测到的对象是否为UI元素,并且是否属于CanvasGroup
|
||||
CanvasGroup canvasGroup = result.gameObject.GetComponentInParent<CanvasGroup>();
|
||||
|
||||
if (canvasGroup != null)
|
||||
switch (rayCastType)
|
||||
{
|
||||
// 如果CanvasGroup不允许交互或不阻挡射线,我们认为鼠标不是位于UI上
|
||||
if (!canvasGroup.interactable || !canvasGroup.blocksRaycasts)
|
||||
case RayCastType._3D:
|
||||
// 3d
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
if (hit.collider != null)
|
||||
{
|
||||
Debug.Log(hit.collider.name);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case RayCastType._2D:
|
||||
//2d
|
||||
var point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
var hit2D = Physics2D.Raycast(point, -Vector2.up);
|
||||
if (hit2D.collider != null)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
UnityEngine.Debug.Log(hit2D.collider.name);
|
||||
mouseInputData.rayCastType = this.rayCastType;
|
||||
mouseInputData.point = hit2D.point;
|
||||
mouseInputData.isPressDown = true;
|
||||
mouseInputData.go = hit2D.collider.gameObject;
|
||||
EventManager.Instance.FireNow(this, new InputObjectFinishEventArgs(mouseInputData));
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(2))
|
||||
{
|
||||
// Game.bfsManager.Test(hit2D.point);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsMouseOverUI()
|
||||
{
|
||||
PointerEventData eventData = new PointerEventData(EventSystem.current)
|
||||
{
|
||||
position = Input.mousePosition
|
||||
};
|
||||
|
||||
List<RaycastResult> results = new List<RaycastResult>();
|
||||
EventSystem.current.RaycastAll(eventData, results);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
// 检查射线检测到的对象是否为UI元素,并且是否属于CanvasGroup
|
||||
CanvasGroup canvasGroup = result.gameObject.GetComponentInParent<CanvasGroup>();
|
||||
|
||||
if (canvasGroup != null)
|
||||
{
|
||||
continue;
|
||||
// 如果CanvasGroup不允许交互或不阻挡射线,我们认为鼠标不是位于UI上
|
||||
if (!canvasGroup.interactable || !canvasGroup.blocksRaycasts)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果找到至少一个允许交互且阻挡射线的UI元素,返回true
|
||||
return true;
|
||||
}
|
||||
|
||||
// 如果找到至少一个允许交互且阻挡射线的UI元素,返回true
|
||||
return true;
|
||||
// 如果所有射线检测到的UI元素都不允许交互或不阻挡射线,返回false
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果所有射线检测到的UI元素都不允许交互或不阻挡射线,返回false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum RayCastType
|
||||
{
|
||||
_3D,
|
||||
_2D,
|
||||
}
|
||||
public enum RayCastType
|
||||
{
|
||||
_3D,
|
||||
_2D,
|
||||
}
|
||||
|
||||
public class MouseInputData
|
||||
{
|
||||
public RayCastType rayCastType;
|
||||
public bool isPressDown;
|
||||
public Vector3 point;
|
||||
public GameObject go;
|
||||
public class MouseInputData
|
||||
{
|
||||
public RayCastType rayCastType;
|
||||
public bool isPressDown;
|
||||
public Vector3 point;
|
||||
public GameObject go;
|
||||
}
|
||||
}
|
|
@ -1,28 +1,29 @@
|
|||
using System;
|
||||
|
||||
namespace Game.RayCast;
|
||||
|
||||
public class MouseInputManager : ManagerBase, IMouseInputManager
|
||||
namespace Game.RayCast
|
||||
{
|
||||
private MouseInput _currentMouseInput;
|
||||
|
||||
public MouseInput currentMouseInput => this._currentMouseInput;
|
||||
|
||||
protected override void OnInit()
|
||||
public class MouseInputManager : ManagerBase, IMouseInputManager
|
||||
{
|
||||
base.OnInit();
|
||||
AddMouseInput(RayCastType._2D);
|
||||
private MouseInput _currentMouseInput;
|
||||
|
||||
public MouseInput currentMouseInput => this._currentMouseInput;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
AddMouseInput(RayCastType._2D);
|
||||
}
|
||||
|
||||
public void AddMouseInput(RayCastType rayCastType)
|
||||
{
|
||||
_currentMouseInput ??= Game.self.AddComponent<MouseInput>();
|
||||
this._currentMouseInput.rayCastType = rayCastType;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddMouseInput(RayCastType rayCastType)
|
||||
public interface IMouseInputManager
|
||||
{
|
||||
_currentMouseInput ??= Game.self.AddComponent<MouseInput>();
|
||||
this._currentMouseInput.rayCastType = rayCastType;
|
||||
MouseInput currentMouseInput { get; }
|
||||
void AddMouseInput(RayCastType rayCastType);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMouseInputManager
|
||||
{
|
||||
MouseInput currentMouseInput { get; }
|
||||
void AddMouseInput(RayCastType rayCastType);
|
||||
}
|
|
@ -5,190 +5,191 @@ using Cysharp.Threading.Tasks;
|
|||
using Game.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Room;
|
||||
|
||||
public interface IRoomManager
|
||||
namespace Game.Room
|
||||
{
|
||||
IRoom currentRoom { get; }
|
||||
IRoom CreateRoom(RoomType roomType);
|
||||
void SetCurrentRoom(RoomType roomType);
|
||||
IRoom GetRoom(RoomType roomType);
|
||||
RandomRoomData GetAllRandomRoom();
|
||||
UniTask<bool> JoinRoomAsync(RoomType roomType, IPlayer player, CancellationToken token);
|
||||
bool QuitRoom(RoomType roomType, IPlayer player);
|
||||
UniTask QuitAllRoomAsync(CancellationToken token);
|
||||
void DeleteRoom(RoomType roomType);
|
||||
}
|
||||
|
||||
public class RoomManager : ManagerBase, IRoomManager
|
||||
{
|
||||
private IRoom birthRoom;
|
||||
private Dictionary<RoomType, IRoom> _rooms = new Dictionary<RoomType, IRoom>();
|
||||
private Dictionary<RoomType, IRoom> tmp = new Dictionary<RoomType, IRoom>();
|
||||
private IRoom _currentRoom;
|
||||
|
||||
public IRoom currentRoom => this._currentRoom;
|
||||
|
||||
protected override void OnInit()
|
||||
public interface IRoomManager
|
||||
{
|
||||
base.OnInit();
|
||||
EventManager.Instance.Subscribe(RoomJinBeiChangeEventArgs.EventId, RoomJinBeiChangeEvent);
|
||||
IRoom currentRoom { get; }
|
||||
IRoom CreateRoom(RoomType roomType);
|
||||
void SetCurrentRoom(RoomType roomType);
|
||||
IRoom GetRoom(RoomType roomType);
|
||||
RandomRoomData GetAllRandomRoom();
|
||||
UniTask<bool> JoinRoomAsync(RoomType roomType, IPlayer player, CancellationToken token);
|
||||
bool QuitRoom(RoomType roomType, IPlayer player);
|
||||
UniTask QuitAllRoomAsync(CancellationToken token);
|
||||
void DeleteRoom(RoomType roomType);
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
public class RoomManager : ManagerBase, IRoomManager
|
||||
{
|
||||
base.OnDispose();
|
||||
EventManager.Instance.Unsubscribe(RoomJinBeiChangeEventArgs.EventId, RoomJinBeiChangeEvent);
|
||||
}
|
||||
private IRoom birthRoom;
|
||||
private Dictionary<RoomType, IRoom> _rooms = new Dictionary<RoomType, IRoom>();
|
||||
private Dictionary<RoomType, IRoom> tmp = new Dictionary<RoomType, IRoom>();
|
||||
private IRoom _currentRoom;
|
||||
|
||||
private void RoomJinBeiChangeEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as RoomJinBeiChangeEventArgs;
|
||||
args.room.InvestmentJinBei(args.player, args.jinBei);
|
||||
}
|
||||
public IRoom currentRoom => this._currentRoom;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
base.OnInit();
|
||||
EventManager.Instance.Subscribe(RoomJinBeiChangeEventArgs.EventId, RoomJinBeiChangeEvent);
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
base.OnDispose();
|
||||
EventManager.Instance.Unsubscribe(RoomJinBeiChangeEventArgs.EventId, RoomJinBeiChangeEvent);
|
||||
}
|
||||
|
||||
private void RoomJinBeiChangeEvent(object sender, GameEventArgs e)
|
||||
{
|
||||
var args = e as RoomJinBeiChangeEventArgs;
|
||||
args.room.InvestmentJinBei(args.player, args.jinBei);
|
||||
}
|
||||
|
||||
public IRoom CreateRoom(RoomType roomType)
|
||||
{
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
return room;
|
||||
|
||||
var gameObject = Game.resourceManager.LoadGameObjectSync(roomType.ToString());
|
||||
room = new Room(roomType, gameObject);
|
||||
|
||||
this._rooms.Add(roomType, room);
|
||||
|
||||
public IRoom CreateRoom(RoomType roomType)
|
||||
{
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
return room;
|
||||
|
||||
var gameObject = Game.resourceManager.LoadGameObjectSync(roomType.ToString());
|
||||
room = new Room(roomType, gameObject);
|
||||
|
||||
this._rooms.Add(roomType, room);
|
||||
|
||||
return room;
|
||||
}
|
||||
|
||||
public void SetCurrentRoom(RoomType roomType)
|
||||
{
|
||||
if (roomType == RoomType.出生点)
|
||||
return;
|
||||
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
this._currentRoom = room;
|
||||
}
|
||||
|
||||
public IRoom GetRoom(RoomType roomType)
|
||||
{
|
||||
return this._rooms.GetValueOrDefault(roomType);
|
||||
}
|
||||
|
||||
public RandomRoomData GetAllRandomRoom()
|
||||
{
|
||||
if (this.tmp.Count <= 0 || this.tmp.ContainsKey(RoomType.出生点))
|
||||
{
|
||||
this.tmp = new Dictionary<RoomType, IRoom>(this._rooms);
|
||||
this.tmp.Remove(RoomType.出生点);
|
||||
}
|
||||
|
||||
// kill
|
||||
var killRoom = this.tmp.Values.ToList();
|
||||
ShuffleAndRemoveRooms(killRoom);
|
||||
|
||||
//
|
||||
var survivorRoom = this.tmp.Values.ToList().Except(killRoom).ToList();
|
||||
|
||||
// 标记一下
|
||||
foreach (var room in killRoom)
|
||||
public void SetCurrentRoom(RoomType roomType)
|
||||
{
|
||||
room.SetIsCanReturnJinBei(false);
|
||||
if (roomType == RoomType.出生点)
|
||||
return;
|
||||
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
this._currentRoom = room;
|
||||
}
|
||||
|
||||
// 标记一下
|
||||
foreach (var room in survivorRoom)
|
||||
public IRoom GetRoom(RoomType roomType)
|
||||
{
|
||||
room.SetIsCanReturnJinBei(true);
|
||||
return this._rooms.GetValueOrDefault(roomType);
|
||||
}
|
||||
|
||||
RandomRoomData roomData = new RandomRoomData();
|
||||
roomData.killRoom = killRoom;
|
||||
roomData.survivorRoom = survivorRoom;
|
||||
|
||||
return roomData;
|
||||
}
|
||||
|
||||
public void ShuffleAndRemoveRooms(List<IRoom> list)
|
||||
{
|
||||
ShuffleList(list);
|
||||
|
||||
int removeCount = Random.Range(1, list.Count);
|
||||
|
||||
for (int i = 0; i < removeCount; i++)
|
||||
public RandomRoomData GetAllRandomRoom()
|
||||
{
|
||||
list.RemoveAt(list.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 实现Fisher-Yates洗牌算法
|
||||
private void ShuffleList<T>(List<T> list)
|
||||
{
|
||||
for (int i = list.Count - 1; i > 0; i--)
|
||||
{
|
||||
int swapIndex = Random.Range(0, i + 1);
|
||||
(list[i], list[swapIndex]) = (list[swapIndex], list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public async UniTask<bool> JoinRoomAsync(RoomType roomType, IPlayer player, CancellationToken token)
|
||||
{
|
||||
if (!player.isMoving)
|
||||
return false;
|
||||
|
||||
foreach (IRoom roomsValue in this._rooms.Values)
|
||||
{
|
||||
var roomInfo = roomsValue.roomInfo;
|
||||
roomInfo.SetSelect(false);
|
||||
}
|
||||
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
{
|
||||
room.roomInfo.SetSelect(true);
|
||||
await room.JoinAsync(player, token);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool QuitRoom(RoomType roomType, IPlayer player)
|
||||
{
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
{
|
||||
room.Quit(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async UniTask QuitAllRoomAsync(CancellationToken token)
|
||||
{
|
||||
List<UniTask> tasks = new List<UniTask>();
|
||||
foreach (IRoom room in this.tmp.Values)
|
||||
{
|
||||
var players = room.QuitAndClearAll();
|
||||
foreach (var player in players)
|
||||
if (this.tmp.Count <= 0 || this.tmp.ContainsKey(RoomType.出生点))
|
||||
{
|
||||
Debug.Log($"正在安排{player}返回出生点");
|
||||
var task = this.JoinRoomAsync(RoomType.出生点, player, token);
|
||||
tasks.Add(task);
|
||||
this.tmp = new Dictionary<RoomType, IRoom>(this._rooms);
|
||||
this.tmp.Remove(RoomType.出生点);
|
||||
}
|
||||
|
||||
// kill
|
||||
var killRoom = this.tmp.Values.ToList();
|
||||
ShuffleAndRemoveRooms(killRoom);
|
||||
|
||||
//
|
||||
var survivorRoom = this.tmp.Values.ToList().Except(killRoom).ToList();
|
||||
|
||||
// 标记一下
|
||||
foreach (var room in killRoom)
|
||||
{
|
||||
room.SetIsCanReturnJinBei(false);
|
||||
}
|
||||
|
||||
// 标记一下
|
||||
foreach (var room in survivorRoom)
|
||||
{
|
||||
room.SetIsCanReturnJinBei(true);
|
||||
}
|
||||
|
||||
RandomRoomData roomData = new RandomRoomData();
|
||||
roomData.killRoom = killRoom;
|
||||
roomData.survivorRoom = survivorRoom;
|
||||
|
||||
return roomData;
|
||||
}
|
||||
|
||||
public void ShuffleAndRemoveRooms(List<IRoom> list)
|
||||
{
|
||||
ShuffleList(list);
|
||||
|
||||
int removeCount = Random.Range(1, list.Count);
|
||||
|
||||
for (int i = 0; i < removeCount; i++)
|
||||
{
|
||||
list.RemoveAt(list.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
await UniTask.WhenAll(tasks);
|
||||
Debug.Log("全部返回了出生点");
|
||||
// 实现Fisher-Yates洗牌算法
|
||||
private void ShuffleList<T>(List<T> list)
|
||||
{
|
||||
for (int i = list.Count - 1; i > 0; i--)
|
||||
{
|
||||
int swapIndex = Random.Range(0, i + 1);
|
||||
(list[i], list[swapIndex]) = (list[swapIndex], list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public async UniTask<bool> JoinRoomAsync(RoomType roomType, IPlayer player, CancellationToken token)
|
||||
{
|
||||
if (!player.isMoving)
|
||||
return false;
|
||||
|
||||
foreach (IRoom roomsValue in this._rooms.Values)
|
||||
{
|
||||
var roomInfo = roomsValue.roomInfo;
|
||||
roomInfo.SetSelect(false);
|
||||
}
|
||||
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
{
|
||||
room.roomInfo.SetSelect(true);
|
||||
await room.JoinAsync(player, token);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool QuitRoom(RoomType roomType, IPlayer player)
|
||||
{
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
{
|
||||
room.Quit(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public async UniTask QuitAllRoomAsync(CancellationToken token)
|
||||
{
|
||||
List<UniTask> tasks = new List<UniTask>();
|
||||
foreach (IRoom room in this.tmp.Values)
|
||||
{
|
||||
var players = room.QuitAndClearAll();
|
||||
foreach (var player in players)
|
||||
{
|
||||
Debug.Log($"正在安排{player}返回出生点");
|
||||
var task = this.JoinRoomAsync(RoomType.出生点, player, token);
|
||||
tasks.Add(task);
|
||||
}
|
||||
}
|
||||
|
||||
await UniTask.WhenAll(tasks);
|
||||
Debug.Log("全部返回了出生点");
|
||||
}
|
||||
|
||||
public void DeleteRoom(RoomType roomType)
|
||||
{
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
room.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteRoom(RoomType roomType)
|
||||
public struct RandomRoomData
|
||||
{
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
room.Dispose();
|
||||
public IReadOnlyList<IRoom> killRoom;
|
||||
public IReadOnlyList<IRoom> survivorRoom;
|
||||
}
|
||||
}
|
||||
|
||||
public struct RandomRoomData
|
||||
{
|
||||
public IReadOnlyList<IRoom> killRoom;
|
||||
public IReadOnlyList<IRoom> survivorRoom;
|
||||
}
|
|
@ -5,126 +5,127 @@ using Cysharp.Threading.Tasks;
|
|||
using Game.Player;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Room;
|
||||
|
||||
public interface IRoom
|
||||
namespace Game.Room
|
||||
{
|
||||
string roomName { get; }
|
||||
RoomData roomData { get; }
|
||||
RoomInfo roomInfo { get; }
|
||||
IReadOnlyList<IPlayer> players { get; }
|
||||
RoomType roomType { get; }
|
||||
public interface IRoom
|
||||
{
|
||||
string roomName { get; }
|
||||
RoomData roomData { get; }
|
||||
RoomInfo roomInfo { get; }
|
||||
IReadOnlyList<IPlayer> players { get; }
|
||||
RoomType roomType { get; }
|
||||
|
||||
UniTask<bool> JoinAsync(IPlayer player, CancellationToken token);
|
||||
UniTask<bool> Quit(IPlayer player);
|
||||
UniTask<bool> JoinAsync(IPlayer player, CancellationToken token);
|
||||
UniTask<bool> Quit(IPlayer player);
|
||||
|
||||
void SetIsCanReturnJinBei(bool isCan);
|
||||
void SetIsCanReturnJinBei(bool isCan);
|
||||
|
||||
List<IPlayer> QuitAndClearAll();
|
||||
List<IPlayer> QuitAndClearAll();
|
||||
|
||||
// float ClearAll();
|
||||
void Dispose();
|
||||
void Dispose();
|
||||
|
||||
bool InvestmentJinBei(IPlayer player, float jinbei);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Room : IRoom
|
||||
{
|
||||
private GameObject self;
|
||||
private RoomInfo _roomInfo;
|
||||
private RoomData _roomData;
|
||||
private string _roomName;
|
||||
private bool _isCanReturnJinBei;
|
||||
|
||||
public RoomType roomType => this._roomData.roomType;
|
||||
|
||||
public string roomName => this._roomName;
|
||||
|
||||
|
||||
public RoomData roomData => this._roomData;
|
||||
public RoomInfo roomInfo => this._roomInfo;
|
||||
|
||||
public IReadOnlyList<IPlayer> players => this._roomData.players;
|
||||
|
||||
public Room(RoomType roomType, GameObject roomGo)
|
||||
{
|
||||
this._roomData = new RoomData(roomType);
|
||||
_roomName = roomType.ToString();
|
||||
|
||||
// view
|
||||
this._roomInfo = roomGo.GetComponent<RoomInfo>();
|
||||
this._roomInfo.SetRoom(this);
|
||||
this.self = roomGo;
|
||||
this._roomData.jinBeiCallback += this._roomInfo.UpdateNumber;
|
||||
bool InvestmentJinBei(IPlayer player, float jinbei);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
[System.Serializable]
|
||||
public class Room : IRoom
|
||||
{
|
||||
this._roomData.jinBeiCallback -= this._roomInfo.UpdateNumber;
|
||||
this._roomData.Reset();
|
||||
private GameObject self;
|
||||
private RoomInfo _roomInfo;
|
||||
private RoomData _roomData;
|
||||
private string _roomName;
|
||||
private bool _isCanReturnJinBei;
|
||||
|
||||
this.self = null;
|
||||
this._roomInfo = null;
|
||||
this._roomData = null;
|
||||
this._roomName = null;
|
||||
}
|
||||
public RoomType roomType => this._roomData.roomType;
|
||||
|
||||
public async UniTask<bool> JoinAsync(IPlayer player, CancellationToken token)
|
||||
{
|
||||
if (this.players.Contains(player))
|
||||
return false;
|
||||
public string roomName => this._roomName;
|
||||
|
||||
|
||||
public RoomData roomData => this._roomData;
|
||||
public RoomInfo roomInfo => this._roomInfo;
|
||||
|
||||
public IReadOnlyList<IPlayer> players => this._roomData.players;
|
||||
|
||||
public Room(RoomType roomType, GameObject roomGo)
|
||||
{
|
||||
this._roomData = new RoomData(roomType);
|
||||
_roomName = roomType.ToString();
|
||||
|
||||
// view
|
||||
this._roomInfo = roomGo.GetComponent<RoomInfo>();
|
||||
this._roomInfo.SetRoom(this);
|
||||
this.self = roomGo;
|
||||
this._roomData.jinBeiCallback += this._roomInfo.UpdateNumber;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this._roomData.jinBeiCallback -= this._roomInfo.UpdateNumber;
|
||||
this._roomData.Reset();
|
||||
|
||||
this.self = null;
|
||||
this._roomInfo = null;
|
||||
this._roomData = null;
|
||||
this._roomName = null;
|
||||
}
|
||||
|
||||
public async UniTask<bool> JoinAsync(IPlayer player, CancellationToken token)
|
||||
{
|
||||
if (this.players.Contains(player))
|
||||
return false;
|
||||
// Debug.Log($"{player.playerName} join {roomType} !!");
|
||||
bool res = await player.WaitMoveRoomAsync(this, token);
|
||||
this._roomData.AddPlayer(player);
|
||||
return true;
|
||||
}
|
||||
bool res = await player.WaitMoveRoomAsync(this, token);
|
||||
this._roomData.AddPlayer(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async UniTask<bool> Quit(IPlayer player)
|
||||
{
|
||||
if (!this.players.Contains(player))
|
||||
return false;
|
||||
Debug.Log($"{player.playerName} quit {roomType} !!");
|
||||
|
||||
var f = this._roomData.RemovePlayer(player);
|
||||
EventManager.Instance.FireNow(this, new ReturnPlayerJinBeiEventArgs(player, f));
|
||||
|
||||
await UniTask.Yield();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetIsCanReturnJinBei(bool isCan)
|
||||
{
|
||||
this._isCanReturnJinBei = isCan;
|
||||
}
|
||||
|
||||
public List<IPlayer> QuitAndClearAll()
|
||||
{
|
||||
if (this._isCanReturnJinBei)
|
||||
public async UniTask<bool> Quit(IPlayer player)
|
||||
{
|
||||
// 归还金贝
|
||||
var dictionary = this._roomData.ReturnPlayerAndJinBei();
|
||||
foreach (var player in dictionary.Keys)
|
||||
if (!this.players.Contains(player))
|
||||
return false;
|
||||
Debug.Log($"{player.playerName} quit {roomType} !!");
|
||||
|
||||
var f = this._roomData.RemovePlayer(player);
|
||||
EventManager.Instance.FireNow(this, new ReturnPlayerJinBeiEventArgs(player, f));
|
||||
|
||||
await UniTask.Yield();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetIsCanReturnJinBei(bool isCan)
|
||||
{
|
||||
this._isCanReturnJinBei = isCan;
|
||||
}
|
||||
|
||||
public List<IPlayer> QuitAndClearAll()
|
||||
{
|
||||
if (this._isCanReturnJinBei)
|
||||
{
|
||||
Debug.Log($"return player {player.playerName} jinBei : {dictionary[player]}");
|
||||
EventManager.Instance.FireNow(this, new ReturnPlayerJinBeiEventArgs(player, dictionary[player]));
|
||||
// 归还金贝
|
||||
var dictionary = this._roomData.ReturnPlayerAndJinBei();
|
||||
foreach (var player in dictionary.Keys)
|
||||
{
|
||||
Debug.Log($"return player {player.playerName} jinBei : {dictionary[player]}");
|
||||
EventManager.Instance.FireNow(this, new ReturnPlayerJinBeiEventArgs(player, dictionary[player]));
|
||||
}
|
||||
}
|
||||
|
||||
var list = new List<IPlayer>(_roomData.players);
|
||||
this._roomData.Reset();
|
||||
return list;
|
||||
}
|
||||
|
||||
var list = new List<IPlayer>(_roomData.players);
|
||||
this._roomData.Reset();
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool InvestmentJinBei(IPlayer player, float jinBei)
|
||||
{
|
||||
if (!this.players.Contains(player))
|
||||
public bool InvestmentJinBei(IPlayer player, float jinBei)
|
||||
{
|
||||
Debug.LogWarning($"{roomType} dont have {player.playerName}");
|
||||
return false;
|
||||
}
|
||||
if (!this.players.Contains(player))
|
||||
{
|
||||
Debug.LogWarning($"{roomType} dont have {player.playerName}");
|
||||
return false;
|
||||
}
|
||||
|
||||
this._roomData.AddJinBei(player, jinBei);
|
||||
return true;
|
||||
this._roomData.AddJinBei(player, jinBei);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,110 +4,111 @@ using Spine;
|
|||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Spine;
|
||||
|
||||
public interface ISpineAnimator
|
||||
namespace Game.Spine
|
||||
{
|
||||
SkeletonAnimation skeletonAnimation { get; }
|
||||
Action<TrackEntry> complete { get; set; }
|
||||
void PlayAni(string animaName, bool isLoop);
|
||||
UniTask PlayAniAsync(string animaName);
|
||||
UniTask PlayAniAsync(string animaName, float time);
|
||||
|
||||
/// <summary>
|
||||
/// 从某一帧开始播放某个动画
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="animaName"></param>
|
||||
/// <param name="isLoop"></param>
|
||||
void PlayAniFromPoint(int index, string animaName, bool isLoop);
|
||||
|
||||
void StopAni();
|
||||
}
|
||||
|
||||
public class SpineAnimator : MonoBehaviour, ISpineAnimator
|
||||
{
|
||||
[SerializeField] private SkeletonAnimation _skeletonAnimation;
|
||||
private bool _isPlaying;
|
||||
|
||||
public SkeletonAnimation skeletonAnimation => this._skeletonAnimation;
|
||||
|
||||
public Action<TrackEntry> complete { get; set; }
|
||||
|
||||
private void Awake()
|
||||
public interface ISpineAnimator
|
||||
{
|
||||
if (this._skeletonAnimation == null)
|
||||
throw new NullReferenceException();
|
||||
SkeletonAnimation skeletonAnimation { get; }
|
||||
Action<TrackEntry> complete { get; set; }
|
||||
void PlayAni(string animaName, bool isLoop);
|
||||
UniTask PlayAniAsync(string animaName);
|
||||
UniTask PlayAniAsync(string animaName, float time);
|
||||
|
||||
complete = null;
|
||||
_isPlaying = false;
|
||||
/// <summary>
|
||||
/// 从某一帧开始播放某个动画
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="animaName"></param>
|
||||
/// <param name="isLoop"></param>
|
||||
void PlayAniFromPoint(int index, string animaName, bool isLoop);
|
||||
|
||||
void StopAni();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
public class SpineAnimator : MonoBehaviour, ISpineAnimator
|
||||
{
|
||||
this._skeletonAnimation.state.Complete += Finish;
|
||||
this.StopAni();
|
||||
}
|
||||
[SerializeField] private SkeletonAnimation _skeletonAnimation;
|
||||
private bool _isPlaying;
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
this._skeletonAnimation.state.Complete -= Finish;
|
||||
}
|
||||
public SkeletonAnimation skeletonAnimation => this._skeletonAnimation;
|
||||
|
||||
private void Finish(TrackEntry trackentry)
|
||||
{
|
||||
// Debug.Log("动画播放完成: " + trackentry.Animation.Name);
|
||||
_isPlaying = false;
|
||||
complete?.Invoke(trackentry);
|
||||
}
|
||||
public Action<TrackEntry> complete { get; set; }
|
||||
|
||||
public virtual void PlayAni(string animaName, bool isLoop = false)
|
||||
{
|
||||
_skeletonAnimation.AnimationName = animaName;
|
||||
this._skeletonAnimation.loop = isLoop;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仅适用于一次性播放动画,循环动画勿用
|
||||
/// </summary>
|
||||
/// <param name="animaName"></param>
|
||||
/// <returns></returns>
|
||||
public async UniTask PlayAniAsync(string animaName)
|
||||
{
|
||||
_isPlaying = true;
|
||||
this._skeletonAnimation.loop = false;
|
||||
this._skeletonAnimation.AnimationName = animaName;
|
||||
|
||||
while (_isPlaying)
|
||||
private void Awake()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
if (this._skeletonAnimation == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
complete = null;
|
||||
_isPlaying = false;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
this._skeletonAnimation.state.Complete += Finish;
|
||||
this.StopAni();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
this._skeletonAnimation.state.Complete -= Finish;
|
||||
}
|
||||
|
||||
private void Finish(TrackEntry trackentry)
|
||||
{
|
||||
// Debug.Log("动画播放完成: " + trackentry.Animation.Name);
|
||||
_isPlaying = false;
|
||||
complete?.Invoke(trackentry);
|
||||
}
|
||||
|
||||
public virtual void PlayAni(string animaName, bool isLoop = false)
|
||||
{
|
||||
_skeletonAnimation.AnimationName = animaName;
|
||||
this._skeletonAnimation.loop = isLoop;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仅适用于一次性播放动画,循环动画勿用
|
||||
/// </summary>
|
||||
/// <param name="animaName"></param>
|
||||
/// <returns></returns>
|
||||
public async UniTask PlayAniAsync(string animaName)
|
||||
{
|
||||
_isPlaying = true;
|
||||
this._skeletonAnimation.loop = false;
|
||||
this._skeletonAnimation.AnimationName = animaName;
|
||||
|
||||
while (_isPlaying)
|
||||
{
|
||||
await UniTask.Yield();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放某个动画多少秒
|
||||
/// </summary>
|
||||
/// <param name="animaName"></param>
|
||||
/// <param name="time"></param>
|
||||
public async UniTask PlayAniAsync(string animaName, float time)
|
||||
{
|
||||
this._skeletonAnimation.loop = true;
|
||||
this._skeletonAnimation.AnimationName = animaName;
|
||||
float f = 0;
|
||||
f = time * 1000;
|
||||
|
||||
await UniTask.Delay((int)f);
|
||||
this._skeletonAnimation.loop = false;
|
||||
StopAni();
|
||||
}
|
||||
|
||||
public void PlayAniFromPoint(int index, string animaName, bool isLoop)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void StopAni()
|
||||
{
|
||||
_skeletonAnimation.AnimationName = default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放某个动画多少秒
|
||||
/// </summary>
|
||||
/// <param name="animaName"></param>
|
||||
/// <param name="time"></param>
|
||||
public async UniTask PlayAniAsync(string animaName, float time)
|
||||
{
|
||||
this._skeletonAnimation.loop = true;
|
||||
this._skeletonAnimation.AnimationName = animaName;
|
||||
float f = 0;
|
||||
f = time * 1000;
|
||||
|
||||
await UniTask.Delay((int)f);
|
||||
this._skeletonAnimation.loop = false;
|
||||
StopAni();
|
||||
}
|
||||
|
||||
public void PlayAniFromPoint(int index, string animaName, bool isLoop)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void StopAni()
|
||||
{
|
||||
_skeletonAnimation.AnimationName = default;
|
||||
}
|
||||
}
|
|
@ -2,28 +2,29 @@
|
|||
using System.Collections.Generic;
|
||||
using Sirenix.Utilities;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public static class AssemblyManager
|
||||
namespace Game
|
||||
{
|
||||
private static List<Type> _types ;
|
||||
|
||||
public static void Initialize()
|
||||
public static class AssemblyManager
|
||||
{
|
||||
var types = typeof(AssemblyManager).Assembly.GetTypes();
|
||||
_types = new List<Type>(types);
|
||||
}
|
||||
private static List<Type> _types ;
|
||||
|
||||
public static void GetTypesInhertType<T>(Type baseType, List<(Type, T)> types) where T : Attribute
|
||||
{
|
||||
foreach (var type in _types)
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!baseType.IsAssignableFrom(type))
|
||||
continue;
|
||||
var attribute = type.GetCustomAttribute<T>();
|
||||
if (attribute == null)
|
||||
continue;
|
||||
types.Add((type, attribute));
|
||||
var types = typeof(AssemblyManager).Assembly.GetTypes();
|
||||
_types = new List<Type>(types);
|
||||
}
|
||||
|
||||
public static void GetTypesInhertType<T>(Type baseType, List<(Type, T)> types) where T : Attribute
|
||||
{
|
||||
foreach (var type in _types)
|
||||
{
|
||||
if (!baseType.IsAssignableFrom(type))
|
||||
continue;
|
||||
var attribute = type.GetCustomAttribute<T>();
|
||||
if (attribute == null)
|
||||
continue;
|
||||
types.Add((type, attribute));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +1,29 @@
|
|||
using UnityEngine.UI;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[UIType(UIType.GameSceneHelpUI)]
|
||||
public class GameSceneHelpUI : UIBase
|
||||
namespace Game
|
||||
{
|
||||
private Button btn_Back;
|
||||
|
||||
public override void Init()
|
||||
[UIType(UIType.GameSceneHelpUI)]
|
||||
public class GameSceneHelpUI : UIBase
|
||||
{
|
||||
base.Init();
|
||||
this.btn_Back = this.self.transform.FindChildDeep<Button>("btn_Back");
|
||||
private Button btn_Back;
|
||||
|
||||
this.btn_Back.onClick.AddListener(this.ClickSureButton);
|
||||
}
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.btn_Back = this.self.transform.FindChildDeep<Button>("btn_Back");
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
this.btn_Back.onClick.RemoveListener(this.ClickSureButton);
|
||||
}
|
||||
this.btn_Back.onClick.AddListener(this.ClickSureButton);
|
||||
}
|
||||
|
||||
private void ClickSureButton()
|
||||
{
|
||||
Game.uiManager.CloseLast();
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
this.btn_Back.onClick.RemoveListener(this.ClickSureButton);
|
||||
}
|
||||
|
||||
private void ClickSureButton()
|
||||
{
|
||||
Game.uiManager.CloseLast();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,44 +3,45 @@ using Cysharp.Threading.Tasks;
|
|||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[UIType(UIType.GameSceneResultUI)]
|
||||
public class GameSceneResultUI : UIBase
|
||||
namespace Game
|
||||
{
|
||||
private Image img_Lose;
|
||||
private Image img_Success;
|
||||
private TMP_Text txt_LoseContent;
|
||||
private TMP_Text txt_SuccessContent;
|
||||
|
||||
public override void Init()
|
||||
[UIType(UIType.GameSceneResultUI)]
|
||||
public class GameSceneResultUI : UIBase
|
||||
{
|
||||
base.Init();
|
||||
this.img_Lose = this.self.transform.FindChildDeep<Image>("img_Lose");
|
||||
this.img_Success = this.self.transform.FindChildDeep<Image>("img_Success");
|
||||
private Image img_Lose;
|
||||
private Image img_Success;
|
||||
private TMP_Text txt_LoseContent;
|
||||
private TMP_Text txt_SuccessContent;
|
||||
|
||||
this.txt_LoseContent = this.self.transform.FindChildDeep<TMP_Text>("txt_LoseContent");
|
||||
this.txt_SuccessContent = this.self.transform.FindChildDeep<TMP_Text>("txt_SuccessContent");
|
||||
}
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.img_Lose = this.self.transform.FindChildDeep<Image>("img_Lose");
|
||||
this.img_Success = this.self.transform.FindChildDeep<Image>("img_Success");
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
this.txt_LoseContent = this.self.transform.FindChildDeep<TMP_Text>("txt_LoseContent");
|
||||
this.txt_SuccessContent = this.self.transform.FindChildDeep<TMP_Text>("txt_SuccessContent");
|
||||
}
|
||||
|
||||
public async UniTask WaitShowAndCloseResultAsync(CancellationToken token)
|
||||
{
|
||||
await UniTask.Delay(4000);
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
Game.uiManager.CloseLast();
|
||||
}
|
||||
public async UniTask WaitShowAndCloseResultAsync(CancellationToken token)
|
||||
{
|
||||
await UniTask.Delay(4000);
|
||||
|
||||
public void SetResult(string str, bool isSuccess)
|
||||
{
|
||||
img_Success.gameObject.SetActive(isSuccess);
|
||||
this.img_Lose.gameObject.SetActive(!isSuccess);
|
||||
Game.uiManager.CloseLast();
|
||||
}
|
||||
|
||||
this.txt_SuccessContent.text = str;
|
||||
this.txt_LoseContent.text = str;
|
||||
public void SetResult(string str, bool isSuccess)
|
||||
{
|
||||
img_Success.gameObject.SetActive(isSuccess);
|
||||
this.img_Lose.gameObject.SetActive(!isSuccess);
|
||||
|
||||
this.txt_SuccessContent.text = str;
|
||||
this.txt_LoseContent.text = str;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +1,26 @@
|
|||
using TMPro;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[UIType(UIType.GlobalLogOnlyAppUI)]
|
||||
public class GlobalLogOnlyAppUI : UIBase
|
||||
namespace Game
|
||||
{
|
||||
private TMP_Text txt_Content;
|
||||
|
||||
public override void Init()
|
||||
[UIType(UIType.GlobalLogOnlyAppUI)]
|
||||
public class GlobalLogOnlyAppUI : UIBase
|
||||
{
|
||||
base.Init();
|
||||
this.txt_Content = this.self.transform.FindChildDeep<TMP_Text>("txt_Content");
|
||||
}
|
||||
private TMP_Text txt_Content;
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.txt_Content = this.self.transform.FindChildDeep<TMP_Text>("txt_Content");
|
||||
}
|
||||
|
||||
public void AddLog(string message)
|
||||
{
|
||||
this.txt_Content.text += message + "\n";
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
public void AddLog(string message)
|
||||
{
|
||||
this.txt_Content.text += message + "\n";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +1,36 @@
|
|||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Game;
|
||||
|
||||
[UIType(UIType.InputNameUI)]
|
||||
public class InputNameUI : UIBase
|
||||
namespace Game
|
||||
{
|
||||
private TMP_InputField _inputField;
|
||||
private Button _button;
|
||||
|
||||
public override void Init()
|
||||
[UIType(UIType.InputNameUI)]
|
||||
public class InputNameUI : UIBase
|
||||
{
|
||||
base.Init();
|
||||
this._inputField = self.transform.FindChildDeep<TMP_InputField>("inp_Name");
|
||||
this._button = self.transform.FindChildDeep<Button>("btn_Sure");
|
||||
private TMP_InputField _inputField;
|
||||
private Button _button;
|
||||
|
||||
this._button.onClick.AddListener(ClickSureButton);
|
||||
}
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this._inputField = self.transform.FindChildDeep<TMP_InputField>("inp_Name");
|
||||
this._button = self.transform.FindChildDeep<Button>("btn_Sure");
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
this._button.onClick.RemoveListener(ClickSureButton);
|
||||
}
|
||||
this._button.onClick.AddListener(ClickSureButton);
|
||||
}
|
||||
|
||||
private void ClickSureButton()
|
||||
{
|
||||
var inputFieldText = this._inputField.text;
|
||||
if (string.IsNullOrEmpty(inputFieldText))
|
||||
return;
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
this._button.onClick.RemoveListener(ClickSureButton);
|
||||
}
|
||||
|
||||
EventManager.Instance.FireNow(this, new InputNameFinishEventArgs(inputFieldText));
|
||||
private void ClickSureButton()
|
||||
{
|
||||
var inputFieldText = this._inputField.text;
|
||||
if (string.IsNullOrEmpty(inputFieldText))
|
||||
return;
|
||||
|
||||
EventManager.Instance.FireNow(this, new InputNameFinishEventArgs(inputFieldText));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public class WayPointFlag: MonoBehaviour
|
||||
namespace Game
|
||||
{
|
||||
public class WayPointFlag: MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -98,7 +98,7 @@ public class TwoByTwoTransformEffectExampleEditor : UnityEditor.Editor {
|
|||
Color originalColor = UnityEditor.Handles.color;
|
||||
UnityEditor.Handles.color = color;
|
||||
UnityEditor.Handles.DrawLine(transform.position, transform.TransformPoint(v));
|
||||
var fmh_101_103_638483627229624472 = Quaternion.identity; v = transform.InverseTransformPoint(UnityEditor.Handles.FreeMoveHandle(transform.TransformPoint(v), 0.3f, Vector3.zero, UnityEditor.Handles.CubeHandleCap));
|
||||
var fmh_101_103_638483627229624472 = Quaternion.identity; v = transform.InverseTransformPoint(UnityEditor.Handles.FreeMoveHandle(transform.TransformPoint(v), Quaternion.identity, 0.3f, Vector3.zero, UnityEditor.Handles.CubeHandleCap));
|
||||
UnityEditor.Handles.color = originalColor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: dragon_dragon
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: dragon_dragon2
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: dragon_dragon3
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: dragon_dragon4
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: dragon_dragon5
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: dragon_dragon6
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: eyes_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Equipment_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FS_White_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Gauge_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: goblins_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: hero-pro_Material
|
||||
m_Shader: {fileID: 4800000, guid: 45495790b394f894a967dbf44489b57b, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Raggedy Spineboy_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: raptor_Material
|
||||
m_Shader: {fileID: 4800000, guid: 522f03282fd79be47b306e2ef4b593fd, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Doi_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: stretchyman-diffuse-pma_Material
|
||||
m_Shader: {fileID: 4800000, guid: 2ce511398fb980f41b7d316c51534590, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ALPHAPREMULTIPLY_ON
|
||||
- _EMISSION
|
||||
|
@ -28,7 +26,6 @@ Material:
|
|||
IGNOREPROJECTOR: true
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: mix-and-match-pma_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: raptor-pma_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spineboy-pro_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: spineboy_Material
|
||||
m_Shader: {fileID: 4800000, guid: 522f03282fd79be47b306e2ef4b593fd, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -9,8 +9,6 @@ Material:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: whirlyblendmodes_Material
|
||||
m_Shader: {fileID: 4800000, guid: 1e8a610c9e01c3648bac42585e5fc676, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
|
@ -20,7 +18,6 @@ Material:
|
|||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
-nullable:enable
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d61f4871a540437ab7819672db9d1d03
|
||||
timeCreated: 1712415087
|
|
@ -25,91 +25,91 @@
|
|||
"dependencies": {
|
||||
"com.unity.modules.ai": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.collab-proxy": {
|
||||
"version": "2.2.0",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.editorcoroutines": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ext.nunit": {
|
||||
"version": "1.0.6",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.feature.development": {
|
||||
"version": "1.0.1",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.ide.visualstudio": "2.0.18",
|
||||
"com.unity.ide.rider": "3.0.21",
|
||||
"com.unity.ide.visualstudio": "2.0.17",
|
||||
"com.unity.ide.rider": "3.0.18",
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.editorcoroutines": "1.0.0",
|
||||
"com.unity.performance.profile-analyzer": "1.2.2",
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.unity.testtools.codecoverage": "1.2.3"
|
||||
"com.unity.test-framework": "1.1.31",
|
||||
"com.unity.testtools.codecoverage": "1.2.2"
|
||||
}
|
||||
},
|
||||
"com.unity.ide.rider": {
|
||||
"version": "3.0.21",
|
||||
"version": "3.0.18",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": "1.0.6"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.18",
|
||||
"version": "2.0.17",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.9"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ide.vscode": {
|
||||
"version": "1.2.5",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.performance.profile-analyzer": {
|
||||
"version": "1.2.2",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.scriptablebuildpipeline": {
|
||||
"version": "1.21.21",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.settings-manager": {
|
||||
"version": "2.0.1",
|
||||
"version": "1.0.3",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.1.33",
|
||||
"version": "1.1.31",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
|
@ -117,17 +117,17 @@
|
|||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.testtools.codecoverage": {
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.2",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.0.16",
|
||||
"com.unity.settings-manager": "1.0.1"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.textmeshpro": {
|
||||
"version": "3.0.6",
|
||||
|
@ -136,7 +136,7 @@
|
|||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.timeline": {
|
||||
"version": "1.7.6",
|
||||
|
@ -148,7 +148,7 @@
|
|||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ugui": {
|
||||
"version": "1.0.0",
|
||||
|
@ -291,6 +291,17 @@
|
|||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.uielementsnative": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.uielementsnative": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
|
|
|
@ -13,15 +13,15 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_EnablePreReleasePackages: 0
|
||||
m_EnablePackageDependencies: 0
|
||||
m_AdvancedSettingsExpanded: 1
|
||||
m_ScopedRegistriesSettingsExpanded: 1
|
||||
m_SeeAllPackageVersions: 0
|
||||
m_DismissPreviewPackagesInUse: 0
|
||||
oneTimeWarningShown: 0
|
||||
m_Registries:
|
||||
- m_Id: main
|
||||
m_Name:
|
||||
m_Url: https://packages.unity.cn
|
||||
m_Url: https://packages.unity.com
|
||||
m_Scopes: []
|
||||
m_IsDefault: 1
|
||||
m_Capabilities: 7
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"m_Name": "Settings",
|
||||
"m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json",
|
||||
"m_Dictionary": {
|
||||
"m_DictionaryValues": []
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
m_EditorVersion: 2022.3.0f1c1
|
||||
m_EditorVersionWithRevision: 2022.3.0f1c1 (aad67108fc1f)
|
||||
m_EditorVersion: 2021.3.22f1
|
||||
m_EditorVersionWithRevision: 2021.3.22f1 (b6c551784ba3)
|
||||
|
|
Loading…
Reference in New Issue