Changes for moving player back to base.
This commit is contained in:
parent
151823eb36
commit
d603699981
36
Assets/PlayerBaseHandler.cs
Normal file
36
Assets/PlayerBaseHandler.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerBaseData
|
||||
{
|
||||
public PlayerTypes playerType;
|
||||
public PlayerBase playerBase;
|
||||
}
|
||||
|
||||
public class PlayerBaseHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private PlayerBase[] playerBases;
|
||||
|
||||
public void InitPlayerTypes(List<PlayerTypes> playerTypes)
|
||||
{
|
||||
foreach (PlayerBase playerBase in playerBases)
|
||||
{
|
||||
if (playerTypes.Contains(playerBase.GetPlayerType()))
|
||||
{
|
||||
playerBase.InitPlayerIds();
|
||||
playerBase.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerBase.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetPlayerBase()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/PlayerBaseHandler.cs.meta
Normal file
11
Assets/PlayerBaseHandler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 647207b7c72d24ccaaebc10900c23d2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1041,7 +1041,7 @@ GameObject:
|
||||
- component: {fileID: 241691680}
|
||||
- component: {fileID: 241691681}
|
||||
m_Layer: 0
|
||||
m_Name: Player2
|
||||
m_Name: Player2Base
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -1076,6 +1076,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 789d50d84a2014dedb8aa0bb22261a7e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basePlacementDatas: []
|
||||
--- !u!1 &257080519
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1795,7 +1796,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 433034050}
|
||||
m_Layer: 0
|
||||
m_Name: Pawns/Characters
|
||||
m_Name: PlayerBases
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -2171,7 +2172,7 @@ GameObject:
|
||||
- component: {fileID: 574007535}
|
||||
- component: {fileID: 574007536}
|
||||
m_Layer: 0
|
||||
m_Name: Player1
|
||||
m_Name: Player1Base
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -2206,6 +2207,15 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 789d50d84a2014dedb8aa0bb22261a7e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basePlacementDatas:
|
||||
- baseId: 1
|
||||
placementTransform: {fileID: 0}
|
||||
- baseId: 2
|
||||
placementTransform: {fileID: 0}
|
||||
- baseId: 3
|
||||
placementTransform: {fileID: 0}
|
||||
- baseId: 4
|
||||
placementTransform: {fileID: 0}
|
||||
--- !u!1001 &574642922
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3710,28 +3720,28 @@ MonoBehaviour:
|
||||
startIndex: 0
|
||||
endIndex: 46
|
||||
playersParent: {fileID: 1373272158}
|
||||
playerPawns: []
|
||||
playerPawnsDict: []
|
||||
totalPawnsFinished: 0
|
||||
- playerType: 1
|
||||
playerCornerEntity: {fileID: 241691679}
|
||||
startIndex: 12
|
||||
endIndex: 10
|
||||
playersParent: {fileID: 1841959051}
|
||||
playerPawns: []
|
||||
playerPawnsDict: []
|
||||
totalPawnsFinished: 0
|
||||
- playerType: 2
|
||||
playerCornerEntity: {fileID: 987201643}
|
||||
startIndex: 24
|
||||
endIndex: 22
|
||||
playersParent: {fileID: 1934858463}
|
||||
playerPawns: []
|
||||
playerPawnsDict: []
|
||||
totalPawnsFinished: 0
|
||||
- playerType: 3
|
||||
playerCornerEntity: {fileID: 1251876826}
|
||||
startIndex: 36
|
||||
endIndex: 34
|
||||
playersParent: {fileID: 1094154913}
|
||||
playerPawns: []
|
||||
playerPawnsDict: []
|
||||
totalPawnsFinished: 0
|
||||
--- !u!1001 &923111009
|
||||
PrefabInstance:
|
||||
@ -4257,7 +4267,7 @@ GameObject:
|
||||
- component: {fileID: 987201644}
|
||||
- component: {fileID: 987201645}
|
||||
m_Layer: 0
|
||||
m_Name: Player3
|
||||
m_Name: Player3Base
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -4292,6 +4302,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 789d50d84a2014dedb8aa0bb22261a7e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basePlacementDatas: []
|
||||
--- !u!1001 &987559890
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -5698,7 +5709,7 @@ GameObject:
|
||||
- component: {fileID: 1251876827}
|
||||
- component: {fileID: 1251876828}
|
||||
m_Layer: 0
|
||||
m_Name: Player4
|
||||
m_Name: Player4Base
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -5733,6 +5744,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 789d50d84a2014dedb8aa0bb22261a7e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basePlacementDatas: []
|
||||
--- !u!1001 &1266600967
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -15,7 +15,6 @@ public enum PlayerTypes
|
||||
public class PlayerGameData
|
||||
{
|
||||
public PlayerTypes playerType;
|
||||
public GameObject playerCornerEntity;
|
||||
public int startIndex;
|
||||
public int endIndex;
|
||||
public Transform playersParent;
|
||||
@ -31,6 +30,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
[SerializeField] private Material selectMat;
|
||||
|
||||
[SerializeField] private PlayerGameData[] playerGameDatas;
|
||||
[SerializeField] private PlayerBaseHandler playerBaseHandler;
|
||||
|
||||
private PlayerTypes currentPlayerTypeTurn;
|
||||
private int currentPlayerTurnIndex = 0;
|
||||
@ -61,39 +61,31 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
|
||||
CanRollDice = true;
|
||||
InitCurrentGamePlayerInfo(
|
||||
new List<PlayerTypes> { PlayerTypes.Player1, PlayerTypes.Player2, PlayerTypes.Player3, PlayerTypes.Player4 });
|
||||
playerTypes = new List<PlayerTypes> { PlayerTypes.Player1, PlayerTypes.Player2, PlayerTypes.Player3, PlayerTypes.Player4 };
|
||||
|
||||
playerBaseHandler.InitPlayerTypes(playerTypes);
|
||||
InitCurrentGamePlayerInfo();
|
||||
}
|
||||
|
||||
// TODO :: Call based on 2P/3P/4P
|
||||
public void InitCurrentGamePlayerInfo(List<PlayerTypes> playerTypes)
|
||||
public void InitCurrentGamePlayerInfo()
|
||||
{
|
||||
this.playerTypes = playerTypes;
|
||||
currentPlayerTypeTurn = playerTypes[currentPlayerTurnIndex];
|
||||
|
||||
// initialize the board based on the player types
|
||||
foreach (PlayerGameData playerGameData in playerGameDatas)
|
||||
{
|
||||
if (!playerTypes.Contains(playerGameData.playerType))
|
||||
{
|
||||
playerGameData.playerCornerEntity.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new List<PlayerPawn>();
|
||||
PlayerPawn playerPawn = null;
|
||||
int indexer = 0;
|
||||
continue;
|
||||
|
||||
foreach (Transform playerPawnChild in playerGameData.playersParent)
|
||||
{
|
||||
if (!playerPawnChild.gameObject.activeInHierarchy) continue;
|
||||
|
||||
playerPawn = playerPawnChild.GetComponent<PlayerPawn>();
|
||||
indexer++;
|
||||
playerPawn.InitId(indexer);
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict.Add(playerPawn);
|
||||
}
|
||||
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new List<PlayerPawn>();
|
||||
|
||||
foreach (Transform playerPawnChild in playerGameData.playersParent)
|
||||
{
|
||||
if (!playerPawnChild.gameObject.activeInHierarchy) continue;
|
||||
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict.Add(playerPawnChild.GetComponent<PlayerPawn>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,7 +225,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
if (safeTile.PlayerTypesCount == 1)
|
||||
{
|
||||
PlayerTypes playerType = safeTile.GetFirstPlayerType();
|
||||
|
||||
|
||||
var playerPawns = safeTile.GetPlayerPawns(playerType);
|
||||
foreach (var pawn in playerPawns)
|
||||
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
||||
|
||||
@ -1,15 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class BasePlacementData
|
||||
{
|
||||
public int playerBaseId;
|
||||
public Transform placementTransform;
|
||||
}
|
||||
|
||||
public class PlayerBase : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
[SerializeField] private PlayerTypes playerType;
|
||||
[SerializeField] private BasePlacementData[] basePlacementDatas;
|
||||
[SerializeField] private PlayerPawn[] playerPawns;
|
||||
|
||||
public PlayerTypes GetPlayerType() => playerType;
|
||||
|
||||
public void InitPlayerIds()
|
||||
{
|
||||
|
||||
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
|
||||
{
|
||||
playerPawns[idx].InitId(basePlacementDatas[idx].playerBaseId);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public BasePlacementData GetBasePlacementData(int idx)
|
||||
{
|
||||
|
||||
return basePlacementDatas[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,11 @@ public class PlayerPawn : MonoBehaviour
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public int BaseId
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public void SetPlayerSelectionState(bool state)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user