private void EncodeQuestion(int QuestionNumber, string Question, string objective, string answer, string outputpath) { //QuestionNumber = Convert.ToInt32(ViewState["QuestionNumber"]); //Question = QuestionTextArea.Value; FigureTypes f = new FigureTypes(); int count = 0; using (System.IO.StreamWriter swriter = new System.IO.StreamWriter(outputpath)) { swriter.Write(QuestionNumber + ". "); swriter.WriteLine(Question + System.Environment.NewLine); swriter.Write(f.Alphabet[count] + " " + objective + " "); swriter.WriteLine(); swriter.WriteLine("Answer: " + answer); swriter.WriteLine(); swriter.WriteLine(); } }
public ChessBoard(FigureTypes figure, int startPos) { _figure = figure; _startPosX = startPos / 10; _startPosY = startPos % 10; InitChessBoard(); }
public TangramFigure(FigureTypes type, Color c, PointF location) { FigureType = type; FigureColor = c; Reset(location); created = true; }
private static void ShowTypesOfFigures() { foreach (string s in FigureTypes.GetNames(typeof(FigureTypes))) { ConsoleHelper.Write($"-{s}"); } }
public TangramFigure(FigureTypes type, Color c, PointF location, PointF pivot, float angle) { FigureType = type; FigureColor = c; Reset(location, pivot, angle); created = true; }
private void GenerateOptionFigureTypes(bool IsRoman) { FigureTypes f = new FigureTypes(); int count = 0; if (IsRoman) { foreach (HtmlTableRow hrow in obtable.Rows) { if (hrow.ID != "header_row") { hrow.Cells[1].InnerHtml = f.Romans[count]; count++; } } } else { foreach (HtmlTableRow hrow in obtable.Rows) { if (hrow.ID != "header_row") { hrow.Cells[1].InnerHtml = f.Alphabet[count].ToString(); count++; } } } }
private Figures CreateFigure(FigureTypes figureTypes, bool isWhite) { switch (figureTypes) { case FigureTypes.Queen: { return(new Queen(figureTypes, isWhite)); } case FigureTypes.Rook: { return(new Rook(figureTypes, isWhite)); } case FigureTypes.Bishop: { return(new Bishop(figureTypes, isWhite)); } case FigureTypes.Knight: { return(new Knight(figureTypes, isWhite)); } default: { return(new Pawn(figureTypes, isWhite)); } } }
protected void SendSuperiority(NetworkStream ns, FigureTypes figtype, Position pos) { hassuperiority = false; WriteString(ns, comsuperiority); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(ns, figtype); formatter.Serialize(ns, pos); }
public void NewSuperiority(FigureTypes figtype, Position pos) { lock (lockobj) { hassuperiority = true; superiorityfigtype = figtype; superioritypos = pos; } }
// Start is called before the first frame update void Awake() { NowActiveFigure = FigureTypes.FirstPlayer; if (instance == null) { instance = this; } }
public ChessBoardViewModel InitChessBoard(FigureTypes figure, int startPos) { _chessBoard = new ChessBoardViewModel { Figure = figure, FigurePosition = startPos, PossibleMoves = new ChessBoard(figure, startPos).PossibleMoves }; return(_chessBoard); }
public void CreateBlockInCell(Vector2 coord, int figureIndex) { GameObject figureCube = Instantiate(CubePrefab, this.transform); Color color = FigureTypes.GetСolor(figureIndex); figureCube.GetComponent <SpriteRenderer>().color = color; figureCube.GetComponent <SpriteRenderer>().material.color = color; figureCube.transform.localPosition = GetCellPosition(coord); figureCube.SetActive(true); Cell cell = GetCellByCoord(coord); cell.occupyingCube = figureCube; cell.cubeIndex = figureIndex; }
private void Update() { RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector3.forward); hasFigure = hit.transform.GetComponent <Figure>(); if (hasFigure) { _typeOfFigureOnCell = hit.transform.GetComponent <Figure>().FigureType; } else { _typeOfFigureOnCell = FigureTypes.ZeroFigure; } }
/// <summary> /// Поменять пешку на фигуру заданного типа /// </summary> /// <param name="pos"></param> /// <param name="figuretype"></param> public Figure TransformPawn(Position pos, FigureTypes figuretype) { Figure fig; Side side; side = GetFigureAt(pos).Side; Figure oldfig = SideToPlayer(side).alivefigures[SideToPlayer(side).alivefigures.IndexOf(GetFigureAt(pos))]; fig = CreateFigure(figuretype, pos, side); SetFigureAt(pos, fig); SideToPlayer(side).alivefigures.Remove(oldfig); SideToPlayer(side).alivefigures.Add(fig); fig.MoveEvent += MoveFigureHandler; fig.KillEvent += SideToPlayer(side).KillFigureHandler; // надо восстановить старые обработчики для пешки FIX IT return(fig); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBox1.SelectedIndex) { case 0: figuretype = FigureTypes.Queen; break; case 1: figuretype = FigureTypes.Rook; break; case 2: figuretype = FigureTypes.Bishop; break; case 3 : figuretype = FigureTypes.Knight; break; } }
protected void GetSuperiority(NetworkStream ns, View view, Game game) { BinaryFormatter formatter = new BinaryFormatter(); FigureTypes figtype = (FigureTypes)formatter.Deserialize(ns); Position pos = (Position)formatter.Deserialize(ns); view.Invoke(new Action( () => { game.DirectStateCycle(); game.Field.TransformPawn(pos, figtype); view.DrawField(); game.Field.ShahCheck(game.Field.GetFigureAt(pos)); view.SetTurnText(); view.WhiteCount(game.Player1.GetCount()); view.BlackCount(game.Player2.GetCount()); })); }
public void Start() { foreach (Transform child in this.transform) { GameObject.Destroy(child.gameObject); } FigureTypes.Init(); cells = new Cell[sizeX, sizeY]; startPositon = new Vector3(-cellSize.x * (sizeX / 2), cellSize.y * (sizeX / 2)); currentDelayBeforeFigureLanding = 0; speedCoeff = 1.0f; figureFallDelayDecreaseCurrentTime = 0; nextFigureIndex = -1; for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { cells[x, y] = new Cell(); Vector3 cellCenterPosition = GetCellPosition(new Vector2(x, y)); if (x == sizeX - 1) { DrawBorder(Sides.Right, cellCenterPosition); } if (y == 0) { DrawBorder(Sides.Top, cellCenterPosition); } if (x == 0) { DrawBorder(Sides.Left, cellCenterPosition); } if (y == sizeY - 1) { DrawBorder(Sides.Bottom, cellCenterPosition); } } } OnGameStart(); }
public void LaunchSavedStartFigure(Vector3 startPosition, int figureIndex, int rotationCount, int nextFigureIndex) { currentFigureSpeed = slowFigureSpeed; int[,] figureMatrix = FigureTypes.GetFigureByIndex(figureIndex); currentFigure = CreateFigure(figureMatrix, figureIndex); currentFigure.transform.localPosition = startPosition; currentFigureCoord = GetCellСoordByPosition(startPosition); figScript = currentFigure.GetComponent <Figure>(); for (int i = 0; i < rotationCount; i++) { figScript.Rotate(); } currentCell = GetCellByPosition(startPosition); UpdateFallFigureTip(); OnFigureCreate(CreateFigure(FigureTypes.GetFigureByIndex(nextFigureIndex), nextFigureIndex, false)); }
private int depth = 5; // текущая толщина private void DefineFigure(object sender, EventArgs e) { // определение последней нажатой кнопки switch (((Button)sender).Name) { case "btnLine": figureType = FigureTypes.line; break; case "btnCircle": figureType = FigureTypes.circle; break; case "btnEllipse": figureType = FigureTypes.ellipse; break; case "btnSquare": figureType = FigureTypes.square; break; case "btnRectangle": figureType = FigureTypes.rectangle; break; case "btnPolyline": figureType = FigureTypes.polyline; break; case "btnPolygon": figureType = FigureTypes.polygon; break; } isCompleted = true; }
private void changeFigureType(FigureTypes type) { switch (type) { case FigureTypes.Rectangle: ShapeRectangle.Visibility = Visibility.Visible; ShapeRoundedRect.Visibility = Visibility.Collapsed; ShapeEllipse.Visibility = Visibility.Collapsed; break; case FigureTypes.RoundedRect: ShapeRectangle.Visibility = Visibility.Collapsed; ShapeRoundedRect.Visibility = Visibility.Visible; ShapeEllipse.Visibility = Visibility.Collapsed; break; case FigureTypes.Ellipse: ShapeRectangle.Visibility = Visibility.Collapsed; ShapeRoundedRect.Visibility = Visibility.Collapsed; ShapeEllipse.Visibility = Visibility.Visible; break; } }
private void Render() { for (int i = 1; i <= blocksCount; i++) { if (blocks[i] != null) { Destroy(blocks[i]); blocks[i] = null; } GameObject figureCube = Instantiate(cubePrefab, this.transform); blocks[i] = figureCube; Vector2 blockCoord = GetBlockCoord(i); Vector3 position = GetBlockPositionByCoord(blockCoord); figureCube.transform.localPosition = GetBlockPositionByCoord(blockCoord); figureCube.SetActive(true); Color color = FigureTypes.GetСolor(index); figureCube.GetComponent <SpriteRenderer>().color = color; figureCube.GetComponent <SpriteRenderer>().material.color = color; } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBox1.SelectedIndex) { case 0: figuretype = FigureTypes.Queen; break; case 1: figuretype = FigureTypes.Rook; break; case 2: figuretype = FigureTypes.Bishop; break; case 3: figuretype = FigureTypes.Knight; break; } }
public void LaunchStartFigure() { Vector3 startPosition = GetFigureStartPosition(); currentFigureSpeed = slowFigureSpeed; int figureIndex; if (nextFigureIndex == -1) { figureIndex = FigureTypes.GetRangdomIndex(); } else { figureIndex = nextFigureIndex; } nextFigureIndex = FigureTypes.GetRangdomIndex(); int[,] figureMatrix = FigureTypes.GetFigureByIndex(figureIndex); currentFigure = CreateFigure(figureMatrix, figureIndex); figScript = currentFigure.GetComponent <Figure>(); currentCell = GetCellByPosition(startPosition); if (CheckIfCellIsFreeForBlock(currentCell)) { currentFigure.transform.localPosition = startPosition; currentFigureCoord = new Vector2(1000, 1000); CheckIfFigureCanExistInCoord(figScript, GetCellСoordByPosition(startPosition)); currentFigureCoord = GetCellСoordByPosition(startPosition); UpdateFallFigureTip(); } currentDelayBeforeFigureLanding = 0; figureFallDelayDecreaseCurrentTime = 0; figureFastFalling = false; OnFigureCreate(CreateFigure(FigureTypes.GetFigureByIndex(nextFigureIndex), nextFigureIndex, false)); }
private void rbPawn_CheckedChanged(object sender, EventArgs e) { if (((RadioButton)sender).Checked == true) { switch (((RadioButton)sender).Text) { case "ROOK": FigureTypes = FigureTypes.Rook; break; case "BISHOP": FigureTypes = FigureTypes.Bishop; break; case "KNIGHT": FigureTypes = FigureTypes.Knight; break; default: FigureTypes = FigureTypes.Queen; break; } } }
/// <summary> /// Создать фигуру заданного типа /// </summary> /// <param name="figtype">Тип фигуры</param> /// <param name="pos">Позиция</param> /// <returns></returns> Figure CreateFigure(FigureTypes figtype, Position pos, Side side) { switch (figtype) { case FigureTypes.Bishop: { return(new Bishop(pos, side, this)); } case FigureTypes.King: { return(new King(pos, side, this)); } case FigureTypes.Knight: { return(new Knight(pos, side, this)); } case FigureTypes.Pawn: { return(new Pawn(pos, side, this)); } case FigureTypes.Queen: { return(new Queen(pos, side, this)); } case FigureTypes.Rook: { return(new Rook(pos, side, this)); } } return(null); }
public static IHtmlContent GetFigureCode(this IHtmlHelper htmlHelper, FigureTypes figure) { switch (figure) { case FigureTypes.QUEEN: return(new HtmlString("♛")); case FigureTypes.ROCK: return(new HtmlString("♜")); case FigureTypes.BISHOP: return(new HtmlString("♝")); case FigureTypes.KNIGHT: return(new HtmlString("♞")); case FigureTypes.PAWN: return(new HtmlString("♟")); case FigureTypes.KING: default: return(new HtmlString("♚")); } }
void OnFigureCreate(GameObject figure) { foreach (Transform child in nextFigureContainer.transform) { GameObject.Destroy(child.gameObject); } Vector2 cellSize = tetrisGrid.GetComponent <TetrisGrid>().cellSize; Figure figScript = figure.GetComponent <Figure>(); int matrixSize = figScript.blockMatrix.GetUpperBound(0) + 1; Vector3 positionDiff = (float)matrixSize / 2.0f * cellSize * 1 / 0.35f; figure.transform.SetParent(nextFigureContainer.transform); figure.transform.localPosition = -positionDiff - FigureTypes.GetPositionShiftByIndex(figScript.GetIndex()); Vector3 scale = figure.transform.localScale; scale *= 0.35f; figure.transform.localScale = scale; currFigure = figure; currFigurePos = -positionDiff; //figure.transform.position = nextFigureContainer.transform.position - new Vector3(0.4f * positionDiff.x, -0.27f * positionDiff.y); }
/// <summary> /// Создать фигуру заданного типа /// </summary> /// <param name="figtype">Тип фигуры</param> /// <param name="pos">Позиция</param> /// <returns></returns> Figure CreateFigure(FigureTypes figtype, Position pos, Side side) { switch (figtype) { case FigureTypes.Bishop: { return new Bishop(pos, side, this); } case FigureTypes.King: { return new King(pos, side, this); } case FigureTypes.Knight: { return new Knight(pos, side, this); } case FigureTypes.Pawn: { return new Pawn(pos, side, this); } case FigureTypes.Queen: { return new Queen(pos, side, this); } case FigureTypes.Rook: { return new Rook(pos, side, this); } } return null; }
/// <summary> /// Поменять пешку на фигуру заданного типа /// </summary> /// <param name="pos"></param> /// <param name="figuretype"></param> public Figure TransformPawn(Position pos, FigureTypes figuretype) { Figure fig; Side side; side = GetFigureAt(pos).Side; Figure oldfig = SideToPlayer(side).alivefigures[SideToPlayer(side).alivefigures.IndexOf(GetFigureAt(pos))]; fig = CreateFigure(figuretype, pos, side); SetFigureAt(pos, fig); SideToPlayer(side).alivefigures.Remove(oldfig); SideToPlayer(side).alivefigures.Add(fig); fig.MoveEvent += MoveFigureHandler; fig.KillEvent += SideToPlayer(side).KillFigureHandler; // надо восстановить старые обработчики для пешки FIX IT return fig; }
protected void SendSuperiority(NetworkStream ns, FigureTypes figtype,Position pos) { hassuperiority = false; WriteString(ns, comsuperiority); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(ns, figtype); formatter.Serialize(ns, pos); }
private void EncodeQuestion(int QuestionNumber, string Question, string[] objectives, string answer, string outputpath) { //QuestionNumber = Convert.ToInt32(ViewState["QuestionNumber"]); //Question = QuestionTextArea.Value; FigureTypes f = new FigureTypes(); List <string> validatedobjectives = new List <string>(); int valcount = 0; foreach (string obj in objectives) { if (obj != "") { validatedobjectives.Add(obj); valcount++; } else { } } if (!File.Exists(outputpath)) { using (System.IO.StreamWriter swriter = new System.IO.StreamWriter(outputpath)) { swriter.Write(QuestionNumber + ". "); swriter.WriteLine(Question + System.Environment.NewLine); for (int count = 0; count < valcount - 1; count++) { swriter.Write(f.Alphabet[count] + " " + validatedobjectives.ElementAt(count) + " "); } swriter.WriteLine(); swriter.WriteLine("Answer: " + answer); swriter.WriteLine(); swriter.WriteLine(); swriter.Flush(); swriter.Close(); } } else { using (StreamWriter sw = File.AppendText(outputpath)) { sw.Write(QuestionNumber + ". "); sw.WriteLine(Question + System.Environment.NewLine); for (int count = 0; count < valcount - 1; count++) { sw.Write(f.Alphabet[count] + " " + validatedobjectives.ElementAt(count) + " "); } sw.WriteLine(); sw.WriteLine("Answer: " + answer); sw.WriteLine(); sw.WriteLine(); sw.Flush(); sw.Close(); } } }
public bool Transform(sbyte x, sbyte y, FigureTypes type) { Figure p = this.GetFigureByXY(x, y); if (p.type != FigureTypes.Pawn) return false; Figure newFigure; switch (type) { case FigureTypes.Knight: newFigure = new Knight(this, p.field.x, p.field.y, p.color); break; case FigureTypes.Bishop: newFigure = new Bishop(this, p.field.x, p.field.y, p.color); break; case FigureTypes.Queen: newFigure = new Queen(this, p.field.x, p.field.y, p.color); break; case FigureTypes.Rook: newFigure = new Rook(this, p.field.x, p.field.y, p.color); break; default: return false; } if (p.color == Color.white) { this.whites.Remove(p); this.whites.Add(newFigure); } else { this.blacks.Remove(p); this.blacks.Add(newFigure); } this.UpdateAllBeatFields(); this.IsGameOvered(); return true; }
static void Main(string[] args) { Console.WriteLine("Choose a figure:"); foreach (FigureTypes type in Enum.GetValues(typeof(FigureTypes))) { Console.WriteLine($"{(int) type} - {type}"); } int chooseFigure = TryNum; while (chooseFigure > 0) { try { int userInput = int.Parse(Console.ReadLine()); FigureTypes typeSelected = (FigureTypes)userInput; if (!Enum.IsDefined(typeof(FigureTypes), userInput)) { throw new ArgumentException(); } int enterLeft = TryNum; while (enterLeft > 0) { try { switch (typeSelected) { case FigureTypes.Circle: Console.WriteLine("Enter diameter:"); double circleD = StringToDouble(Console.ReadLine()); Console.WriteLine($"Area of the circle is {0.25 * Math.PI * circleD}"); Console.WriteLine($"Circumference of the circle is {Math.PI * circleD}"); break; case FigureTypes.Triangle: Console.WriteLine("Enter side length:"); double triangleA = StringToDouble(Console.ReadLine()); Console.WriteLine("Enter the second side length:"); double triangleB = StringToDouble(Console.ReadLine()); Console.WriteLine("Enter the third side length:"); double triangleC = StringToDouble(Console.ReadLine()); double halfP = (triangleA + triangleB + triangleC) / 2.0; Console.WriteLine( $"Area of the triangle is {Math.Sqrt(halfP * (halfP - triangleA) * (halfP - triangleB) * (halfP - triangleC))}"); Console.WriteLine($"Perimeter is {halfP * 2}"); break; case FigureTypes.Rectangle: Console.WriteLine("Enter side length:"); double rectangleA = StringToDouble(Console.ReadLine()); Console.WriteLine("Enter the second side length:"); double rectangleB = StringToDouble(Console.ReadLine()); Console.WriteLine($"Area of the rectangle is {rectangleA * rectangleB}"); Console.WriteLine($"Perimeter is {2 * (rectangleA + rectangleB)}"); break; } enterLeft = 0; } catch (FormatException) { Console.WriteLine($"Invalid input, tries left: {enterLeft - 1}"); } catch (Exception e) // like "default" in switch construction { Console.WriteLine($"Unexpected error: {e.Message}"); } enterLeft--; } chooseFigure = 0; } catch (ArgumentNullException) { Console.WriteLine($"Nothing was chosen, tries left: {chooseFigure - 1}"); } catch (ArgumentException) { Console.WriteLine($"No type found, tries left: {chooseFigure - 1}"); } catch (FormatException) { Console.WriteLine($"Invalid input, tries left: {chooseFigure - 1}"); } catch (Exception e) // like "default" in switch construction { Console.WriteLine($"Unexpected error: {e.Message}"); } chooseFigure--; } }
public Figure(FigureTypes figureType) { this.FigureType = figureType; }
public Figures(FigureTypes t, bool iw) { Type = t; IsWhite = iw; moves = new List <Point>(); }
public bool Transform(FigureTypes figureTypes) { if ((field.y == 8 && color == Color.white) || (field.y == 1 && color == Color.black)) { Figure newFigure; switch (figureTypes) { case FigureTypes.Bishop: newFigure = new Bishop(GameObject, field.x, field.y, color); break; case FigureTypes.Knight: newFigure = new Knight(GameObject, field.x, field.y, color); break; case FigureTypes.Queen: newFigure = new Queen(GameObject, field.x, field.y, color); break; case FigureTypes.Rook: newFigure = new Rook(GameObject, field.x, field.y, color); break; default: return false; } GameObject.RemoveFigureByXY(field.x, field.y); if (color == Color.black) GameObject.blacks.Add(newFigure); else GameObject.whites.Add(newFigure); GameObject.UpdateAllBeatFields(); return true; } return false; }
public ChooseFigureForm() { InitializeComponent(); comboBox1.SelectedIndex = 0; figuretype = FigureTypes.Queen; }