void OnEnable() { playerCursor = GetComponent <PlayerCursor>(); if (FreeIndices == null) { FreeIndices = new List <int>() { 1, 2, 3 } } ; PlayerIndex = FreeIndices[0]; FreeIndices.RemoveAt(0); if (!board) { board = FindObjectOfType <Board>(); } } void OnDisable() { FreeIndices.Add(PlayerIndex); } Homebase homebase; void Start() { playerCursor.SetColor(PlayerCursor.PlayerColors[PlayerIndex]); coro = StartCoroutine(Play()); homebase = Homebase.ForPlayerIndex(PlayerIndex); }
public void SetHomebase(int playerIndex) { if (playerIndex == -1 && Homebase) { Destroy(Homebase); } else if (playerIndex >= 0 && !Homebase) { Homebase = Instantiate <GameObject>(HomebasePrefab).GetComponent <Homebase>(); Assert.IsNotNull(Homebase); Homebase.transform.SetParent(transform, false); Homebase.transform.localPosition = Vector3.zero; Homebase.SetPlayerIndex(playerIndex); } }