public void ChangeTile(int x, int y, eCountry country) { Destroy(GetTile(x, y).gameObject); MapTileData mapTileData = mapData.tiles[getTileIndex(x, y)]; createTile(x, y, country, mapTileData); }
//Sửa thông tin quốc gia public void updateCountry(eCountry q) { nuoc temp = db.nuocs.Where(x => x.maNuoc.ToString().Equals(q.Id)).FirstOrDefault(); // Cập nhật dữ liệu temp.maNuoc = q.Id; temp.tenNuoc = q.Name; db.SubmitChanges(); }
public TroopInfo GetTroopInfo(eTroopType type, eCountry country) { foreach (TroopInfo ti in troopList) { if (ti.type == type && ti.country == country) { return(ti); } } return(null); }
public GameObject GetTilePrefab(eCountry country) { // 只按照阵营划分 foreach (TileInfo ti in tileList) { if (ti.country == country) { return(ti.prefab); } } return(null); }
private void onGetOccupyTile(eCountry country) { int i = 0; foreach (MapTile mt in modelGame.mapTiles.Values) { if (mt.country == country) { i++; } } signalGetOccupyTile.OccupyTileCount = i; }
private void onGameOver(eCountry winner) { if (winner == eCountry.A) { view.flagWin.SetActive(true); view.flagFail.SetActive(false); } else if (winner == eCountry.B) { view.flagWin.SetActive(false); view.flagFail.SetActive(true); } gameObject.SetActive(true); }
//Nhập quốc gia mới vào database public int insertCountry(eCountry q) { if (checkIDExist(q.Id)) { return(0); } nuoc temp = new nuoc(); temp.maNuoc = q.Id; temp.tenNuoc = q.Name; db.nuocs.InsertOnSubmit(temp); db.SubmitChanges(); return(1); }
//Lấy toàn bộ quốc gia có trong database public List <eCountry> getAllCountry() { var list = (from m in db.nuocs orderby m.tenNuoc //Sắp xếp select m).ToList(); List <eCountry> ls = new List <eCountry>(); foreach (var m in list) { eCountry e = new eCountry(); e.Id = m.maNuoc.ToString(); e.Name = m.tenNuoc; ls.Add(e); } return(ls); }
public void MakeTroop(eTroopType type, eCountry country, int x, int y) { TroopInfo ti = troopData.GetTroopInfo(type, country); GameObject troopGo = Instantiate(ti.prefab, transform); troopGo.transform.localPosition = GridToPosition(x, y); Troop t = troopGo.GetComponent <Troop>(); t.type = type; t.country = country; t.x = x; t.y = y; t.SetTapCallback(onTapTroop); t.sortingGroup.sortingOrder = GetTroopOrder(x, y); t.FINISH_ACTION = true; mapTiles[x + "_" + y].troop = t; }
private void createTile(int x, int y, eCountry country, MapTileData mapTileData) { GameObject go = Instantiate(tileData.GetTilePrefab(country), transform); go.name = "tile_" + x + "_" + y; go.transform.localScale = Vector3.one; go.transform.localPosition = GridToPosition(x, y); MapTile tile = go.GetComponent <MapTile>(); tile.type = mapTileData.type; tile.country = country; tile.SetOrder(getTileOrder(x, y)); tile.SetTile(x, y); tile.SetTapCallback(onTapTile); mapTiles[x + "_" + y] = tile; if (mapTileData.type == eTileType.CoreLand) { if (mapTileData.initCountry == eCountry.A) { go = Instantiate(Resources.Load <GameObject>("baseA"), transform); go.transform.localPosition = GridToPosition(x, y); go.GetComponent <SortingGroup>().sortingOrder = getObjOrder(x, y); } else if (mapTileData.initCountry == eCountry.B) { go = Instantiate(Resources.Load <GameObject>("baseB"), transform); go.transform.localPosition = GridToPosition(x, y); go.GetComponent <SortingGroup>().sortingOrder = getObjOrder(x, y); } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtID.Text.Length == 0 || txtName.Text.Length == 0) { MessageBox.Show("Không chừa trống dữ liệu nhập !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtID.Text.Length != 3) { MessageBox.Show("Mã có số kí tự bằng 3 !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } eCountry sup = new eCountry(); sup.Id = txtID.Text; sup.Name = txtName.Text; if (btnSave.Text.Equals("Lưu thêm")) { try { int result = bCou.insertCountry(sup); if (result == 1) { clearTextbox(); btnSave.Enabled = false; btnSave.Text = "Lưu"; btnSave.BackColor = Color.Gainsboro; btnNew.Text = "Thêm"; btnNew.BackColor = Color.Gainsboro; label2.Text = ""; setOnOffEditTextbox(0); btnSave.ForeColor = Color.Black; btnNew.ForeColor = Color.Black; btnUpdate.Enabled = true; btnDelete.Enabled = true; MessageBox.Show("Thêm quốc gia mới thành công !", "Thêm NCC", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvCountryList.DataSource = bCou.getAllCountry(); } else { MessageBox.Show("Mã quốc gia bị trùng ! Vui lòng thử lại !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { bCou.updateCountry(sup); btnSave.Enabled = false; btnSave.Text = "Lưu"; btnSave.BackColor = Color.Gainsboro; btnUpdate.Text = "Sửa"; btnUpdate.BackColor = Color.Gainsboro; label2.Text = ""; setOnOffEditTextbox(0); btnSave.ForeColor = Color.Black; btnUpdate.ForeColor = Color.Black; btnNew.Enabled = true; btnDelete.Enabled = true; MessageBox.Show("Cập nhập quốc gia thành công !", "Cập nhập", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvCountryList.DataSource = bCou.getAllCountry(); } }
public void updateCountry(eCountry c) { dCou.updateCountry(c); }
public int insertCountry(eCountry c) { return(dCou.insertCountry(c)); }
// 建造部队 private void onMakeTroop(eTroopType troopType, eCountry country, int x, int y) { view.MakeTroop(troopType, country, x, y); }