public User GetUserAtPos(SeatPosition pos) { if (MySeat == -1) { return(null); } switch (pos) { case SeatPosition.Bottom: return(GetUserAtSeat(MySeat)); case SeatPosition.Left: { var seat = (MySeat + 3) % 4; return(GetUserAtSeat(seat)); } case SeatPosition.Right: { var seat = (MySeat + 1) % 4; return(GetUserAtSeat(seat)); } case SeatPosition.Top: { var seat = (MySeat + 2) % 4; return(GetUserAtSeat(seat)); } default: return(null); } }
public int SeatOfPosition(SeatPosition pos) { if (MySeat == -1) { return(-1); } switch (pos) { case SeatPosition.Bottom: return(MySeat); case SeatPosition.Right: return((MySeat + 1) % 4); case SeatPosition.Top: return((MySeat + 2) % 4); case SeatPosition.Left: return((MySeat + 3) % 4); default: return(-1); } }
public void Hide(SeatPosition pos) { if (pos == SeatPosition.Null) { return; } if (pos == _pos) { if (Arrow && Arrow.gameObject.activeSelf) { Arrow.gameObject.SetActive(false); } _pos = SeatPosition.Null; } else if (pos == _pos1) { if (Arrow1 && Arrow1.gameObject.activeSelf) { Arrow1.gameObject.SetActive(false); } _pos1 = SeatPosition.Null; } if (_pos == SeatPosition.Null && _pos1 == SeatPosition.Null) { // 如果两个箭头都被隐藏了,则隐藏整体时钟。 if (Content && Content.gameObject.activeSelf) { Content.gameObject.SetActive(false); } } }
private float SeatAngle(SeatPosition pos) { float angle = 0; switch (pos) { case SeatPosition.Top: angle = (0 + AngleOffset) % 360; break; case SeatPosition.Left: angle = (90 + AngleOffset) % 360; break; case SeatPosition.Bottom: angle = (180 + AngleOffset) % 360; break; case SeatPosition.Right: angle = (270 + AngleOffset) % 360; break; } return(angle); }
public void ChangePos(SeatPosition pos) { var rt = GetComponent <RectTransform>(); var trt = TextCont.GetComponent <RectTransform>(); var offsetX = 120; rt.anchoredPosition = new Vector2(0, 68); Arrow.SetActive(true); // 当玩家参与游戏时,调整特殊的位置 if (Uid == GameData.Shared.Uid) { rt.anchoredPosition = new Vector2(0, -210); // rt.anchoredPosition = new Vector2(-270, -110); trt.anchoredPosition = new Vector2(0, 0); Arrow.SetActive(false); } else if (pos == SeatPosition.Right || pos == SeatPosition.TopLeft) { trt.anchoredPosition = new Vector2(-offsetX, 0); } else if (pos == SeatPosition.Left || pos == SeatPosition.TopRight) { trt.anchoredPosition = new Vector2(offsetX, 0); } else if (pos == SeatPosition.Top || pos == SeatPosition.Bottom) { trt.anchoredPosition = new Vector2(0, 0); } }
private void setPosition(SeatPosition pos) { var y = -65; var x = 90; if (pos == SeatPosition.Right) { x = -90; } GetComponent <RectTransform>().DOAnchorPos(new Vector2(x, y), 0.15f); }
private Tweener GetBuChuTweener(SeatPosition pos) { if (pos == SeatPosition.Null) { return(null); } Tweener tweener; _buChuTweeners.TryGetValue(pos, out tweener); return(tweener); }
private void SetLastChuPai(SeatPosition seatPos, PokerPattern lastChuPai, int sex, bool withEffect = true) { if (lastChuPai == null) { return; } var value = new PatternValue(GetCurrentHost); var matcher = new PatternMatcher(value); var pattern = matcher.Match(PokerLogicUtil.ToPokerList(lastChuPai.pokers)); var pokers = PokerLogicUtil.ConvertToPokerList(pattern, value); SetLastChuPai(seatPos, pokers, sex, withEffect); }
public void ChangePos(SeatPosition pos) { var rect = GetComponent <RectTransform>(); var tab = rect.transform.Find("Tab").GetComponent <RectTransform>(); if (pos == SeatPosition.Left || pos == SeatPosition.TopRight) { tab.rotation = Quaternion.Euler(new Vector2(0, 180)); rect.anchoredPosition = new Vector2(64, -48); } else { tab.rotation = Quaternion.Euler(new Vector2(0, 0)); rect.anchoredPosition = new Vector2(-64, -48); } }
private void SetBuChuTweener(SeatPosition pos, Tweener tweener) { if (pos == SeatPosition.Null) { return; } if (tweener != null) { if (!_buChuTweeners.ContainsKey(pos)) { _buChuTweeners.Add(pos, tweener); } else { _buChuTweeners[pos] = tweener; } } }
static void Main(string[] args) { var lines = File.ReadAllLines("input.txt"); var positions = lines .SelectMany(line => SeatPosition.TryParse(line, out var sp) ? new[] { sp } : Enumerable.Empty <SeatPosition>()); var seatIds = positions .Select(sp => sp.SeatId) .ToList(); seatIds.Sort(); Console.WriteLine("Heighest id: {0}", seatIds.LastOrDefault()); var ourSeat = seatIds .Zip(seatIds.Skip(1), (a, b) => a + 1 < b ? a + 1 : uint.MaxValue) .Min(); Console.WriteLine("Our seat: {0}", ourSeat); }
private Vector2 getVector(SeatPosition pos) { var vector = new Vector2(136, 20); if (pos == SeatPosition.Right) { vector = new Vector2(-136, 20); } else if (pos == SeatPosition.Top || pos == SeatPosition.TopLeft || pos == SeatPosition.TopRight) { vector = new Vector2(0, -180); } else if (pos == SeatPosition.Bottom) { vector = new Vector2(136, 0); } return(vector); }
private List <Poker> GetLastChuPai(SeatPosition pos) { switch (pos) { case SeatPosition.Bottom: return(_bottomeChuPai); case SeatPosition.Top: return(_topChuPai); case SeatPosition.Left: return(_leftChuPai); case SeatPosition.Right: return(_rightChuPai); default: return(null); } }
private Image GetBuChuImage(SeatPosition pos) { switch (pos) { case SeatPosition.Top: return(BuChuTop); case SeatPosition.Bottom: return(BuChuBottom); case SeatPosition.Left: return(BuChuLeft); case SeatPosition.Right: return(BuChuRight); default: return(null); } }
private Vector2 GetBasePos(SeatPosition pos) { switch (pos) { case SeatPosition.Bottom: return(MyLastChuPaiPos); case SeatPosition.Top: return(TopLastChuPaiPos); case SeatPosition.Left: return(LeftLastChuPaiPos); case SeatPosition.Right: return(RightLastChuPaiPos); default: return(Vector2.zero); } }
private List <LastCardSlot> GetLastChuPaiSlots(SeatPosition pos) { switch (pos) { case SeatPosition.Bottom: return(_bottomSlots); case SeatPosition.Top: return(_topSlots); case SeatPosition.Left: return(_leftSlots); case SeatPosition.Right: return(_rightSlots); default: return(null); } }
internal static bool TryParse(ReadOnlySpan <char> input, out SeatPosition result) { result = default; if (input.Length != 10) { return(false); } var row = 0u; for (var i = 0; i < 7; i++) { row += row; switch (input[i]) { case 'F': break; case 'B': row += 1; break; default: return(false); } } var seat = 0u; for (var i = 7; i < 10; i++) { seat += seat; switch (input[i]) { case 'L': break; case 'R': seat += 1; break; default: return(false); } } result = new SeatPosition(row, seat); return(true); }
private void SetLastChuPai(SeatPosition pos, List <Poker> lastChuPai) { switch (pos) { case SeatPosition.Bottom: _bottomeChuPai = lastChuPai; break; case SeatPosition.Top: _topChuPai = lastChuPai; break; case SeatPosition.Left: _leftChuPai = lastChuPai; break; case SeatPosition.Right: _rightChuPai = lastChuPai; break; } }
public void ClearSeat(SeatPosition pos) { var buChu = GetBuChuImage(pos); if (buChu && buChu.gameObject.activeSelf) { buChu.gameObject.SetActive(false); } var lastChuPai = GetLastChuPaiSlots(pos); if (lastChuPai != null && lastChuPai.Count > 0) { for (int i = 0; i < lastChuPai.Count; i++) { SetSlotIdle(lastChuPai[i]); } lastChuPai.Clear(); } SetLastChuPai(pos, null); }
public Seat(byte row, byte column) { Position = new SeatPosition(row, column); }
public Seat(string seatNumber, SeatPosition seatPosition, bool isAvailable) { this.seatNumber = seatNumber; this.seatPosition = seatPosition; this.isAvailable = isAvailable; }
public Result UpdateRoom(Room room, RoomPlan roomPlan, ICollection <SeatPosition> added, ICollection <SeatPosition> updated) { try { string seatPositionIds = ""; foreach (SeatPosition seatPosition in updated) { SeatPosition dbSeatPosition = GetSeatPositionById(seatPosition.Id); if (dbSeatPosition != null) { dbSeatPosition.Column = seatPosition.Column; dbSeatPosition.Rotation = seatPosition.Rotation; dbSeatPosition.Row = seatPosition.Row; dbSeatPosition.SeatTypeId = seatPosition.SeatTypeId; databaseContext.SeatPositions.Update(dbSeatPosition); seatPositionIds += seatPositionIds == "" ? seatPosition.Id.ToString() : ";" + seatPosition.Id; } } if (added.Count > 0) { ICollection <SeatPosition> dbSeatPositions = databaseContext.SeatPositions.ToList(); int id = dbSeatPositions.Count + 1; bool duplicateId = false; foreach (SeatPosition seatPosition in added) { do { duplicateId = dbSeatPositions.Any(x => x.Id == id); if (duplicateId) { id++; } } while (duplicateId); seatPosition.Id = id; seatPositionIds += seatPositionIds == "" ? id.ToString() : ";" + id; id++; } databaseContext.SeatPositions.AddRange(added); } string[] oldSeatPositionIds = roomPlan.Seats.Split(';', StringSplitOptions.RemoveEmptyEntries); foreach (string seatPositionId in oldSeatPositionIds) { if (!seatPositionIds.Contains(seatPositionId)) { SeatPosition seatPosition = databaseContext.SeatPositions.FirstOrDefault(x => x.Id == int.Parse(seatPositionId)); if (seatPosition != null) { databaseContext.SeatPositions.Remove(seatPosition); } } } roomPlan.Seats = seatPositionIds; databaseContext.RoomPlans.Update(roomPlan); room.RoomPlanId = roomPlan.Id; databaseContext.Rooms.Update(room); databaseContext.SaveChanges(); return(new Result()); } catch (Exception ex) { return(new Result(ex)); } }
private void SetTouYou(SeatPosition touYouPos, SeatPosition erYouPos = SeatPosition.Null) { Image touYouImg = null; Image erYouImg = null; if (SeatPosition.Top == touYouPos) { touYouImg = TopTouYou; } else if (SeatPosition.Top == erYouPos) { erYouImg = TopTouYou; } else { if (TopTouYou.gameObject.activeSelf) { TopTouYou.gameObject.SetActive(false); } } if (SeatPosition.Bottom == touYouPos) { touYouImg = BottomTouYou; } else if (SeatPosition.Bottom == erYouPos) { erYouImg = BottomTouYou; } else { if (BottomTouYou.gameObject.activeSelf) { BottomTouYou.gameObject.SetActive(false); } } if (SeatPosition.Left == touYouPos) { touYouImg = LeftTouYou; } else if (SeatPosition.Left == erYouPos) { erYouImg = LeftTouYou; } else { if (LeftTouYou.gameObject.activeSelf) { LeftTouYou.gameObject.SetActive(false); } } if (SeatPosition.Right == touYouPos) { touYouImg = RightTouYou; } else if (SeatPosition.Right == erYouPos) { erYouImg = RightTouYou; } else { if (RightTouYou.gameObject.activeSelf) { RightTouYou.gameObject.SetActive(false); } } if (touYouImg != null) { touYouImg.sprite = TouYouSprite; if (!touYouImg.gameObject.activeSelf) { if (_touYouTweener != null) { _touYouTweener.Kill(); _touYouTweener = null; } touYouImg.gameObject.SetActive(true); touYouImg.rectTransform.localScale = Vector2.zero; _touYouTweener = touYouImg.rectTransform .DOScale(Vector2.one, TouYouAnimationTime) .SetEase(Ease.OutBack); } } if (erYouImg != null) { erYouImg.sprite = ErYouSprite; if (!erYouImg.gameObject.activeSelf) { if (_erYouTweener != null) { _erYouTweener.Kill(); _erYouTweener = null; } erYouImg.gameObject.SetActive(true); erYouImg.rectTransform.localScale = Vector2.zero; _erYouTweener = erYouImg.rectTransform .DOScale(Vector2.one, TouYouAnimationTime) .SetEase(Ease.OutBack); } } }
private void SetLastChuPai(SeatPosition seatPos, List <Poker> lastChuPai, int sex, bool withEffect = true) { if (seatPos == SeatPosition.Null) { return; } var chuPai = GetLastChuPai(seatPos); if (PokerLogicUtil.PokerListEqual(chuPai, lastChuPai)) { // 如果现在要显示的牌,和当前的牌相等的话,就不需要再显示了。 return; } SetLastChuPai(seatPos, lastChuPai); var slots = GetLastChuPaiSlots(seatPos); var buChu = GetBuChuImage(seatPos); var basePos = GetBasePos(seatPos); if (slots.Count > 0) { for (int i = 0; i < slots.Count; i++) { SetSlotIdle(slots[i]); } slots.Clear(); } if (lastChuPai == null || lastChuPai.Count <= 0) { var tweener = GetBuChuTweener(seatPos); if (tweener != null) { tweener.Kill(); } if (buChu) { buChu.sprite = BuChuSprite; if (!buChu.gameObject.activeSelf) { // 只有没显示的情况下,才显示动画。 tweener = StartBuChuAnimation(buChu.transform); SetBuChuTweener(seatPos, tweener); } } if (withEffect) { _soundController.PlayBuChuSound(); _soundController.PlayChuPaiSound(PokerLogic.PokerPattern.BUCHU, sex); } return; } if (buChu && buChu.gameObject.activeSelf) { buChu.gameObject.SetActive(false); } foreach (var p in lastChuPai) { var slot = GetSlot(); if (slot) { slot.Poker = p; slots.Add(slot); } } // SortSlot(slots); UpdateSlotPosition(basePos, slots); if (withEffect) { var value = new PatternValue(GetCurrentHost); var matcher = new PatternMatcher(value); var matched = matcher.Match(lastChuPai); if (matched != null && !matched.IsNull) { _soundController.PlayChuPaiSound(matched, sex); GameWindow.ShowChuPaiEffect(matched); } } }
public void Show( int leftTime, SeatPosition seat0, SeatPosition seat1 = SeatPosition.Null) { if (Content && !Content.gameObject.activeSelf) { Content.gameObject.SetActive(true); } _endTime = Time.time + leftTime; if (seat0 != SeatPosition.Null) { _pos = seat0; float angle = SeatAngle(seat0); if (Arrow) { if (!Arrow.gameObject.activeSelf) { Arrow.gameObject.SetActive(true); } Arrow.rotation = Quaternion.Euler(0, 0, angle); } } else { if (Arrow && Arrow.gameObject.activeSelf) { Arrow.gameObject.SetActive(false); } _pos = SeatPosition.Null; } if (seat1 != SeatPosition.Null) { _pos1 = seat1; float angle = SeatAngle(seat1); if (Arrow1) { if (!Arrow1.gameObject.activeSelf) { Arrow1.gameObject.SetActive(true); } Arrow1.rotation = Quaternion.Euler(0, 0, angle); } } else { if (Arrow1 && Arrow1.gameObject.activeSelf) { Arrow1.gameObject.SetActive(false); } _pos1 = SeatPosition.Null; } // 单机模式下不显示时间计数。 if (TimeCounter && TimeCounter.gameObject.activeSelf == _appController.IsSingleGameMode()) { TimeCounter.gameObject.SetActive(!_appController.IsSingleGameMode()); } }