private void Awake() { player = FindObjectOfType <Player>(); tilesContainer = FindObjectOfType <TilesContainer>(); stateHolder = FindObjectOfType <StateHolder>(); diceUI = FindObjectOfType <DiceUI>(); }
private void Awake() { for (int i = 0; i < HPDots.Count; i++) { HPDots[i].color = DiceUI.newColor(154, 34, 92); } }
public void ShowList(List <List <Dice> > DiceList) { for (int y = 0; y < DiceList.Count; y++) { Rows.Add(Instantiate(Row, DiceListUIParent, false)); DiceUIList.Add(new List <DiceUI>()); for (int x = 0; x < DiceList[y].Count; x++) { GameObject currentDice = Instantiate(Dice, Rows[y].transform, false); DiceUI diceUI = currentDice.GetComponent <DiceUI>(); diceUI.SetDice(DiceList[y][x]); diceUI.DicePointer.y = y; diceUI.DicePointer.x = x; DiceUIList[y].Add(diceUI); } } //Using coroutine because the unity's layout group only update in next frame, so we have to wait to next frame to get the grid position StartCoroutine(IE_AssignPos()); }
void ClearCharDices() { while (dices.Count > 0) { DiceUI diceUI = dices[0]; dices.Remove(diceUI); Destroy(diceUI.gameObject); } }
IEnumerator Replace(DiceUI clicked) { IsInAnimation = true; //Check is the clicked dice is moveable or not if (clicked.DicePointer.y == 1 && IsVaild(Slot, clicked)) { //Score plus one Score++; Chain++; AuPlayer.pitch = 1f + (Chain - 1) / 20f * 2f; AuPlayer.PlayOneShot(ChainAudio); //Change Parent and do animation moving Vector3 pos = clicked.transform.position; clicked.transform.SetParent(SlotUI, false); clicked.transform.position = pos; clicked.transform.DOMove(SlotUI.transform.position, 0.5f); //Move the element in DiceList down Vector2Int clickedPos = new Vector2Int(clicked.DicePointer.x, clicked.DicePointer.y); //--Move in List UIMgr.DiceUIList[clickedPos.y].RemoveAt(clickedPos.x); DiceUI temp = UIMgr.DiceUIList[clickedPos.y - 1][clickedPos.x]; UIMgr.DiceUIList[clickedPos.y].Insert(clickedPos.x, temp); UIMgr.DiceUIList[clickedPos.y - 1].RemoveAt(clickedPos.x); UIMgr.DiceUIList[clickedPos.y][clickedPos.x].DicePointer = clickedPos; UIMgr.DiceUIList[clickedPos.y][clickedPos.x].transform.SetParent(UIMgr.Rows[clickedPos.y].transform); UIMgr.DiceUIList[clickedPos.y][clickedPos.x].transform.SetSiblingIndex(clickedPos.x); //--Move in Animation UIMgr.DiceUIList[clickedPos.y][clickedPos.x].transform.DOMove(UIMgr.GetPos(clickedPos), 0.5f); //Generate a new Dice UIMgr.AddDice(Dice.RandomDice(), new Vector2Int(clickedPos.x, clickedPos.y - 1)); yield return(new WaitForSeconds(0.5f)); if (Slot != null) { Destroy(Slot.gameObject); } Slot = clicked; } else { clicked.transform.DOShakePosition(0.5f, 15, 90, 50); yield return(new WaitForSeconds(0.5f)); } IsInAnimation = false; StartCoroutine(Check()); }
void CreateDices(List <int> vals) { for (int i = 0; i < vals.Count; i++) { DiceUI diceUI = Instantiate(prefabDiceUI, transform).GetComponent <DiceUI>(); diceUI.dice.color = character.color; diceUI.number.text = vals[i].ToString(); dices.Add(diceUI); } }
private void _RollServer(int idPlayer) { currentRollPlayerID = idPlayer; _clientReceiveCount = 0; int diceCount = _baseDiceCount; receivedDiceUICallback.Clear(); // Send diceCount to Effects that effect number of dice //////////////////////// // Code go here //////////////////////// if (_result == null) { _result = new List <int>(); } if (_currentDices == null) { _currentDices = new List <DiceUI>(); } _result.Clear(); _resultCount = 0; // Add or destroy dice object to match dice count if (diceCount > _currentDices.Count) { while (diceCount > _currentDices.Count) { DiceUI dice = PhotonNetwork.Instantiate("Dice", diceSpawnPosition.position, Quaternion.identity).GetComponent <DiceUI>(); //DiceUI dice = Instantiate(_dicePrefab, new Vector3(0, 0, 0), Quaternion.identity); dice.ReceiveResult += ReceiveResult; _currentDices.Add(dice); } } else if (diceCount < _currentDices.Count) { while (diceCount < _currentDices.Count) { DiceUI dice = _currentDices[_currentDices.Count - 1]; PhotonNetwork.Destroy(dice.gameObject); _currentDices.RemoveAt(_currentDices.Count - 1); } } for (int i = 0; i < diceCount; i++) { _currentDices[i].Roll(); } }
IEnumerator Shinny() { while (true) { Fill.DOColor(Color.yellow, 0.2f); yield return(new WaitForSeconds(0.2f)); Fill.DOColor(DiceUI.newColor(154, 34, 92), 0.2f); yield return(new WaitForSeconds(0.7f)); } }
public void AddDice(Dice newDice, Vector2Int Pos) { GameObject currentDice = Instantiate(Dice, Rows[Pos.y].transform, false); currentDice.transform.SetSiblingIndex(Pos.x); DiceUI diceUI = currentDice.GetComponent <DiceUI>(); diceUI.SetDice(newDice); diceUI.DicePointer = Pos; Vector3 TargetPos = GetPos(Pos); diceUI.transform.position = new Vector3(TargetPos.x, 1080 + 400); diceUI.transform.DOMove(TargetPos, 0.5f); DiceUIList[Pos.y].Insert(Pos.x, diceUI); }
private void ReceiveResult(DiceUI who, int result) { if (receivedDiceUICallback.Contains(who)) { return; } receivedDiceUICallback.Add(who); _result.Add(result); _resultCount++; if (_resultCount == _baseDiceCount) { photonView.RPC("_ReceiveRollResult", RpcTarget.All, currentRollPlayerID, (object)(_result.ToArray())); } }
bool IsVaild(DiceUI Slot, DiceUI Clicked) { if (Slot == null) { return(true); } if ( (Slot.dice.Number <= 5 && Slot.dice.Number >= 1 && Slot.dice.Number == Clicked.dice.Number - 1) || (Slot.dice.Number == 6 && Clicked.dice.Number == 1) || (Slot.dice.DiceColor == Clicked.dice.DiceColor) ) { return(true); } else { return(false); } }
IEnumerator Discard() { IsInAnimation = true; Slot.transform.DOMove(new Vector3(Slot.transform.position.x, -500), 0.5f); Chain = 0; AuPlayer.pitch = 1; AuPlayer.PlayOneShot(DiscardAudio); HP--; yield return(new WaitForSeconds(0.5f)); Destroy(Slot.gameObject); Slot = null; IsInAnimation = false; StartCoroutine(Check()); }
private void Awake() { diceUI = FindObjectOfType <DiceUI>(); tileSelector = FindObjectOfType <TileSelector>(); }
public Dice(DiceUI diceUI) { this.diceUI = diceUI; PipNum = (int)Define.DicePipType.One; }