public GridMap(int width, int height) { this.width = width; this.height = height; gridMap = new GridTile[width * height]; tracker = new PieceTracker(); }
// visual representation of the game piece to the player public void dressMe() { destroyCall(1); if (pd == null) { return; // no piece definition... quit } if (pd is TreasurePiece) { Debug.Log("sinh con sau"); int a = Random.Range(0, 100); Debug.Log("b=" + a); if (a % 2 == 0) { if (wc.countSpwanTreasure1 > 0) { thisPiece = (GameObject)Object.Instantiate(pd.getSkin(0)); wc.countSpwanTreasure1--; Debug.Log("sinh sau1"); } else { thisPiece = (GameObject)Object.Instantiate(pd.getSkin(1)); wc.countSpwanTreasure2--; Debug.Log("sinh sau2"); } } else { if (wc.countSpwanTreasure2 > 0) { thisPiece = (GameObject)Object.Instantiate(pd.getSkin(1)); wc.countSpwanTreasure2--; Debug.Log("sinh sau2"); } else { thisPiece = (GameObject)Object.Instantiate(pd.getSkin(0)); wc.countSpwanTreasure1--; Debug.Log("sinh sau2"); } } } else { thisPiece = (GameObject)Object.Instantiate(pd.getSkin(slotNum)); } if (pd is HorizontalPiece || pd is VerticalPiece || pd is SpecialFive || pd is BombPiece) { gm.animScript.doAnim(animType.CONVERTSPEC, master.arrayRef); } pd.onPieceCreated(this); // piece is created, call the onCreate (if any) thisPiece.transform.parent = master.gm.gameObject.transform; // re-parent the object to the gameManager panel thisPiece.transform.position = position; if (thisPiece.GetComponent <CircleCollider2D>() == null) { thisPiece.AddComponent <CircleCollider2D>(); // add a box collider if not present } JMFUtils.autoScalePadded(thisPiece); // auto scaling feature pd.extraPiecePositioning(thisPiece); // prefab properties to sync-up ( don't forget the PieceTracker script ) PieceTracker pt = thisPiece.GetComponent <PieceTracker>(); if (pt == null) { // if the prefab doesnt have the script, add it dynamically... pt = thisPiece.AddComponent <PieceTracker>(); } thisPiece.AddComponent <GP_PieceScripts>(); pt.arrayRef = master.arrayRef; }