Beispiel #1
0
 public PlayerSteps(List <BoardTile> initTileList)
 {
     foreach (var tiles in initTileList)
     {
         BoardTile initTile = new BoardTile(tiles);
         tileList.Add(initTile);
     }
 }
Beispiel #2
0
        private void setLastState()
        {
            SecondLastState.Clear();
            if (LastState.Count != 0)
            {
                foreach (var tiles in LastState)
                {
                    BoardTile initTile = new BoardTile(tiles);
                    SecondLastState.Add(initTile);
                }
            }
            LastState.Clear();

            foreach (var tiles in gameMesh)
            {
                BoardTile initTile = new BoardTile(tiles);
                LastState.Add(initTile);
            }
        }
Beispiel #3
0
        public bool getLastState(bool isAI)
        {
            if (LastState.Count != 0)
            {
                gameMesh.Clear();
                if (isAI)
                {
                    LastState.Clear();
                    foreach (var tiles in SecondLastState)
                    {
                        BoardTile initTile = new BoardTile(tiles);
                        gameMesh.Add(initTile);
                    }
                    SecondLastState.Clear();
                }
                else
                {
                    foreach (var tiles in LastState)
                    {
                        BoardTile initTile = new BoardTile(tiles);
                        gameMesh.Add(initTile);
                    }

                    LastState.Clear();

                    if (SecondLastState.Count != 0)
                    {
                        foreach (var tiles in SecondLastState)
                        {
                            BoardTile initTile = new BoardTile(tiles);
                            LastState.Add(initTile);
                        }
                    }
                    SecondLastState.Clear();
                }
                return(true);
            }

            return(false);
        }
Beispiel #4
0
        public void gameStep(int new_id, int player)
        {
            setLastState();

            gameMesh[new_id].field_owner = player;

            PlayerSteps newStep = new PlayerSteps(gameMesh);

            foreach (PlayerSteps.Directions dir in (PlayerSteps.Directions[])Enum.GetValues(typeof(PlayerSteps.Directions)))
            {
                newStep.nextStep(new_id, dir);
            }

            gameMesh.Clear();
            foreach (var tiles in newStep.getBoard())
            {
                BoardTile initTile = new BoardTile(tiles);
                gameMesh.Add(initTile);
            }

            calcualteNextStep();
        }
Beispiel #5
0
        public void calcualteNextStep()
        {
            int tileid = 0;

            foreach (BoardTile tiles in gameMesh)
            {
                if (tiles.field_owner == 3 || tiles.field_owner == 4 || tiles.field_owner == 5)
                {
                    tiles.field_owner = 0;
                }

                tileid++;
            }

            PlayerSteps newStep = new PlayerSteps(gameMesh);

            tileid = 0;

            foreach (BoardTile tiles in gameMesh)
            {
                if (tiles.field_owner == 1 || tiles.field_owner == 2)
                {
                    foreach (PlayerSteps.Directions dir in (PlayerSteps.Directions[])Enum.GetValues(typeof(PlayerSteps.Directions)))
                    {
                        newStep.suggestedStep(tileid, dir);
                    }
                }
                tileid++;
            }

            gameMesh.Clear();
            foreach (var tiles in newStep.getBoard())
            {
                BoardTile initTile = new BoardTile(tiles);
                gameMesh.Add(initTile);
            }
        }
Beispiel #6
0
 public BoardTile(BoardTile copyTo)
 {
     this.pos_x       = copyTo.pos_x;
     this.pos_y       = copyTo.pos_y;
     this.field_owner = copyTo.field_owner;
 }