public bool CanControlThisPlayer(AreaPosition owner) { bool PlayersTurn = (TurnManager.Instance.whoseTurn == Players[owner]); bool NotDrawingAnyCards = !Command.CardDrawPending(); return(Players[owner].PArea.AllowedToControlThisPlayer && Players[owner].PArea.ControlsON && PlayersTurn && NotDrawingAnyCards); }
public void initialize(float x, float y, ModelType type, AreaPosition _position = AreaPosition.NA, bool givenIsHorizontal = true) { mapPosition = new Vector2(x, y); isHorizontal = givenIsHorizontal; areaPosition = _position; createModel(type); }
public string CreateNewAreaPoint(string pointName, decimal longitude, decimal latitude, int areaId) { WorkspaceDataSaveResult saveResult = new WorkspaceDataSaveResult(); pointName = pointName.Trim(); var statusId = SystemStaticData.LookUpSystemIncomeStatusId(SystemStaticData.SystemIncomeDictionary.Normal); var existPoint = db.AreaPosition.FirstOrDefault(p => p.Latitude == latitude && p.Longitude == longitude); if (existPoint != null) { saveResult.Status = (int)DataSaveStatus.DataValidationError; saveResult.Description = "该点已存在地标"; return(new JavaScriptSerializer().Serialize(saveResult)); } AreaPosition model = new AreaPosition(); model.Status = statusId; model.Latitude = latitude; model.Longitude = longitude; model.CreateAt = DateTime.Now; model.AreaId = areaId; model.PositionName = pointName; db.AreaPosition.Add(model); db.SaveChanges(); saveResult.Status = (int)DataSaveStatus.Success; saveResult.Description = "创建成功"; return(new JavaScriptSerializer().Serialize(saveResult)); }
public void Board1x1_CurrentState_Test() { var game = new Game(); game.CreateBoard(new AreaSize(1, 1)); var position = new AreaPosition(0, 0); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(-1, -1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(0, -1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(1, -1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(-1, 0))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(1, 0))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(-1, 1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(0, 1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(1, 1))); Assert.AreEqual(0, game.GetAliveNeighbors(position)); game.Board.Columns[0][0] = true; Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(-1, -1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(0, -1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(1, -1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(-1, 0))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(1, 0))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(-1, 1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(0, 1))); Assert.AreEqual(0, game.CurrentState(position.GetOffsetPosition(1, 1))); Assert.AreEqual(0, game.GetAliveNeighbors(new AreaPosition(0, 0))); }
public async Task UpdateAreaPosition(AreaPosition model) { var uid = HttpContext.User.FindFirst("user_id"); if (ModelState.IsValid) { var _envSetting = await _dbContext.EnvSettings.FirstOrDefaultAsync(x => x.Uid == uid.Value); if (_envSetting == null) { _dbContext.EnvSettings.Add(new EnvSetting() { Uid = uid.Value, MaxHeight = model.MaxHeight, MaxWidth = model.MaxWidth, StartX = model.StartX, StartY = model.StartY }); } else { _envSetting.MaxHeight = model.MaxHeight; _envSetting.MaxWidth = model.MaxWidth; _envSetting.StartX = model.StartX; _envSetting.StartY = model.StartY; } await _dbContext.SaveChangesAsync(); } }
public bool CanControlThisPlayer(AreaPosition owner) { // TODO: This might need to change to reflect Event, or be removed // bool PlayersTurn = (TurnManager.Instance.whoseTurn == Players[owner]); bool PlayersTurn = true; bool NotDrawingAnyCards = !Command.CardDrawPending(); return(Players[owner].PArea.AllowedToControlThisPlayer && Players[owner].PArea.ControlsON && PlayersTurn && NotDrawingAnyCards); }
// CONSTRUCTOR public Ente(AreaPosition area, CartaBase ca) { this.area = area; this.assetCarta = ca; defensa = ca.Defensa; ataque = ca.Ataque; idCriatura = IDFactory.GetBattleUniqueID(); Recursos.EntesCreadosEnElJuego.Add(idCriatura, this); }
private void setRegion(int prefixWidth, int prefixHeight, AreaPosition pos) { int prefixBlockSize = (int)(SimParameter.unitBlockSize / 2.0f); region = Rect.MinMaxRect(center.x - prefixWidth, center.y - prefixHeight, center.x + prefixWidth, center.y + prefixHeight); region = Rect.MinMaxRect(region.xMin * SimParameter.unitBlockSize - prefixBlockSize + (pos == AreaPosition.NE || pos == AreaPosition.SE ? +SimParameter.unitBlockSize : 0), region.yMin * SimParameter.unitBlockSize - prefixBlockSize + (pos == AreaPosition.NE || pos == AreaPosition.NW ? +SimParameter.unitBlockSize : 0), region.xMax * SimParameter.unitBlockSize - prefixBlockSize + (pos == AreaPosition.NW || pos == AreaPosition.SW ? -SimParameter.unitBlockSize : 0), region.yMax * SimParameter.unitBlockSize - prefixBlockSize + (pos == AreaPosition.SW || pos == AreaPosition.SE ? -SimParameter.unitBlockSize : 0)); }
private void ImportComponent(Board component) { if (this.game.Board == null || this.game.Board.AreaSize.Width < component.AreaSize.Width || this.game.Board.AreaSize.Height < component.AreaSize.Height) { this.InitializeBoard(component.AreaSize); } var position = new AreaPosition((this.game.Board.AreaSize.Width - component.AreaSize.Width) / 2, (this.game.Board.AreaSize.Height - component.AreaSize.Height) / 2); var board = this.game.ImportComponent(position, component); this.UpdateBoard(board); }
public bool CanControlThisPlayer(AreaPosition areaViewOwner) { bool PlayersTurn = (GameManager.Instance.WhoseTurn == Players[areaViewOwner]); return(Players[areaViewOwner].playerView.AllowedToControlThisPlayer && Players[areaViewOwner].playerView.ControlsON && PlayersTurn); }
private void createABuilding(Rect region, ref List <GameObject> buildingOnArea, AreaPosition pos) { GameObject aBuilding = getRandomBuilding(); BoxCollider boxCollider = aBuilding.transform.GetComponent <BoxCollider>(); Vector3 newPosition = Vector3.zero; if (pos == AreaPosition.SW) { newPosition = new Vector3(region.xMin + boxCollider.bounds.size.x / 2, boxCollider.bounds.max.y + SimParameter.areaHeight + SimParameter.blockHeightHalf, region.yMin + boxCollider.bounds.size.z / 2); } else if (pos == AreaPosition.NW) { newPosition = new Vector3(region.xMin + boxCollider.bounds.size.x / 2, boxCollider.bounds.max.y + SimParameter.areaHeight + SimParameter.blockHeightHalf, region.yMax - boxCollider.bounds.size.z / 2); } else if (pos == AreaPosition.SE) { newPosition = new Vector3(region.xMax - boxCollider.bounds.size.x / 2, boxCollider.bounds.max.y + SimParameter.areaHeight + SimParameter.blockHeightHalf, region.yMin + boxCollider.bounds.size.z / 2); } else { newPosition = new Vector3(region.xMax - boxCollider.bounds.size.x / 2, boxCollider.bounds.max.y + SimParameter.areaHeight + SimParameter.blockHeightHalf, region.yMax - boxCollider.bounds.size.z / 2); } aBuilding.transform.position = newPosition; aBuilding.transform.parent = this.transform; buildingOnArea.Add(aBuilding); }
// CONSTRUCTOR public Criatura(AreaPosition area, CartaBase ca, PosicionCriatura posicionCriatura) : base(area, ca) { this.posicionCriatura = posicionCriatura; this.haAtacado = false; }
public void initialize(int givenWidth, int givenHeight, Vector2 givenCenter, AreaPosition pos, AreaType type, ref List <Block> sidewalks) { areaSetIndex = -1; areaPosition = pos; center = givenCenter; width = givenWidth; height = givenHeight; transform.name = type.ToString(); int prefixWidth = width / 2; int prefixHeight = height / 2; setRegion(prefixWidth, prefixHeight, pos); blocks = new List <List <Block> >(); for (int i = 0; i < width; i++) { blocks.Add(new List <Block>()); for (int k = 0; k < height; k++) { if (putSidewalkBlock(i, k, width, height, prefixWidth, prefixHeight, ref sidewalks)) { continue; } float idxX = i - prefixWidth + (int)center.x; float idxY = k - prefixHeight + (int)center.y; if (type == AreaType.Intersection) { blocks[i].Add(Object.Instantiate((Resources.Load("Prefab/DummyObjects/DummyRoadBlock") as GameObject).GetComponent <RoadBlock>(), Vector3.zero, Quaternion.identity) as SCPAR.SIM.PVATestbed.RoadBlock); blocks[i][blocks[i].Count - 1].initialize(idxX, idxY, ModelType.RoadIntersection); } else if (type == AreaType.AreaBlock) { blocks[i].Add(Object.Instantiate((Resources.Load("Prefab/DummyObjects/DummyAreaBlock") as GameObject).GetComponent <AreaBlock>(), Vector3.zero, Quaternion.identity) as SCPAR.SIM.PVATestbed.AreaBlock); blocks[i][blocks[i].Count - 1].initialize(idxX, idxY, ModelType.AreaBuilding); } /* * else if (type == AreaType.Grass) * { * blocks[i].Add(Object.Instantiate(model, Vector3.zero, Quaternion.identity) as SCPAR.SIM.PVATestbed.AreaBlock); * blocks[i][blocks[i].Count - 1].initialize(idxX, idxY, ModelType.AreaGrass); * } * else if (type == AreaType.Building) * { * blocks[i].Add(Object.Instantiate(model, Vector3.zero, Quaternion.identity) as SCPAR.SIM.PVATestbed.AreaBlock); * blocks[i][blocks[i].Count - 1].initialize(idxX, idxY, ModelType.AreaBuilding); * } * else if (type == AreaType.Forest) * { * blocks[i].Add(Object.Instantiate(model, Vector3.zero, Quaternion.identity) as SCPAR.SIM.PVATestbed.AreaBlock); * blocks[i][blocks[i].Count - 1].initialize(idxX, idxY, ModelType.AreaForest); * } */ blocks[i][blocks[i].Count - 1].transform.parent = transform; } } // create more roadblock for four corners of an intersection if (type == AreaType.Intersection) { RoadBlock temp = Object.Instantiate((Resources.Load("Prefab/DummyObjects/DummyRoadBlock") as GameObject).GetComponent <RoadBlock>(), Vector3.zero, Quaternion.identity, transform) as SCPAR.SIM.PVATestbed.RoadBlock; temp.initialize(-1 - prefixWidth + (int)center.x, -1 - prefixHeight + (int)center.y, ModelType.RoadNormal); temp = Object.Instantiate((Resources.Load("Prefab/DummyObjects/DummyRoadBlock") as GameObject).GetComponent <RoadBlock>(), Vector3.zero, Quaternion.identity, transform) as SCPAR.SIM.PVATestbed.RoadBlock; temp.initialize(width - prefixWidth + (int)center.x, height - prefixHeight + (int)center.y, ModelType.RoadNormal); temp = Object.Instantiate((Resources.Load("Prefab/DummyObjects/DummyRoadBlock") as GameObject).GetComponent <RoadBlock>(), Vector3.zero, Quaternion.identity, transform) as SCPAR.SIM.PVATestbed.RoadBlock; temp.initialize(width - prefixWidth + (int)center.x, -1 - prefixHeight + (int)center.y, ModelType.RoadNormal); temp = Object.Instantiate((Resources.Load("Prefab/DummyObjects/DummyRoadBlock") as GameObject).GetComponent <RoadBlock>(), Vector3.zero, Quaternion.identity, transform) as SCPAR.SIM.PVATestbed.RoadBlock; temp.initialize(-1 - prefixWidth + (int)center.x, height - prefixHeight + (int)center.y, ModelType.RoadNormal); } }
// CONSTRUCTOR public Magica(AreaPosition area, CartaBase ca) : base(area, ca) { this.efectoActivado = false; }