2026-01-21 20:27:45 +05:30
|
|
|
using System;
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public enum PlayerState
|
|
|
|
|
{
|
|
|
|
|
InHome,
|
|
|
|
|
InSafeZone,
|
|
|
|
|
Moving,
|
|
|
|
|
InFinishingPath,
|
|
|
|
|
HasFinished
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PlayerPawn : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private PlayerState playerState;
|
|
|
|
|
|
|
|
|
|
private bool canSelectPlayerFromHome;
|
|
|
|
|
public int CurrentTileIndex
|
|
|
|
|
{
|
|
|
|
|
get; private set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private GameplayManager gameplayManager;
|
|
|
|
|
|
|
|
|
|
public void SetPlayerSelectionState(bool state)
|
|
|
|
|
{
|
|
|
|
|
canSelectPlayerFromHome = state;
|
|
|
|
|
if (canSelectPlayerFromHome)
|
|
|
|
|
{
|
|
|
|
|
// Play animation for selecting any of the players
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 20:50:41 +05:30
|
|
|
public void SetCurrentTileIndex(int tileIndex)
|
2026-01-21 20:27:45 +05:30
|
|
|
{
|
2026-01-22 20:50:41 +05:30
|
|
|
CurrentTileIndex = tileIndex;
|
2026-01-21 20:27:45 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveToTile(Vector3 startingPoint, Action onComplete, int tileIndex)
|
|
|
|
|
{
|
|
|
|
|
CurrentTileIndex = tileIndex;
|
|
|
|
|
transform.DOMove(startingPoint, 0.1f).onComplete = () => onComplete?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 20:50:41 +05:30
|
|
|
public void MoveToTileSubPosition(Vector3 targetPoint)
|
|
|
|
|
{
|
|
|
|
|
transform.DOMove(targetPoint, 0.1f);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-21 20:27:45 +05:30
|
|
|
// when he is defeated
|
|
|
|
|
public void MoveBackToHome()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PlayerState GetPlayerState() => playerState;
|
|
|
|
|
|
|
|
|
|
public void SetPlayerState(PlayerState state)
|
|
|
|
|
{
|
|
|
|
|
playerState = state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMouseDown()
|
|
|
|
|
{
|
|
|
|
|
if (!canSelectPlayerFromHome) return;
|
|
|
|
|
|
|
|
|
|
SetGameplayManager();
|
|
|
|
|
gameplayManager.OnPawnSelected(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetGameplayManager()
|
|
|
|
|
{
|
|
|
|
|
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
|
|
|
|
}
|
|
|
|
|
}
|