/// <summary> /// Default constructor /// </summary> public Cell() { Bound = new GRectangle(); IsHighlighted = false; OccupiedBy = new List <Pawn>(); IsShield = false; IsBanj = false; }
/// <summary> /// Default constructor /// </summary> public GameBoard() { Cells = new Dictionary <int, Cell>(); centerBox = new GRectangle(); topLeftBox = new GRectangle(); topRightBox = new GRectangle(); bottomLeftBox = new GRectangle(); bottomRightBox = new GRectangle(); Bound = new GRectangle(); }
public void SetRect(GRectangle rect) { if (!RectScreen.Equals(rect)) { RectScreen.Rectangle = rect.Rectangle; Rect.X = 0; Rect.Y = 0; Rect.Width = rect.Width; // new GRectangle(0, 0, rect.Width, rect.Height); Rect.Height = rect.Height; // new GRectangle(0, 0, rect.Width, rect.Height); if (OnChangeRect.NotIsNull()) { OnChangeRect(rect); } Clear(); } }
/// <summary> /// Update the achieved pawns rectangles /// </summary> private void UpdateAchievedPawnRects() { AchievedPawnRects = new GRectangle [2, 4]; int space = (int)CenterBox.R.Width / 5; // Player 0, Pawn 0 AchievedPawnRects[0, 0] = new GRectangle(new Rectangle( CenterBox.R.Left + space, CenterBox.R.Bottom - 2 * Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); for (int i = 1; i <= 3; i++) { // Player 0, Pawn i AchievedPawnRects[0, i] = new GRectangle(new Rectangle( AchievedPawnRects[0, i - 1].R.Right + space, AchievedPawnRects[0, i - 1].R.Bottom - 2 * Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); } // Player 1, Pawn 0 AchievedPawnRects[1, 0] = new GRectangle(new Rectangle( CenterBox.R.Left + space, CenterBox.R.Top + 2 * Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); for (int i = 1; i <= 3; i++) { // Player 1, Pawn i AchievedPawnRects[1, i] = new GRectangle(new Rectangle( AchievedPawnRects[1, i - 1].R.Right + space, AchievedPawnRects[1, i - 1].R.Top + 2 * Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); } }
public GRectangle ExtractLeft(int width) { if (width == 0) { return(RectScreen); } GRectangle res = new GRectangle(); res.X = RectScreen.X; res.Y = RectScreen.Y; res.Width = width; res.Height = RectScreen.Height; SetRect(new GRectangle() { X = RectScreen.X + width, Y = RectScreen.Y, Width = RectScreen.Width, Height = RectScreen.Height }); Clear(); return(res); }
/// <summary> /// Выделить панель снизу от текущей /// </summary> /// <param name="height"></param> /// <returns></returns> public GRectangle ExtractBottom(int height) { if (height == 0) { return(RectScreen); } GRectangle res = new GRectangle(); res.X = RectScreen.X; res.Y = RectScreen.Y + RectScreen.Height - height; res.Width = RectScreen.Width; res.Height = height; SetRect(new GRectangle() { X = RectScreen.X, Y = RectScreen.Y, Width = RectScreen.Width, Height = RectScreen.Height - height }); Clear(); return(res); }
/// <summary> /// Update the pawn state /// </summary> public override void Update() { base.Update(); //if (IsAchieved) //{ // if (Owner != null) // { // int playerIndex = (Owner.ID == GameApp.Instance.Players[0].ID) ? 0 : 1; // for (int i = Owner.Pawns.Count(x=> x.IsAchieved) - 1; i < Owner.Pawns.Length; i++) // { // if (ID == Owner.Pawns[i].ID) // { // Bound = GameApp.Instance.Board.AchievedPawnRects[playerIndex, i]; // break; // } // } // } //} //else if (!IsLive) { if (Owner != null) { int playerIndex = (Owner.ID == GameApp.Instance.Players[0].ID) ? 0 : 1; for (int i = 0; i < Owner.Pawns.Length; i++) { if (ID == Owner.Pawns[i].ID) { Bound = GameApp.Instance.Board.DefaultPawnRects[playerIndex, i]; break; } } } } }
/// <summary> Расчет панелей</summary> private void GetRectsPanels() { Candels.Panel.SetRect(MainPanel.ExtractBottom(0)); Cross.Panel.SetRect(Candels.Panel.ExtractBottom(0)); Times.Panel.SetRect(Candels.Panel.ExtractBottom(20)); Times.Panel.SetRect(GRectangle.Join(Candels.Panel.RectScreen, Times.Panel.RectScreen)); //Interest.Panel.SetRect(Candels.Panel.ExtractBottom(50)); //DeltaVol.Panel.SetRect(Candels.Panel.ExtractBottom(50)); Volumes.Panel.SetRect(Candels.Panel.ExtractBottom(60)); /////////////////////////// /// Right panels /////////////////////////// RightPrices.Panel.SetRect(Candels.Panel.ExtractRight(RightPrices.WidthBorder)); RightPrices.Panel.SetRect(GRectangle.Join(Candels.Panel.RectScreen, RightPrices.Panel.RectScreen)); GHorVolumes.Panel.SetRect(Candels.Panel.RectScreen); GHorVolumes.PanelVolume.SetRect(Candels.Panel.ExtractRight(150)); Candels.Panel.ExtractRight(15); //Ширина свечки float WidthOneCandle = Candels.GetWidthOne(); Cross.HeightForPrice = Candels.Panel.RectScreen.Height; Times.WidthOneCandle = WidthOneCandle; //Ширина области значений в нижних панелях Volumes.Values.SetWidthValues(RightPrices.WidthBorder); //DeltaVol.Values.SetWidthValues(RightPrices.WidthBorder); //Interest.Values.SetWidthValues(RightPrices.WidthBorder); LevelsOrders.Panel.SetRect(Candels.Panel.RectScreen); Levels.Panel.SetRect(Candels.Panel.RectScreen); }
public void PaintByCandle(CandleInfo candle, CandleInfo leftCandle, CandleInfo rightCandle, int count) { if (!Visible) { return; } if (this.Collection.IsNull()) { return; } if (candle.IsNull()) { return; } var canvas = Panel.GetGraphics; //Поиск всех уровней попадающий в окно видимости if (candle.Index == 0) { SearchRectLevel(leftCandle, rightCandle); } if (candle.PrevCandleInfo.NotIsNull()) { //Ищем правые грани уровня listTmpLevRect.Where(l => l.level.DateRight.DateTime >= candle.Candle.Time && l.level.DateRight.DateTime < candle.PrevCandleInfo.Candle.Time ).ForEach <LevelRect>((lev) => { lev.candleRight = candle; }); // Ищем левые грани уровня listTmpLevRect.Where(l => l.level.DateLeft.DateTime >= candle.Candle.Time && l.level.DateLeft.DateTime < candle.PrevCandleInfo.Candle.Time ).ForEach <LevelRect>((lev) => { lev.candleLeft = candle; }); } //Обработка на последней свече if (count == candle.Index + 1) { //Рисуем прямоугольные уровни foreach (var levRect in listTmpLevRect.ToArray()) { bool paint = false; Rectangle rect = new Rectangle(); //Прямоугольный уровень if (levRect.candleLeft.NotIsNull() && levRect.candleRight.NotIsNull()) { var width = Panel.Rect.Width - levRect.candleLeft.TailCoord.High.X; rect = (GRectangle.GetRight(Panel.Rect.Clone(), width)).Rectangle; levRect.candleRight.TailCoord.High.X = levRect.candleRight.TailCoord.High.X < 0 ? 0 : levRect.candleRight.TailCoord.High.X; levRect.candleLeft.TailCoord.High.X = levRect.candleLeft.TailCoord.High.X < 0 ? 0 : levRect.candleLeft.TailCoord.High.X; rect.Width = levRect.candleRight.TailCoord.High.X - levRect.candleLeft.TailCoord.High.X; paint = true; } //Линейный уровень else if (levRect.candleLeft.NotIsNull()) { var time = levRect.level.DateLeft.GetDateTime(); if (time <= rightCandle.Candle.Time) { var width = Panel.Rect.Width - levRect.candleLeft.TailCoord.High.X; rect = (GRectangle.GetRight(Panel.Rect.Clone(), width)).Rectangle; levRect.candleLeft.TailCoord.High.X = levRect.candleLeft.TailCoord.High.X < 0 ? 0 : levRect.candleLeft.TailCoord.High.X; paint = true; } } if (paint) { rect.X = rect.X < 0 ? 0 : rect.X; if (levRect.level.Bottom <= 0 && levRect.level.Top > 0) { PaintLineLevel(canvas, rect, levRect.level, 2f); } else { PaintRectangleLevel(canvas, rect, levRect.level, 1); } } listTmpLevRect.Clear(); } } }
/// <summary> /// Recalculate the default pawn rectangles /// </summary> private void UpdateDefaultPawnRects() { DefaultPawnRects = new GRectangle[2, 4]; // Player 0, Pawn 0 DefaultPawnRects[0, 0] = new GRectangle(new Rectangle( TopRightBox.Center.X - Pawn.SIZE, TopRightBox.Center.Y - Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); // Player 0, Pawn 1 DefaultPawnRects[0, 1] = new GRectangle(new Rectangle( TopRightBox.Center.X + Pawn.SIZE, TopRightBox.Center.Y - Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); // Player 0, Pawn 2 DefaultPawnRects[0, 2] = new GRectangle(new Rectangle( TopRightBox.Center.X - Pawn.SIZE, TopRightBox.Center.Y + Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); // Player 0, Pawn 3 DefaultPawnRects[0, 3] = new GRectangle(new Rectangle( TopRightBox.Center.X + Pawn.SIZE, TopRightBox.Center.Y + Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); // Player 1, Pawn 0 DefaultPawnRects[1, 0] = new GRectangle(new Rectangle( BottomLeftBox.Center.X - Pawn.SIZE, BottomLeftBox.Center.Y - Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); // Player 1, Pawn 1 DefaultPawnRects[1, 1] = new GRectangle(new Rectangle( BottomLeftBox.Center.X + Pawn.SIZE, BottomLeftBox.Center.Y - Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); // Player 1, Pawn 2 DefaultPawnRects[1, 2] = new GRectangle(new Rectangle( BottomLeftBox.Center.X - Pawn.SIZE, BottomLeftBox.Center.Y + Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); // Player 1, Pawn 3 DefaultPawnRects[1, 3] = new GRectangle(new Rectangle( BottomLeftBox.Center.X + Pawn.SIZE, BottomLeftBox.Center.Y + Pawn.SIZE, Pawn.SIZE, Pawn.SIZE )); if (GameApp.Instance.Players != null) { foreach (var player in GameApp.Instance.Players) { foreach (var pawn in player.Pawns) { pawn.Update(); } } } }
/// <summary> /// Change the game board rectangle /// </summary> /// <param name="rect"></param> public void SetRect(Rectangle rect) { rect.Inflate(-10, -10); Bound = new GRectangle(rect); UpdateRects(); }
/// <summary> /// Constructor with bound /// </summary> /// <param name="rect">The bound of board</param> public GameBoard(GRectangle rect) { Bound = rect; }