public override void TunEnd() { MyOperateStep = EOpStep.None; }
public override void Update() { //H键切换视图 if (Input.GetKeyDown(KeyCode.H)) { if (ViewType == ECampType.Red) { ViewType = ECampType.Black; } else { ViewType = ECampType.Red; } Gamer.Chessboard.SetPlayerView(ViewType); } switch (MyOperateStep) { case EOpStep.Select: { //选择棋子 if (Input.GetMouseButtonDown(0)) { RaycastHit HitInfo; if (Physics.Raycast(Gamer.Chessboard.GetViewCamera().ScreenPointToRay(Input.mousePosition), out HitInfo)) { UChess HitChess = Gamer.Chessboard[Gamer.Chessboard.WorldToPos(HitInfo.point)]; if (HitChess != null && HitChess.campType == MyCamp) { selectedChess = HitChess; MyOperateStep = EOpStep.Push; ShowMoveTargets(); } } } } break; case EOpStep.Push: { RaycastHit HitInfo; if (Physics.Raycast(Gamer.Chessboard.GetViewCamera().ScreenPointToRay(Input.mousePosition), out HitInfo)) { if (selectedChess.gameObject != null) { selectedChess.gameObject.transform.position = HitInfo.point; } if (Input.GetMouseButtonDown(0)) { Point NewPoint = Gamer.Chessboard.WorldToPos(HitInfo.point); if (selectedChess.GetAvailablePoints().Contains(Gamer.Chessboard.ToChessPoint(NewPoint, selectedChess.campType))) { Command Cmd = new Command(); Cmd.Camp = MyCamp; Cmd.From = selectedChess.ToChessboardPoint(); Cmd.To = NewPoint; Gamer.Chessboard.DoCommand(Cmd); } else { selectedChess.ResetPosition(); } ClearMoveTargets(); MyOperateStep = EOpStep.Select; } } } break; default: break; } }
public override void TunStart() { MyOperateStep = EOpStep.Select; }