public Region(int rid, int gid, Point coords, TERRAIN terrain) { Coords = coords; RID = rid; GID = gid; Terrain = terrain; }
public List <int> GetScores(TERRAIN boon, TERRAIN barren, int bonus) { List <int> points = new List <int> { 0, 0, 0, 0, 0 }; Village = true; if (barren == Terrain) { return(points); } // Clans battle if all are present if (Huts.Min() > 0) { Huts = Huts.Select(h => h == 1 ? 0 : h).ToObservableCollection <int>(); OnHutChange(); } // Remaining clans score for (int cid = 0; cid < 5; cid++) { if (Huts[cid] > 0) { points[cid] = Huts.Sum() + bonus; } } return(points); }
public void ScoreVillage(Region village) { TERRAIN boon = GameData.GetBonusTerrain(Chips); TERRAIN barren = GameData.GetBarrenTerrain(Chips); int bonus = GameData.GetBonus(Chips); Chips -= 1; CurrentPlayer.Points += 1; List <int> points = village.GetScores(boon, barren, bonus); for (int cid = 0; cid < 5; cid++) { Clans[cid].Points += points[cid] * 10; } }
/// <summary> /// Fill the world with given terraintile-spriteID /// </summary> /// <param name="terrain"></param> /// <param name="size"></param> public void FillWorld(TERRAIN terrain, Size size) { this.width = Math.Max(StaticVariables.minWorldSize, Math.Min(size.Width, StaticVariables.maxWorldSize)); this.height = Math.Max(StaticVariables.minWorldSize, Math.Min(size.Height, StaticVariables.maxWorldSize)); terrainTiles = new List<TerrainTile> (); objects = new List<Entity> (); for (int i = 0; i < width * height; i++) { terrainTiles.Add(TileTypes[(int)terrain]); } player = null; Entity focus = new Entity (ENTITIES.def, new PointF (size.Width / 2, size.Height / 2), 0); setFocusEntity (focus); }
protected override void InternalEvent(Entry e) { base.InternalEvent(e); // 空格重置视口 if (e.INPUT.Keyboard.IsClick(PCKeys.Space)) { ResetViewport(); } // 滑轮缩放地图 if (e.INPUT.Mouse.ScrollWheelValue != 0) { float scale = offset.M11; scale = _MATH.Clamp(scale + e.INPUT.Mouse.ScrollWheelValue * 0.1f, 0.2f, 1); offset.M11 = scale; offset.M22 = scale; MATRIX2x3.Invert(ref offset, out offsetInvert); } if (e.INPUT.Pointer.IsPressed(1)) { // 拖拽地图 var delta = e.INPUT.Pointer.DeltaPosition; offset.M31 += delta.X; offset.M32 += delta.Y; MATRIX2x3.Invert(ref offset, out offsetInvert); } if (e.INPUT.Keyboard.Ctrl && e.INPUT.Keyboard.IsClick(PCKeys.A)) { NewMap(); } VECTOR2 position = GetCurrentPosition(); painting.X = (int)position.X; painting.Y = (int)position.Y; int index = -1; for (int i = 0; i < map.Terrains.Count; i++) { if (map.Terrains[i].X == position.X && map.Terrains[i].Y == position.Y) { index = i; break; } } if (e.INPUT.Pointer.IsTap(1)) { // 右键删除地形 if (index != -1) { map.Terrains.RemoveAt(index); } // 右键取消绘制 else { painting.ID = 0; } } // 左键刷地形 if (e.INPUT.Pointer.IsClick(0)) { if (painting.ID == 0) { // 拿起之前绘制的地形变成笔刷 if (index != -1) { painting.ID = map.Terrains[index].ID; painting.Data = map.Terrains[index].Data; painting.Texture = map.Terrains[index].Texture; } } } if (e.INPUT.Pointer.IsPressed(0)) { if (e.INPUT.Keyboard.Alt) { // Alt + 左键删除地形 if (index != -1) { map.Terrains.RemoveAt(index); } } else if (painting.ID != 0 && TBMap.IsHover) { RECT rect = painting.Area; if (!map.Terrains.Any(t => t.Area.Intersects(rect))) { // 刷地形 TERRAIN terrain = new TERRAIN(); terrain.ID = painting.ID; terrain.X = painting.X; terrain.Y = painting.Y; terrain.Data = painting.Data; terrain.Texture = painting.Texture; map.Terrains.Add(terrain); } } } if (e.INPUT.Keyboard.IsClick(PCKeys.D1)) { // 1修改锁定信息 if (index != -1) { int value = (int)map.Terrains[index].Lock + 1; if (value > 2) { value = 0; } map.Terrains[index].Lock = (ELockMode)value; } } else if (e.INPUT.Keyboard.IsClick(PCKeys.D2)) { } else if (e.INPUT.Keyboard.IsClick(PCKeys.D3)) { // 3修改显示额外信息 display = !display; } // 保存地图 if (e.INPUT.Keyboard.Ctrl && e.INPUT.Keyboard.IsClick(PCKeys.S)) { if (e.INPUT.Keyboard.Shift || string.IsNullOrEmpty(mapFile)) { _IO._iO.FileBrowserSave("NewMap", new string[] { MAP.FILE.Substring(1) }, file => { mapFile = Path.GetFileNameWithoutExtension(file.File); MAP.Save(mapFile, map.Terrains); }); } else { MAP.Save(mapFile, map.Terrains); } } }