public string ColorToControllerId(SideColor color) { if (color == SideColor.Green) return TwoPlayersId.Right; if (color == SideColor.Violet) return TwoPlayersId.Left; throw new ArgumentException("This color is not assigned to any side."); }
public PracticeBoardService(IEngine engine, IAnalysisReceiver analysisReceiver) { UserColor = SideColor.White; this.engine = engine; this.analysisReceiver = analysisReceiver; mainSynchronizationContext = SynchronizationContext.Current; }
private void SwitchColorExecuted(object obj) { UserColor = UserColor == SideColor.Black ? SideColor.White : SideColor.Black; if (practiceBoardService.UserColor != BoardViewModel.Perspective) { BoardViewModel.TogglePerspectiveCommand.Execute(null); } }
public King(Vector2Int position, SideColor side, ChessBoard board) { this.Position = position; this.side = side; this.board = board; // Sets piece type PieceType = ((int)side).ToString() + "K"; }
public AnalysisLineViewModel(SideColor gameStartedBy, AnalysisData analysisData, IList <MoveData> moves) { this.gameStartedBy = gameStartedBy; this.analysisData = analysisData; this.isWhiteFirstMove = gameStartedBy == SideColor.White && moves.First().Index % 2 == 0 || gameStartedBy == SideColor.Black && moves.First().Index % 2 != 0; this.Moves = moves; }
public bool IsComputerTurn() { SideColor sideToMove = IsWhiteTurn ? SideColor.White : SideColor.Black; if (sideToMove == UserColor) { return(false); } return(true); }
public bool IsComputerTurn() { SideColor sideToMove = IsWhiteTurn ? SideColor.White : SideColor.Black; SideColor userColor = WasBlackFirstToMove() ? SideColor.White : SideColor.Black; if (sideToMove == userColor) { return(false); } return(true); }
int Sign(SideColor color) { switch (color) { case SideColor.Green: return 1; case SideColor.Violet: return -1; default: return 0; } }
private void CheckSand(SideColor color) { var sandInBuildingArea = world.IdGenerator.GetAllPairsOfType<TBBObject>() .Where(x => x.Item1.Type == ObjectType.SandCone || x.Item1.Type == ObjectType.SandCube || x.Item1.Type == ObjectType.SandCylinder) .Where(x => world.Engine.FindParent(x.Item2) == null) .Where(x => world.Helper.IsInsideBuildingArea(world.Engine.GetAbsoluteLocation(x.Item2), color)); foreach (var sandBox in sandInBuildingArea) world.Scores.Add(world.Helper.ColorToControllerId(color), 2, "Sand block in building area.", RecordType.Temporary); }
public void CreateBeachHut(string id, Point2D location, SideColor color) { var hut = GameObject.CreatePrimitive(PrimitiveType.Cube); Point3D size = new Point3D(12, 12, 16); hut.transform.position = new Vector3((float)location.X, (float)size.Z / 2, (float)location.Y); hut.transform.localScale = new Vector3((float)size.X, (float)size.Z, (float)size.Y); hut.GetComponent<Renderer>().material.color = GetDrawingColor(color); hut.name = id; }
public static void Create(SideColor sideColor, int delay, string text, string title, bool allowToDisapear = true) { new System.Threading.Thread(() => { using (NotificationCard card = new NotificationCard(text, title) { DelayToDisapear = delay, AllowDisapear = allowToDisapear, CardSideColor = sideColor }) { card.ShowDialog(); } }).Start(); }
public void CreateClapperboard(string clapperboardId, AIRLab.Mathematics.Point2D location, SideColor color) { var clapperboard = GameObject.CreatePrimitive(PrimitiveType.Cube); clapperboard.transform.position = new Vector3((float)location.X, 7, (float)location.Y); clapperboard.transform.localScale = new Vector3(16, 10, 5); clapperboard.GetComponent<Renderer>().material.color = Color.black; var cap = GameObject.CreatePrimitive(PrimitiveType.Cube); cap.transform.position = new Vector3((float)location.X, 14.5f, (float)location.Y); cap.transform.Translate(openClapperCapOffset); cap.transform.rotation = Quaternion.Euler(0, 0, 60); cap.transform.localScale = new Vector3(16, 5, 5); cap.GetComponent<Renderer>().material.color = UnityColor[color]; cap.name = clapperboardId; }
//TODO: this should not know anything about user color // move this to view model public void SwitchUserColor() { bool wasStarted = isStarted; if (wasStarted) { Stop(); } UserColor = UserColor == SideColor.Black ? SideColor.White : SideColor.Black; if (wasStarted) { Start(); } }
public static RankOrFieldViewModel[] GetFields(SideColor color) { var result = new[] { new RankOrFieldViewModel('a'), new RankOrFieldViewModel('b'), new RankOrFieldViewModel('c'), new RankOrFieldViewModel('d'), new RankOrFieldViewModel('e'), new RankOrFieldViewModel('f'), new RankOrFieldViewModel('g'), new RankOrFieldViewModel('h'), }; if (color == SideColor.Black) { result = result.Reverse().ToArray(); } LoadIndexes(result); return(result); }
public static RankOrFieldViewModel[] GetRanks(SideColor color) { var result = new [] { new RankOrFieldViewModel('8'), new RankOrFieldViewModel('7'), new RankOrFieldViewModel('6'), new RankOrFieldViewModel('5'), new RankOrFieldViewModel('4'), new RankOrFieldViewModel('3'), new RankOrFieldViewModel('2'), new RankOrFieldViewModel('1'), }; if (color == SideColor.Black) { result = result.Reverse().ToArray(); } LoadIndexes(result); return(result); }
public bool IsInsideBuildingArea(Frame3D location, SideColor color) { return Distance(location, buildingAreaCenter) < 60 && location.Y < 25 && location.X * Sign(color) >= 0; }
public override void LoadPosition(PositionLoadOptions positionLoadOptions) { base.LoadPosition(positionLoadOptions); UserColor = positionLoadOptions.Perspective; }
/// <summary> /// Hedef hücrede rakip taş varsa ye ve harekete izin ver. /// Kendi taşı varsa harekete izin verme. /// Taş yoksa harekete izin ver. /// İşlemi MoveStatusa kaydet /// </summary> /// <param name="model"></param> /// <returns></returns> private bool RivalPieceEatOrMoveToEmptyCell(GameViewModel model, Cell cellFrom = null, Cell cellTo = null) { if (cellFrom != null) { _cellFrom = cellFrom; } else { _cellFrom = new Cell() { Row = Convert.ToInt32(model.fromCell.Substring(0, 1)), Col = Convert.ToInt32(model.fromCell.Substring(1, 1)) } }; if (cellTo != null) { _cellTo = cellTo; } else { _cellTo = new Cell() { Col = Convert.ToInt32(model.toCell.Substring(1, 1)), Row = Convert.ToInt32(model.toCell.Substring(0, 1)) } }; var destinationCell = model.Pieces.SingleOrDefault(e => e.Col == _cellTo.Col && e.Row == _cellTo.Row); SideColor sorgu = model.Turn; if (cellFrom != null) { sorgu = sorgu == SideColor.White ? SideColor.Black : SideColor.White; } if (destinationCell != null) { if (destinationCell.Color == sorgu) { model.IsMoveCorrect = false; return(false); } if (cellFrom == null) { model.IsMoveCorrect = true; destinationCell.Row = 0; destinationCell.Col = 0; destinationCell.Status = PieceStatus.Eated; } } else { var aPiece = model.Pieces.Find(e => e.Col == _cellFrom.Col && e.Row == _cellFrom.Row); if (aPiece.Name == "Pawn") { int yDifference = _cellTo.Row - _cellFrom.Row; var specialPawn = model.Pieces.Find(e => e.Col == _cellTo.Col && e.Row == _cellTo.Row - yDifference && e.Status == PieceStatus.PawnDoubleMove); if (specialPawn != null && cellFrom == null) { specialPawn.Col = 0; specialPawn.Row = 0; specialPawn.Status = PieceStatus.Eated; } } model.IsMoveCorrect = true; } return(true); }
public void CreateSeashell(string id, Point2D location, SideColor color) { var seashell = GameObject.CreatePrimitive(PrimitiveType.Cylinder); var locationZ = Math.Abs(location.X) > 120 && location.Y < -70 ? floorLevel + 6 : floorLevel; seashell.transform.position = new Vector3((float)location.X, locationZ, (float)location.Y); seashell.transform.localScale = new Vector3(7.62f, 2.5f, 7.62f); seashell.GetComponent<Renderer>().material.color = GetDrawingColor(color); seashell.GetComponent<CapsuleCollider>().enabled = false; seashell.AddComponent<MeshCollider>(); seashell.GetComponent<MeshCollider>().convex = true; seashell.AddComponent<Rigidbody>(); seashell.GetComponent<Rigidbody>().drag = seashell.GetComponent<Rigidbody>().angularDrag = 4; seashell.GetComponent<Rigidbody>().useGravity = true; seashell.GetComponent<Rigidbody>().mass = 0.3f; seashell.name = id; }
public TBBObject(SideColor color, ObjectType type) { Color = color; Type = type; }
public static void Create(SideColor sideColor, int delay, string text) => Create(sideColor, delay, text, "Modetor");
public static void Create(SideColor sideColor, string text) => Create(sideColor, 2500, text, "Modetor");
public Seashell(Point2D position, SideColor color) { Position = position; Color = color; }
public void CreateFish(string id, Point2D location, SideColor color) { var fish = GameObject.CreatePrimitive(PrimitiveType.Sphere); fish.transform.position = new Vector3((float)location.X, floorLevel + 5, (float)location.Y); fish.transform.localScale = new Vector3(5.3f, 5.3f, 9.7f); fish.GetComponent<Renderer>().material.color = GetDrawingColor(color); fish.AddComponent<Rigidbody>(); fish.GetComponent<Rigidbody>().drag = fish.GetComponent<Rigidbody>().angularDrag = 4; fish.GetComponent<Rigidbody>().useGravity = true; fish.GetComponent<Rigidbody>().mass = 0.3f; fish.name = id; }
private bool IsCheck(GameViewModel model, bool AfterMove = false) //After Move true olursa rakip şah kontrol edilir. { SideColor KingColor = model.Turn; if (AfterMove) { KingColor = KingColor == SideColor.White ? SideColor.Black : SideColor.White; } var King = model.Pieces.SingleOrDefault(e => e.Name == "King" && e.Color == KingColor); var CounterPieces = model.Pieces.Where(e => e.Color != KingColor && e.Col != 0 && e.Row != 0); Cell cellto1 = new Cell(); Cell cellFrom1 = new Cell(); var oynanacak = new PieceModel(); var yenecek = new PieceModel(); if (!AfterMove) { cellto1 = new Cell() { Col = Convert.ToInt32(model.toCell.Substring(1, 1)), Row = Convert.ToInt32(model.toCell.Substring(0, 1)) }; cellFrom1 = new Cell() { Row = Convert.ToInt32(model.fromCell.Substring(0, 1)), Col = Convert.ToInt32(model.fromCell.Substring(1, 1)) }; yenecek = model.Pieces.Find(e => e.Col == cellto1.Col && e.Row == cellto1.Row); if (yenecek != null) { yenecek.Row = 0; yenecek.Col = 0; } oynanacak = model.Pieces.Find(e => e.Col == cellFrom1.Col && e.Row == cellFrom1.Row); oynanacak.Row = cellto1.Row; oynanacak.Col = cellto1.Col; } foreach (var aPiece in CounterPieces) { var cellto = new Cell(); var cellFrom = new Cell(); cellto = new Cell { Row = King.Row, Col = King.Col }; cellFrom = new Cell() { Row = aPiece.Row, Col = aPiece.Col }; if (IsCellCorrect(model, cellFrom, cellto)) { if (AfterMove) { return(true); } if (RivalPieceEatOrMoveToEmptyCell(model, cellFrom, cellto)) { if (yenecek != null) { yenecek.Row = cellto1.Row; yenecek.Col = cellto1.Col; } oynanacak.Row = cellFrom1.Row; oynanacak.Col = cellFrom1.Col; return(true); } } } if (!AfterMove) { if (yenecek != null) { yenecek.Row = cellto1.Row; yenecek.Col = cellto1.Col; } oynanacak.Row = cellFrom1.Row; oynanacak.Col = cellFrom1.Col; } return(false); }
private Color GetDrawingColor(SideColor color) { if (color == SideColor.Any) return Color.white; return color == SideColor.Green ? Color.green : Color.yellow; }
public void CreateStairs(string stairsId, AIRLab.Mathematics.Point2D centerLocation, SideColor color) { var offset = new Vector3((float)centerLocation.X, 0, (float)centerLocation.Y); float ySize = 7; Func<float, float> getYSize = y => -ySize / (7 * 4) * (y - 39) + ySize; float width = 50; float bottomLength = 60; float topLength = bottomLength - 21; int stairsCount = 3; var stairStep = (bottomLength - topLength) / stairsCount; for (var length = topLength; length <= bottomLength; length += stairStep) { var height = getYSize(length); var stair = GameObject.CreatePrimitive(PrimitiveType.Cube); stair.transform.position = new Vector3(0, 0, (bottomLength - length) / 2); stair.transform.Translate(offset + Vector3.up * height / 2); stair.transform.localScale = new Vector3(width, height, length); stair.GetComponent<Renderer>().material.color = UnityColor[color]; stair.name = length == topLength ? stairsId : "wall"; } Action<float> addBorder = x => { var border = GameObject.CreatePrimitive(PrimitiveType.Cube); border.transform.localScale = new Vector3(3, ySize + 2.2f, bottomLength); border.transform.position = new Vector3(x, (ySize + 2.2f) / 2, 0) + offset; border.GetComponent<Renderer>().material.color = Color.blue; }; addBorder(width / 2); addBorder(-width / 2); }
public void ReloadBoard(SideColor changedPerspectiveColor) { BoardViewModel.RefreshBoard(changedPerspectiveColor); NotationViewModel.ReloadMoves(); }
public void CreateStand(string standId, AIRLab.Mathematics.Point2D location, SideColor color) { var stand = GameObject.CreatePrimitive(PrimitiveType.Cylinder); stand.transform.position = new Vector3((float)location.X, 3.5f, (float)location.Y); stand.transform.localScale = new Vector3(6, 3.45f, 6); stand.GetComponent<Renderer>().material.color = UnityColor[color]; stand.AddComponent<Rigidbody>(); stand.GetComponent<Rigidbody>().drag = stand.GetComponent<Rigidbody>().angularDrag = 4; stand.GetComponent<Rigidbody>().useGravity = true; stand.GetComponent<Rigidbody>().mass = 0.3f; stand.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; stand.name = standId; }
public void RefreshBoard(SideColor changedPerspective) { Perspective = changedPerspective; UpdateRankAndFields(); RefreshSquares(); }
public void CreateStartingArea(AIRLab.Mathematics.Point2D centerLocation, SideColor color) { var offset = new Vector3((float)centerLocation.X, 1.5f, (float)centerLocation.Y); var top = GameObject.CreatePrimitive(PrimitiveType.Cube); top.transform.position = new Vector3(0, 0, 40 / 2) + offset; var bottom = GameObject.CreatePrimitive(PrimitiveType.Cube); bottom.transform.position = new Vector3(0, 0, -40 / 2) + offset; top.transform.localScale = bottom.transform.localScale = new Vector3(40, 3, 3); bottom.GetComponent<Renderer>().material.color = top.GetComponent<Renderer>().material.color = UnityColor[color]; }
private void CheckSeashells(SideColor color) { var seashells = world.IdGenerator.GetAllPairsOfType<TBBObject>() .Where(x => x.Item1.Type == ObjectType.Seashell) .Where(x => x.Item1.Color == SideColor.Any || x.Item1.Color == color) .Where(x => world.Engine.FindParent(x.Item2) == null) .Where(x => world.Helper.IsInsideStartingArea(world.Engine.GetAbsoluteLocation(x.Item2), color)); foreach (var seashell in seashells) world.Scores.Add(world.Helper.ColorToControllerId(color), 2, "Valid seashell in the starting area", RecordType.Temporary); }
public bool IsInsideStartingArea(Frame3D location, SideColor color) { return Math.Abs(location.X) > 150 - 30 && location.X * Sign(color) >= 0 && location.Y < 40 && location.Y > -10; }