Пример #1
0
 public Block CreateBlock(
     GameObject blockPrefab,
     Vector3 position,
     Quaternion rotation
     )
 {
     // round position and rotation
     position = Functions.RoundVector3ToDiscrete(position);
     rotation = Functions.RoundQuaternionToDiscrete(rotation);
     // create block from prefab and register on block manager
     if (!BlockExists(position))
     {
         GameObject newBlockGO = Instantiate(
             blockPrefab,
             position,
             rotation,
             blocksContainer.transform
             );
         BaseBlockScript newBlockScript = newBlockGO.GetComponent <BaseBlockScript>();
         Block           newBlock       = new Block(
             newBlockGO,
             newBlockScript
             );
         newBlockScript.SetSelfBlock(newBlock);
         SetBlock(newBlock);
         newBlockScript.OnPlacement();
         return(newBlock);
     }
     return(null);
 }
Пример #2
0
 public Block(GameObject gameObject, BaseBlockScript script)
 {
     this.gameObject = gameObject;
     this.script     = script;
 }
Пример #3
0
 public void AddChildBlock(BaseBlockScript child)
 {
     Debug.Log (child.gameObject.name);
     childBlockList.Add (child);
 }