protected void placePlayed(MahjongTile tile, bool withSound = true) { tile.Reset(); _angle = Vector3.Angle(Vector3.right, _direction); if (_direction == Vector3.forward) { _angle = 270f; } tile.Direction = MahjongTile.Face.PLANE_POSITIVE; tile.transform.Rotate(Vector3.up, _angle, Space.Self); Vector3 down = Vector3.Cross(_direction, Vector3.down); tile.transform.parent = PlayLocator; //Debug.Log (tile.transform.localRotation + "/" + _direction + "/" + _angle); int index = PlayLocator.childCount - 1; int row = index / 6; int col = index % 6; Vector3 newpos = col * _direction * MahjongTile.Width + row * down * MahjongTile.Height; //Debug.Log (row +":"+col); tile.Play(newpos); _playedList.Add(tile); if (withSound) { //AudioManager.Instance.PlayPai (((int)tile.ID).ToString ()); //AudioManager.Instance.PlaySound (AudioManager.Instance.Luo_Pai); //TableController.Instance.SetCurrentPlayedTile (tile); } //close hupaiTips UIGameHuPromptController.Instance.Close(); }
public void PlaceWin(MahjongTile tile, bool withSound = true) { tile.Reset(); tile.transform.parent = WinLocator; }
// param id is a combo list public void Combo(TileDef def, int num, int flipNum = 0, bool withAnimation = true) { MahjongTile tile = null; Vector3 localPos = Vector3.zero; if (ComboLocator.childCount > 0) { localPos = Vector3.zero - MahjongTile.Width * _direction * ComboLocator.childCount - MahjongTile.Width * _direction * 0.2f; } else { localPos = Vector3.zero; } for (int i = 0; i < num; ++i) { tile = MahjongTile.Create(def); tile.Reset(); if (i < flipNum) { tile.Direction = MahjongTile.Face.PLANE_NEGTIVE; _angle = Vector3.Angle(Vector3.right, _direction); //Debug.Log (_angle + " " + Vector3.right + "," + _direction); // unity3d bug from vector3.right to vector3.forward == 90 ? if (_direction == Vector3.forward) { _angle = 270f; } tile.transform.Rotate(Vector3.up, _angle, Space.Self); } else { _angle = Vector3.Angle(Vector3.right, _direction); //Debug.Log (_angle + " " + Vector3.right + "," + _direction); // unity3d bug from vector3.right to vector3.forward == 90 ? if (_direction == Vector3.forward) { _angle = 270f; } tile.transform.Rotate(Vector3.up, _angle, Space.Self); } //往左偏移的起始位置 tile.transform.parent = ComboLocator; tile.transform.localPosition = localPos - i * MahjongTile.Width * _direction; if (withAnimation) { //再往左偏移一段位置从起始位置起 然后播放动画 Vector3 localDstPosition = tile.transform.localPosition; tile.transform.localPosition = tile.transform.localPosition - _direction * MahjongTile.Width * 3f; ActionBase act = MoveTo.Create(0.2f, localDstPosition, true); ActionManager.Instance.RunAction(tile.gameObject, act); } } //Debug.Log (_comboLocator.transform.childCount); }
public static void Destroy(MahjongTile tile) { tile.Reset(); _Pool.Despawn(tile.transform); }