添加转向;完善动画脚本
parent
286940d6c8
commit
839c9af9e1
|
@ -28,7 +28,7 @@ Transform:
|
|||
m_GameObject: {fileID: 1517667708138926372}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
|
||||
m_LocalScale: {x: 0.4, y: 0.4, z: 0.4}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2468889828458600031}
|
||||
|
|
|
@ -236,7 +236,7 @@ public class BFS<T>
|
|||
|
||||
if (node == null || node == begin)
|
||||
{
|
||||
Debug.Log("结束了");
|
||||
// Debug.Log("结束了");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,11 @@ public class BossInfo : MonoBehaviour
|
|||
|
||||
async UniTask MoveAsync(Vector2 endPos, CancellationToken token)
|
||||
{
|
||||
var distance = Vector3.Distance(this.transform.position, endPos);
|
||||
var position = this.transform.position;
|
||||
var distance = Vector3.Distance(position, endPos);
|
||||
var time = distance / this.speed;
|
||||
|
||||
CheckIsNeedTurn(position, endPos);
|
||||
|
||||
this.transform.DOMove(endPos, time).SetEase(Ease.Linear);
|
||||
float delayTimeSpan = time * 1000;
|
||||
|
@ -90,4 +93,16 @@ public class BossInfo : MonoBehaviour
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce88d2df0fb5493ca6b21f482df86666
|
||||
timeCreated: 1712815387
|
|
@ -0,0 +1,22 @@
|
|||
namespace Game.Log;
|
||||
|
||||
/// <summary>
|
||||
/// 便于真机上取消log
|
||||
/// </summary>
|
||||
public static class Log
|
||||
{
|
||||
public static void Debug(object message)
|
||||
{
|
||||
UnityEngine.Debug.Log(message);
|
||||
}
|
||||
|
||||
public static void LogWarning(object message)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning(message);
|
||||
}
|
||||
|
||||
public static void LogError(object message)
|
||||
{
|
||||
UnityEngine.Debug.LogError(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d446865da073480cb1dab61ec2f5db27
|
||||
timeCreated: 1712815398
|
|
@ -70,7 +70,7 @@ internal class Player : IPlayer
|
|||
|
||||
await UniTask.Yield();
|
||||
var moveAsync = await this.MoveAsync(wayPoints, token);
|
||||
Debug.Log("Move finish !!!");
|
||||
// Debug.Log("Move finish !!!");
|
||||
return moveAsync;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,14 +50,29 @@ namespace Game.Player
|
|||
|
||||
async UniTask MoveAsync(Vector2 endPos, CancellationToken token)
|
||||
{
|
||||
var distance = Vector3.Distance(this.transform.position, endPos);
|
||||
var position = transform.position;
|
||||
var distance = Vector3.Distance(position, endPos);
|
||||
var time = distance / this.speed;
|
||||
|
||||
CheckIsNeedTurn(position, endPos);
|
||||
|
||||
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}");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -62,6 +62,9 @@ public class RoomManager : ManagerBase, IRoomManager
|
|||
|
||||
public void SetCurrentRoom(RoomType roomType)
|
||||
{
|
||||
if (roomType == RoomType.出生点)
|
||||
return;
|
||||
|
||||
if (this._rooms.TryGetValue(roomType, out var room))
|
||||
this._currentRoom = room;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class Room : IRoom
|
|||
{
|
||||
if (this.players.Contains(player))
|
||||
return false;
|
||||
Debug.Log($"{player.playerName} join {roomType} !!");
|
||||
// Debug.Log($"{player.playerName} join {roomType} !!");
|
||||
bool res = await player.WaitMoveRoomAsync(this, token);
|
||||
this._roomData.AddPlayer(player);
|
||||
return true;
|
||||
|
@ -86,7 +86,9 @@ public class Room : IRoom
|
|||
return false;
|
||||
Debug.Log($"{player.playerName} quit {roomType} !!");
|
||||
|
||||
this._roomData.RemovePlayer(player);
|
||||
var f = this._roomData.RemovePlayer(player);
|
||||
EventManager.Instance.FireNow(this, new ReturnPlayerJinBeiEventArgs(player, f));
|
||||
|
||||
await UniTask.Yield();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -32,13 +32,15 @@ namespace Game.Room
|
|||
this.playersDic.Add(player, 0);
|
||||
}
|
||||
|
||||
public void RemovePlayer(IPlayer player)
|
||||
public float RemovePlayer(IPlayer player)
|
||||
{
|
||||
if (this.playersDic.TryGetValue(player, out var value))
|
||||
{
|
||||
UpdateJinBei(-value);
|
||||
this.playersDic.Remove(player);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public bool AddJinBei(IPlayer player, float jinBei)
|
||||
|
|
|
@ -11,8 +11,17 @@ public interface ISpineAnimator
|
|||
SkeletonAnimation skeletonAnimation { get; }
|
||||
Action<TrackEntry> complete { get; set; }
|
||||
void PlayAni(string animaName, bool isLoop);
|
||||
UniTask<bool> PlayAniAsync(string animaName);
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -63,7 +72,7 @@ public class SpineAnimator : MonoBehaviour, ISpineAnimator
|
|||
/// </summary>
|
||||
/// <param name="animaName"></param>
|
||||
/// <returns></returns>
|
||||
public async UniTask<bool> PlayAniAsync(string animaName)
|
||||
public async UniTask PlayAniAsync(string animaName)
|
||||
{
|
||||
_isPlaying = true;
|
||||
this._skeletonAnimation.loop = false;
|
||||
|
@ -73,8 +82,6 @@ public class SpineAnimator : MonoBehaviour, ISpineAnimator
|
|||
{
|
||||
await UniTask.Yield();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -94,6 +101,11 @@ public class SpineAnimator : MonoBehaviour, ISpineAnimator
|
|||
StopAni();
|
||||
}
|
||||
|
||||
public void PlayAniFromPoint(int index, string animaName, bool isLoop)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void StopAni()
|
||||
{
|
||||
_skeletonAnimation.AnimationName = default;
|
||||
|
|
|
@ -82,6 +82,12 @@ namespace Game
|
|||
return;
|
||||
}
|
||||
|
||||
if (Game.roomManager.currentRoom == null)
|
||||
{
|
||||
UnityEngine.Debug.Log("currentRoom is null");
|
||||
return;
|
||||
}
|
||||
|
||||
jinBei = 0;
|
||||
var inputFieldText = this.dropdown.captionText.text;
|
||||
if (string.IsNullOrEmpty(inputFieldText))
|
||||
|
|
Loading…
Reference in New Issue