2026-01-23 15:32:48 +05:30
|
|
|
using UnityEngine;
|
2026-02-11 19:53:16 +05:30
|
|
|
using System.Collections.Generic;
|
2026-01-23 15:32:48 +05:30
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
public class PlayerBaseData
|
|
|
|
|
{
|
2026-01-26 19:48:55 +05:30
|
|
|
public PlayerType playerType;
|
2026-01-23 15:32:48 +05:30
|
|
|
public PlayerBase playerBase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class PlayerBaseHandler : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private PlayerBase[] playerBases;
|
|
|
|
|
|
2026-01-26 19:48:55 +05:30
|
|
|
private Dictionary<PlayerType, PlayerBase> playerBasesDict = new Dictionary<PlayerType, PlayerBase>();
|
2026-01-26 13:03:50 +05:30
|
|
|
|
2026-01-26 19:48:55 +05:30
|
|
|
public void InitPlayerTypes(List<PlayerType> playerTypes)
|
2026-01-23 15:32:48 +05:30
|
|
|
{
|
|
|
|
|
foreach (PlayerBase playerBase in playerBases)
|
|
|
|
|
{
|
|
|
|
|
if (playerTypes.Contains(playerBase.GetPlayerType()))
|
|
|
|
|
{
|
2026-01-26 13:03:50 +05:30
|
|
|
playerBase.InitPlayerData();
|
2026-01-23 15:32:48 +05:30
|
|
|
playerBase.gameObject.SetActive(true);
|
2026-01-26 13:03:50 +05:30
|
|
|
|
|
|
|
|
if (!playerBasesDict.ContainsKey(playerBase.GetPlayerType()))
|
|
|
|
|
playerBasesDict.Add(playerBase.GetPlayerType(), playerBase);
|
|
|
|
|
else
|
|
|
|
|
playerBasesDict[playerBase.GetPlayerType()] = playerBase;
|
2026-01-23 15:32:48 +05:30
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
playerBase.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-26 19:48:55 +05:30
|
|
|
public PlayerBase GetPlayerBase(PlayerType playerType)
|
2026-01-23 15:32:48 +05:30
|
|
|
{
|
2026-01-26 13:03:50 +05:30
|
|
|
return playerBasesDict[playerType];
|
2026-01-23 15:32:48 +05:30
|
|
|
}
|
2026-02-02 19:27:17 +05:30
|
|
|
|
|
|
|
|
public void ResetPlayerBaseData()
|
|
|
|
|
{
|
|
|
|
|
foreach (var playerBasePair in playerBasesDict)
|
|
|
|
|
{
|
|
|
|
|
playerBasePair.Value.ResetPlayerDatas();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SendPlayerToHome(PlayerPawn pawn)
|
|
|
|
|
{
|
|
|
|
|
var playerBasePos = GetPlayerBase(pawn.PlayerType).GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
|
|
|
|
pawn.MoveBackToHome(playerBasePos);
|
|
|
|
|
}
|
2026-02-06 19:04:39 +05:30
|
|
|
|
|
|
|
|
public void ShowSelectedPlayerBase(PlayerType playerType, bool state)
|
|
|
|
|
{
|
2026-02-23 16:09:23 +05:30
|
|
|
if (playerBasesDict.ContainsKey(playerType))
|
|
|
|
|
playerBasesDict[playerType].ShowPlayerBaseEffect(state);
|
2026-02-06 19:04:39 +05:30
|
|
|
}
|
2026-01-23 15:32:48 +05:30
|
|
|
}
|