/// <summary> /// Place a symbol on a slot /// </summary> /// <param name="slot"></param> private void PlaceSymbolOnSlot(GridSlot slot) { //If game is over, stop playing game if (IsGameOver.Value) { return; } switch (CurrentPlayer.Value) { case PlayerType.Human: slot.Symbol.Value = Instantiate(circlePrefab).GetComponent <Symbol>(); break; case PlayerType.Cpu: slot.Symbol.Value = Instantiate(crossPrefab).GetComponent <Symbol>(); break; } if (_grid.IsFull.Value && !CheckGameOver()) { EndTheGame(true); } else { NextTurn(); } }
/// <summary> /// Attach the symbol to a slot /// </summary> /// <param name="slot">Slot to be attached to</param> public void AttachToSlot(GridSlot slot) { var t = transform; //introduce variable cuz it's more efficient (even if here it's not a performance critical context) t.SetParent(slot.transform, false); t.localPosition = Vector3.zero; t.localRotation = Quaternion.identity; }