public IHttpActionResult PutHouseArea(int id, HouseArea houseArea) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != houseArea.Id) { return(BadRequest()); } db.Entry(houseArea).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HouseAreaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// 从buffer中解析房区信息 /// </summary> /// <param name="message"></param> public HousingSlotSnapshot(byte[] message) { Time = DateTime.Now; var dataList = message.SubArray(32, message.Length - 32); var dataHeader = dataList.SubArray(0, 8); switch (dataHeader[4]) { case 0x53: Area = HouseArea.海雾村; break; case 0x54: Area = HouseArea.薰衣草苗圃; break; case 0x55: Area = HouseArea.高脚孤丘; break; case 0x81: Area = HouseArea.白银乡; break; } Slot = dataHeader[2]; for (int i = 8; i < dataList.Length; i += 40) { int houseId = (i - 8) / 40; HousingItem house = new HousingItem(this, houseId, dataList.SubArray(i, 40)); HouseList.Add(houseId, house); } }
public HousingOnSaleItem(HouseArea _area, int _slot, int _id, HouseSize _size, int _price, bool _status) { Area = _area; Slot = _slot + 1; Id = _id + 1; Size = _size; Price = _price; AddTime = DateTime.Now; ExistenceTime = DateTime.Now; CurrentStatus = _status; }
public IHttpActionResult GetHouseArea(int id) { HouseArea houseArea = db.HouseAreas.Find(id); if (houseArea == null) { return(NotFound()); } return(Ok(houseArea)); }
public IHttpActionResult PostHouseArea(HouseArea houseArea) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.HouseAreas.Add(houseArea); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = houseArea.Id }, houseArea)); }
public void OnToggleBranch() { if (heldBranch != null) // player has a branch, put it down { Vector3 offset = new Vector3(0f, 2f, 0f); heldBranch.transform.position = transform.position + offset; heldBranch.SetActive(true); heldBranch = null; branchIcon.SetActive(false); anim.SetBool("HasBranch", false); } else // player not holding a branch, try to pick one up { if (role == PLAYER_TYPE.ZOOKEEPER) // Zookeepers can pull logs out from the beaver house { float radius = 2f; Collider[] colliders = Physics.OverlapSphere(transform.position, radius); foreach (Collider collider in colliders) { HouseArea houseArea = collider.gameObject.GetComponent <HouseArea>(); if (houseArea != null) { heldBranch = Instantiate(branchPrefab, transform.position, transform.rotation); heldBranch.SetActive(false); Branch branchData = heldBranch.GetComponent <Branch>(); branchData.SetLevel(2); branchData.antiValue = 2; anim.SetBool("HasBranch", true); pickupSound.PlayOneShot(pickupSound.clip, 20f); return; // if we pull it out from the beaver house, we are done } } } // get the nearest branch object GameObject nearestBranch = GetNearestBranch(); if (nearestBranch != null) { heldBranch = nearestBranch; nearestBranch.SetActive(false); // make the branch invisible to players anim.SetBool("HasBranch", true); pickupSound.PlayOneShot(pickupSound.clip, 20f); if (role == PLAYER_TYPE.BEAVER) { branchIcon.GetComponent <SpriteRenderer>().sprite = heldBranch.GetComponent <SpriteRenderer>().sprite; branchIcon.SetActive(true); } } } }
public IHttpActionResult DeleteHouseArea(int id) { HouseArea houseArea = db.HouseAreas.Find(id); if (houseArea == null) { return(NotFound()); } db.HouseAreas.Remove(houseArea); db.SaveChanges(); return(Ok(houseArea)); }
public static string GetHouseAreaStr(HouseArea area) { switch (area) { case HouseArea.海雾村: return("海雾村"); case HouseArea.薰衣草苗圃: return("薰衣草苗圃"); case HouseArea.高脚孤丘: return("高脚孤丘"); case HouseArea.白银乡: return("白银乡"); default: return("未知"); } }
// Start is called before the first frame update void Awake() { for (int i = 0; i < Setting.areaDeckCount[Setting.AreaType.Ant]; i++) { areaList.Add(new AntArea()); } for (int i = 0; i < Setting.areaDeckCount[Setting.AreaType.Rotate]; i++) { areaList.Add(new RotateArea()); } for (int i = 0; i < Setting.areaDeckCount[Setting.AreaType.Exchange]; i++) { areaList.Add(new ExchangeArea()); } for (int i = 0; i < Setting.areaDeckCount[Setting.AreaType.EPresent]; i++) { areaList.Add(new EpresentArea()); } for (int i = 0; i < Setting.areaDeckCount[Setting.AreaType.Gap]; i++) { areaList.Add(new GapArea()); } for (int i = 0; i < Setting.areaDeckCount[Setting.AreaType.Grass]; i++) { areaList.Add(new GrassArea()); } for (int i = Setting.MIN_AREA; i <= Setting.MAX_AREA; i++) { for (int j = Setting.MIN_AREA; j <= Setting.MAX_AREA; j++) { Vector3Int key = new Vector3Int(i, j, 0); if (tilemap.HasTile(key)) { lights[key] = Instantiate(lightPrefab, GetWorldPosition(key), Quaternion.identity, transform); highlights[key] = Instantiate(highlightPrefab, GetWorldPosition(key), Quaternion.identity, transform); lights[key].SetActive(false); highlights[key].SetActive(false); if (key == Setting.houseStartIndex) { areas[key] = new HouseArea(); areas[key].Trigger(key); areas[key].ShowForward(tilemap, key); continue; } else if (key == Setting.girlStartIndex) { areas[key] = new Way1_2_3_4_5_6Area(TileManager.Instance.way1_2_3_4_5_6); areas[key].ShowForward(tilemap, key); continue; } else if (key == Setting.antStartIndex) { areas[key] = new GrassArea(); areas[key].ShowForward(tilemap, key); continue; } int id = UnityEngine.Random.Range(0, areaList.Count); var data = areaList[id]; areaList.RemoveAt(id); areas[key] = data; } } } if (areaList.Count != 0) { Debug.LogError(ToString() + "Area count error" + areaList.Count); } }