示例#1
0
 public void MoveChess(int x, int y, int desX, int desY)
 {
     map[desY, desX] = map[y, x];
     map[y, x].Y     = desY;
     map[y, x].X     = desX;
     map[y, x]       = null;
     MapUpdate?.Invoke(map);
 }
示例#2
0
        public override bool MouseDown(ScreenEventArgs args)
        {
            if (args.X < 1 || args.X > 81 || args.Y < 1 || args.Y > 81)
            {
                return(false);
            }
            int tileX = (int)Math.Floor(((double)args.X - 1) / 16);
            int tileY = (int)Math.Floor(((double)args.Y - 1) / 16);

            if (tileX < 0 || tileY < 0 || tileX > 4 || tileY > 4)
            {
                return(false);
            }

            _city.SetResourceTile(_city.CityRadius[tileX, tileY]);
            _update = true;
            MapUpdate?.Invoke(this, null);
            return(true);
        }
示例#3
0
        public void SetChess(int x, int y, Rule.ChessType chessType, Rule.Country country)
        {
            switch (chessType)
            {
            case Rule.ChessType.King:
                map[y, x] = new KingChess(this, x, y, country);
                break;

            case Rule.ChessType.Guard:
                map[y, x] = new GuardChess(this, x, y, country);
                break;

            case Rule.ChessType.Elephant:
                map[y, x] = new ElephantChess(this, x, y, country);
                break;

            case Rule.ChessType.Rook:
                map[y, x] = new RookChess(this, x, y, country);
                break;

            case Rule.ChessType.Knight:
                map[y, x] = new KnightChess(this, x, y, country);
                break;

            case Rule.ChessType.Cannon:
                map[y, x] = new CannonChess(this, x, y, country);
                break;

            case Rule.ChessType.Pawn:
                map[y, x] = new PawnChess(this, x, y, country);
                break;

            default:
                throw new NotSupportedException();
            }
            MapUpdate?.Invoke(map);
        }
示例#4
0
 public void SetChess(int x, int y, Chess chess)
 {
     map[y, x] = chess;
     MapUpdate?.Invoke(map);
 }
示例#5
0
 public void ForceTriggerMapUpdate() => MapUpdate?.Invoke(map);
示例#6
0
 internal void OnMapUpdate()
 {
     MapUpdate?.Invoke(this, EventArgs.Empty);
 }
        public static event EventHandler <MapUpdateInfo> MapUpdate;       // event

        public static void OnMapUpdate(object sender, MapUpdateInfo info) //if event is not null then call delegate
        {
            MapUpdate?.Invoke(sender, info);
        }