Example #1
0
        public void initialize(GameObject cellPrefab, WorldData data)
        {
            _game  = gameObject.GetComponent <MainProxy>();
            _board = gameObject.AddComponent <BoardContainer>();
            _board.createBoard(cellPrefab, data.sizeX, data.sizeY);
            _data = data;

            _drag = new BoardMouseControl();
            _drag.initialize(_game.myId, Camera.main, _board, deployDebugConfig);
            _cellPrefab = cellPrefab;
        }
Example #2
0
 private Point BoardLeftEdgeLocation()
 {
     return(BoardContainer.TransformToAncestor(App.Current.MainWindow).Transform(new Point(0, 0)));
 }
 private void CreateNewBoard()
 {
     const float size = 3f;
     board = new Board[3, 3];
     for (int i = 0; i < board.GetLength(0); i++)
     {
         for (int j = 0; j < board.GetLength(1); j++)
         {
             if(depth == 1)
             {
                 board[i, j] = new Board(Mathf.RoundToInt(position.x + i * size),
                                         Mathf.RoundToInt(position.y + j * size));
             }
             else
             {
                 board[i, j] = new BoardContainer(Mathf.RoundToInt(position.x + i * size * 3),
                                                  Mathf.RoundToInt(position.y + j * size * 3),
                                                  depth - 1);
             }
         }
     }
     //finally, create the lines that are supposed to go with this
     GameObject linesToClone = null;
     Vector3 linesPosition = Vector3.zero; //Offset given to the position determined by which lines you are cloning
     switch(depth)
     {
         case 1:
             linesToClone = TTTPrefabContainer.mediumBoard;
             linesPosition = new Vector3(position.x + 4f, 0, position.y + 4f);
             break;
         case 2:
             linesToClone = TTTPrefabContainer.largeBoard;
             linesPosition = new Vector3(position.x + 13f, 0, position.y + 13f);
             break;
         default:
             Debug.LogErrorFormat("Depth set to an invalid number: {0}", depth);
             linesToClone = TTTPrefabContainer.largeBoard;
             break;
     }
     lines = GameObject.Instantiate(linesToClone, linesPosition, Quaternion.identity) as GameObject;
     lines.transform.parent = TTTPrefabContainer.tttParentObject.transform;
 }
 void Awake()
 {
     AssignPrefabs();
     parentBoard = new BoardContainer(0, 0, desiredDepth);
 }