60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
[System.Serializable]
|
|
public class BasePlacementData
|
|
{
|
|
public int playerBaseId;
|
|
public Transform placementTransform;
|
|
}
|
|
|
|
public class PlayerBase : MonoBehaviour
|
|
{
|
|
[SerializeField] private PlayerType playerType;
|
|
[SerializeField] private BasePlacementData[] basePlacementDatas;
|
|
[SerializeField] private PlayerPawn[] playerPawns;
|
|
[SerializeField] private GameObject playerBaseEffect;
|
|
|
|
public bool IsBotBase
|
|
{
|
|
get; private set;
|
|
}
|
|
|
|
public PlayerType GetPlayerType() => playerType;
|
|
|
|
public void InitPlayerData()
|
|
{
|
|
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
|
|
{
|
|
playerPawns[idx].Init(this, basePlacementDatas[idx], playerType);
|
|
}
|
|
}
|
|
|
|
public void AssignBotState(PawnType pawnType)
|
|
{
|
|
IsBotBase = pawnType == PawnType.Bot;
|
|
for (int idx = 0; idx < playerPawns.Length; idx++)
|
|
{
|
|
playerPawns[idx].AssignBotPlayerState(IsBotBase);
|
|
}
|
|
}
|
|
|
|
public Transform GetBasePlacementDataPosition(int idx)
|
|
{
|
|
Debug.Log($"Index: {idx}, basePlacementDatas[idx]: {basePlacementDatas[idx]}");
|
|
return basePlacementDatas[idx].placementTransform;
|
|
}
|
|
|
|
public void ResetPlayerDatas()
|
|
{
|
|
for (int idx = 0; idx < playerPawns.Length; idx++)
|
|
{
|
|
playerPawns[idx].ResetData();
|
|
}
|
|
}
|
|
|
|
public void ShowPlayerBaseEffect(bool state)
|
|
{
|
|
playerBaseEffect.SetActive(state);
|
|
}
|
|
}
|