private void InitGoalButton(Game game) { for (int i = 0; i < _goalChessButtonCount / 2; ++i) { _goalbutton[i] = new ChessButton(game, game.Content.Load<Texture2D>("blank"), new DrawState(game, new Vector4(0.025f + (1.0f / Setting.MaxEdgeCount) * (i % Setting.MaxEdgeCount), -0.04f, (1.0f / Setting.MaxEdgeCount) - 0.02f, 0.05f), new Color(0.0f, 0.0f, 0.0f, 0.5f))); AddComponent(_goalbutton[i]); } for (int i = _goalChessButtonCount / 2; i < _goalChessButtonCount; ++i) { _goalbutton[i] = new ChessButton(game, game.Content.Load<Texture2D>("blank"), new DrawState(game, new Vector4(1.02f, 0.025f + (1.0f / Setting.MaxEdgeCount) * (i % Setting.MaxEdgeCount), 0.04f, (1.0f / Setting.MaxEdgeCount) - 0.01f), new Color(0.0f, 0.0f, 0.0f, 0.5f))); AddComponent(_goalbutton[i]); } }
private void UpdatePossibleMoveButton(int i, ChessButton[] chessButton, List<Tuple<int, Chess.Action>> position) { foreach (Tuple<int, Chess.Action> possiblePosition in position) { if (chessButton[possiblePosition.Item1].HaveChess) { chessButton[possiblePosition.Item1].ClearAllAndAddState(0.5f, new DrawState(Game, chessButton[possiblePosition.Item1].State.CurrentState.Bounds, Color.DarkRed)); } else { chessButton[possiblePosition.Item1].ClearAllAndAddState(0.5f, new DrawState(Game, chessButton[possiblePosition.Item1].State.CurrentState.Bounds, Color.DarkSeaGreen)); chessButton[possiblePosition.Item1].WantToGo = i; chessButton[possiblePosition.Item1].WantToGoAction = possiblePosition.Item2; } } }
private void CleanAllChessButtonAnimation(ChessButton[] chessButton, bool[] chessButtonHover, int chessButtonCount) { for (int i = 0; i < chessButtonCount; ++i) { chessButton[i].ClearAllAndAddState(0.5f, new DrawState(Game, chessButton[i].State.CurrentState.Bounds, new Color(0.0f, 0.0f, 0.0f, 0.5f))); chessButton[i].WantToGo = -1; chessButtonHover[i] = false; } }
private void ChessMove(Chess moveChess, ChessButton moveOut, Chess.Action chessAction) { moveOut.HaveChess = false; moveChess.Move(chessAction); if (!moveChess.GoalArrived) _chessbutton[moveChess.Y * Setting.MaxEdgeCount + moveChess.X].HaveChess = true; }
private void ChessButtonHoverAnimation(ChessButton[] chessButtons, bool[] chessButtonHover, int totalButtonCount) { for (int i = 0; i < totalButtonCount; ++i) { if (chessButtons[i].IsHover() && !chessButtonHover[i]) { chessButtonHover[i] = true; chessButtons[i].ClearAllAndAddState(0.2f, new DrawState(Game, chessButtons[i].State.CurrentState.Bounds, new Color( chessButtons[i].State.LastState.Color.R + 50, chessButtons[i].State.LastState.Color.G + 50, chessButtons[i].State.LastState.Color.B + 50, chessButtons[i].State.LastState.Color.A))); } else if (!chessButtons[i].IsHover() && chessButtonHover[i]) { chessButtonHover[i] = false; chessButtons[i].ClearAllAndAddState(0.2f, new DrawState(Game, chessButtons[i].State.CurrentState.Bounds, new Color(chessButtons[i].State.LastState.Color.R - 50, chessButtons[i].State.LastState.Color.G - 50, chessButtons[i].State.LastState.Color.B - 50, chessButtons[i].State.LastState.Color.A))); } } }
private void ChessButtonClickMove(Chess[] nowChess, ChessButton[] chessButtons, int totalButtonCount) { for (int i = 0; i < totalButtonCount; ++i) { if (chessButtons[i].IsHit() && chessButtons[i].WantToGo != -1) { _click.Play(); _errorSound = false; Chess chess = nowChess[chessButtons[i].WantToGo]; ChessMove(chess, _chessbutton[chess.Y * Setting.MaxEdgeCount + chess.X], chessButtons[i].WantToGoAction); CleanAllChessButtonAnimation(_goalbutton, _goalbuttonHover, _goalChessButtonCount); CleanAllChessButtonAnimation(_chessbutton, _chessbuttonHover, _totalChessButtonCount); TurnTheTurn(); NowState = BoardState.Animation; NoMove = false; } else if (chessButtons[i].IsHit()) { _errorSound = true; } } }
private void InitChessButton(Game game) { for (int i = 0; i < _totalChessButtonCount; ++i) { _chessbutton[i] = new ChessButton(game, game.Content.Load<Texture2D>("blank"), new DrawState(game, new Vector4(0.025f + (1.0f / SettingParameters.MaxEdgeCount) * (i % SettingParameters.MaxEdgeCount), 0.025f + (1.0f / SettingParameters.MaxEdgeCount) * (i / SettingParameters.MaxEdgeCount), (1.0f / SettingParameters.MaxEdgeCount) - 0.02f, (1.0f / SettingParameters.MaxEdgeCount) - 0.01f), new Color(0.0f, 0.0f, 0.0f, 0.5f))); AddComponent(_chessbutton[i]); } }