feat: 重构棋盘逻辑和游戏流程,将引擎版本提升至4.3

- 重构了 VirtualBoard 类,优化了棋盘操作和事件处理
- 重写了 ChessPiece 类,增加了事件处理和虚拟棋子逻辑
- 更新了 ChessGame 控制器,增加了结束回合功能和对话框
- 调整了场景布局和资源引用
- 清理了冗余代码和注释
This commit is contained in:
ZZY
2024-11-02 21:18:53 +08:00
parent abace89813
commit 7e2ca3948d
17 changed files with 2984 additions and 503 deletions

View File

@ -0,0 +1,40 @@
// using System.Numerics;
using Godot;
using System;
public class VirtualPiece {
private Vector2 pos; // 注意这个坐标的非像素坐标而是棋盘坐标
private string name;
private bool isSelected;
public object data;
public event Action<Vector2> OnMove;
public event Action<bool> OnSelected;
public void Move(Vector2 pos) {
this.pos = pos;
OnMove?.Invoke(pos);
}
public Vector2 Pos() {
return pos;
}
public void Selected(bool isSelected) {
if (this.isSelected != isSelected) {
OnSelected?.Invoke(isSelected);
this.isSelected = isSelected;
}
}
public bool IsSelected() {
return isSelected;
}
public VirtualPiece(string name = "", Vector2 pos = new Vector2()) {
this.name = name;
this.pos = pos;
}
}