SHARE
TWEET
Untitled
a guest
Jan 29th, 2018
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CheckerBoard : MonoBehaviour
- {
- /*2D array for our pieces and Their Game Objects.*/
- public CheckerPiece[,] pieces = new CheckerPiece[8, 8];
- public GameObject knightsOfBloodPiecePrefab;
- public GameObject sleepingKnightsPiecePrefab;
- public Vector3 boardOffset = new Vector3(-4.0f, 0, -4.0f);
- private void Start()
- {
- InstantiateBoard();
- }
- private void InstantiateBoard()
- {
- //Generates KoB Team
- for (int y = 0; y < 3; y++)
- {
- for (int x = 0; x < 8; x += 2)
- {
- //Generating KoB Pieces
- GeneratePiece(x, y);
- }
- }
- //Generates SK Team
- }
- private void GeneratePiece(int x, int y)
- {
- GameObject go = Instantiate(knightsOfBloodPiecePrefab) as GameObject;
- go.transform.SetParent(transform);
- CheckerPiece p = go.GetComponent<CheckerPiece>();
- pieces[x, y] = p;
- MovePiece(p, x, y);
- }
- private void MovePiece(CheckerPiece p, int x, int y)
- {
- p.transform.position = (Vector3.right * x) + (Vector3.forward * y) + boardOffset;
- }
- }
RAW Paste Data

