feat: 重构多人游戏界面和代码,使用文件存储游戏配置,重构底层代码

This commit is contained in:
ZZY
2024-11-06 22:13:03 +08:00
parent d323a0bee7
commit d6cbb5e11d
30 changed files with 715 additions and 262 deletions

View File

@ -0,0 +1,38 @@
using Vector2 = Godot.Vector2;
using System;
public class VirtualPiece {
private Vector2 pos; // 注意这个坐标的非像素坐标而是棋盘坐标
private readonly 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;
}
}