private void Init() { AISprite = White; PlaySprite = Black; laziStack = new Stack <Vector2Int>(); around = Around.我方; allPiece[0, 0] = piecePrefab.GetComponent <piece>(); Vector2 zero = piecePrefab.GetComponent <RectTransform>().anchoredPosition; for (int i = 0; i < 15; ++i) { for (int j = 0; j < 15; ++j) { if (null == allPiece[i, j]) { GameObject newpiece = Instantiate(piecePrefab, transform); allPiece[i, j] = newpiece.GetComponent <piece>(); newpiece.GetComponent <RectTransform>().anchoredPosition = new Vector2(zero.x + xoffset * i, zero.y - yoffset * j); allPiece[i, j].Record(i, j); } allPiece[i, j].UnShow(); lazis[i, j] = 0; } } }
/// <summary> /// draw each element in canvas and shows the clock /// </summary> public void Draw() { ParentCanvas.Children.Add(SecondHand.GetUI()); ParentCanvas.Children.Add(MinutesHand.GetUI()); ParentCanvas.Children.Add(HoursHand.GetUI()); Around.Draw(); }
public void TurnAround(Vector2Int lazi) { laziStack.Push(lazi); var e = new Evaluation(); e.Evaluate(lazis); if (e.lose) { if (Black == AISprite) { Debug.Log("游戏结束,你输了"); } else { Debug.Log("游戏结束,你赢了"); } around = Around.敌方; return; } if (e.win) { if (White == AISprite) { Debug.Log("游戏结束,你输了"); } else { Debug.Log("游戏结束,你赢了"); } around = Around.敌方; return; } if (Around.我方 == around) { around = Around.敌方; AI(); } if (Around.敌方 == around) { around = Around.我方; } }
public override void Draw() { this.X += this.XSpeed; this.Y += this.YSpeed; if (this.Y < this.Highest_Y) { DDUtils.Approach(ref this.YSpeed, 重力加速度, 0.9); } this.YSpeed = Math.Min(落下最高速度, this.YSpeed); int ix = SCommon.ToInt(this.X); int iy = SCommon.ToInt(this.Y); Around a2 = new Around(ix, iy, 2); int xDirSign = 0; int yDirSign = 0; if (this.Y < this.Highest_Y + 24.0) // ? 最高高度に近い { if ( a2.Table[0, 0].IsEnemyPataWall() || a2.Table[0, 1].IsEnemyPataWall() ) { xDirSign++; } if ( a2.Table[1, 0].IsEnemyPataWall() || a2.Table[1, 1].IsEnemyPataWall() ) { xDirSign--; } } else { if ( a2.Table[0, 0].IsEnemyPataWall() && a2.Table[0, 1].IsEnemyPataWall() ) { xDirSign++; } if ( a2.Table[1, 0].IsEnemyPataWall() && a2.Table[1, 1].IsEnemyPataWall() ) { xDirSign--; } } if ( !a2.Table[0, 0].IsEnemyPataWall() && a2.Table[0, 1].IsEnemyPataWall() || !a2.Table[1, 0].IsEnemyPataWall() && a2.Table[1, 1].IsEnemyPataWall() ) { yDirSign = -1; } else if ( a2.Table[0, 0].IsEnemyPataWall() && a2.Table[1, 0].IsEnemyPataWall() ) { yDirSign = 1; } else { this.YSpeed += 重力加速度; } if (xDirSign != 0) { this.XSpeed = Math.Abs(this.XSpeed) * xDirSign; } if (yDirSign != 0) { this.YSpeed = Math.Abs(this.YSpeed) * yDirSign; } if (!EnemyCommon.IsOutOfScreen_ForDraw(this)) { //DDDraw.SetBright(new I3Color(192, 32, 32)); // old DDDraw.SetBright(Game.I.Map.Design.EnemyColor_Pata); DDDraw.DrawBegin(Ground.I.Picture.WhiteBox, SCommon.ToInt(this.X - DDGround.ICamera.X), SCommon.ToInt(this.Y - DDGround.ICamera.Y)); DDDraw.DrawSetSize(GameConsts.TILE_W, GameConsts.TILE_H); DDDraw.DrawEnd(); DDDraw.Reset(); this.Crash = DDCrashUtils.Rect_CenterSize(new D2Point(this.X, this.Y), new D2Size(GameConsts.TILE_W, GameConsts.TILE_H)); Game.I.タイル接近_敵描画_Points.Add(new D2Point(this.X, this.Y)); } }