private void StartNewGame() { Clear(); turn = 0; text.Introduction(); PlacePiece(red, ChessConfig.GetMainCoord("red")); PlacePiece(black, ChessConfig.GetMainCoord("black")); SwapTurn(); }
private void AddStep(int x, int y, bool isPawnAtack = false) //isPawnAtack = true in case of a pawn move-attack { if (x < ChessConfig.size && x >= 0 && y < ChessConfig.size && y >= 0) { string newType = ChessConfig.GetFieldType(x, y); //Calculation the difference between the power of the piece before step and after int score = ChessConfig.GetPiecePower(newType) - ChessConfig.GetPiecePower(type); posibleSteps.Add(new StepData(x * 8 + y, this.x * 8 + this.y, score, isPawnAtack)); } }
public virtual void Awake() { createManager = CreateManager.Instance; chessReciprocalState = ChessReciprocalState.unChoosed; chessSituationState = ChessSituationState.Idle; PoolManager.PushEvent += SubscribeEvents;//棋子被创建时就该订阅这一堆事件 PoolManager.TakeEvent += SubscribeEvents; PoolManager.RestoreEvent += CancelSubscribeEvents; gameObject.AddComponent <AttrBox>(); attrBox = gameObject.GetComponent <AttrBox>(); attrBox.SetAttrList(ChessConfig.GetAttrList(chessName)); }
public static List <StepData> GetRemainningSteps(char color, char[,] currDesk, Field[,] fields) { List <StepData> allSteps = new List <StepData>(); string pieceType; int size = ChessConfig.size; int crutch; int x, y; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (currDesk[i, j] == color || currDesk[i, j] == char.ToUpper(color)) { crutch = i * size + j; foreach (StepData sd in fields[i, j].posibleSteps) { pieceType = fields[i, j].type; x = sd.dest / size; y = sd.dest % size; sd.stepType = StepCheck(i, j, x, y, currDesk, pieceType, sd.isPawnAtack); sd.eatScore = 0; if (sd.stepType == " ") { sd.stepType = null; continue; } if (sd.stepType == "eat") { if (currDesk[x, y] == 'R' || currDesk[x, y] == 'B') { sd.eatScore = ChessConfig.GetPiecePower("Main"); } else //points for eating ↓ and the power of the enemy’s piece ↓ { sd.eatScore = ChessConfig.GetPiecePower("ordinary") + ChessConfig.GetPiecePower(fields[x, y].type); } } allSteps.Add(sd); } } } } return(allSteps); }
private void FillLocation() { validPos[0, 0] = startPos; fields[0, 0] = new Field(0, 0, ChessConfig.GetFieldType(0, 0)); for (int i = 0; i < size; i++) { for (int j = 1; j < size; j++) { validPos[i, j] = validPos[i, j - 1] + offsetY; fields[i, j] = new Field(i, j, ChessConfig.GetFieldType(i, j)); desk[i, j] = ' '; } if (i < 7) { validPos[i + 1, 0] = validPos[i, 0] + offsetX; fields[i + 1, 0] = new Field(i + 1, 0, ChessConfig.GetFieldType(i + 1, 0)); } } }
public ChessService(IConfiguration config) { //this.config = config; chessConfig = new ChessConfig(); config.GetSection("Chess").Bind(chessConfig); }