-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameController.cs
47 lines (30 loc) · 1.04 KB
/
GameController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour
{
//Dimensions of game board
public int columns = 7;
public int rows = 6;
//Number of pieces in a row needed to win
public int winSize = 4;
public bool againstAI = true;
//Win state
public int winner = 0;
public CameraController cameraControls;
public bool playerTurn = true;
public Transform newPiece;
private PlayerController player;
// Use this for initialization
void Start ()
{
player = gameObject.GetComponent<PlayerController>();
//Draw board
DrawBoardScript drawBoard = gameObject.GetComponent<DrawBoardScript>();
drawBoard.DrawBoard(columns, rows);
//Set camera position to center of board
float halfCellSize = drawBoard.cellSize / 2;
float cameraX = (columns * halfCellSize) - halfCellSize;
float cameraY = (rows * halfCellSize) - halfCellSize;
cameraControls.PositionCamera(cameraX, cameraY);
}
}