daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CheckerBoard : MonoBehaviour
  6. {
  7.     /*2D array for our pieces and Their Game Objects.*/
  8.     public CheckerPiece[,] pieces = new CheckerPiece[8, 8];
  9.     public GameObject knightsOfBloodPiecePrefab;
  10.     public GameObject sleepingKnightsPiecePrefab;
  11.  
  12.     public Vector3 boardOffset = new Vector3(-4.0f, 0, -4.0f);
  13.  
  14.     private void Start()
  15.     {
  16.         InstantiateBoard();
  17.     }
  18.  
  19.     private void InstantiateBoard()
  20.     {
  21.         //Generates KoB Team
  22.         for (int y = 0; y < 3; y++)
  23.         {
  24.             for (int x = 0; x < 8; x += 2)
  25.             {
  26.                 //Generating KoB Pieces
  27.                 GeneratePiece(x, y);
  28.             }
  29.         }
  30.         //Generates SK Team
  31.     }
  32.  
  33.     private void GeneratePiece(int x, int y)
  34.     {
  35.         GameObject go = Instantiate(knightsOfBloodPiecePrefab) as GameObject;
  36.         go.transform.SetParent(transform);
  37.         CheckerPiece p = go.GetComponent<CheckerPiece>();
  38.         pieces[x, y] = p;
  39.         MovePiece(p, x, y);
  40.     }
  41.  
  42.     private void MovePiece(CheckerPiece p, int x, int y)
  43.     {
  44.         p.transform.position = (Vector3.right * x) + (Vector3.forward * y) + boardOffset;
  45.     }
  46. }
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top