예제 #1
0
    void OnEnable()
    {
        BoxCollider bc = gameObject.AddComponent <BoxCollider>();

        JMFUtils.autoScale(gameObject);
        bc.center = new Vector3(0, 0, 10); // send the collider to the back, so it wont interfere with PieceTracker
    }
예제 #2
0
    // to create the foreground visual...
    void createFrontPanel()
    {
        if (!pnd.isInFront || pnd.hasNoSkin)
        {
            return; // not a front panel... no need to proceed
        }
        if (pnd.skin.Length > 0)
        { // if the prefab exists
            frontPanel = (GameObject)Object.Instantiate(pnd.skin[Mathf.Min(
                                                                     pnd.skin.Length - 1, Mathf.Abs(durability))]);
        }
        else
        {
            Debug.Log("No panel skin available. Have you forgotten to skin the panel script?");
        }

        if (frontPanel != null)
        {
            // re-parent the object to the gameManager panel
            frontPanel.transform.parent        = master.gm.gameObject.transform;
            frontPanel.transform.localPosition = master.localPos;
            JMFUtils.autoScale(frontPanel);
            // minor code just to arrange the Z order to always be at the front
            frontPanel.transform.localPosition += new Vector3(0, 0, -2 * master.gm.size * frontPanel.transform.localScale.z);
        }
    }
예제 #3
0
    //void CreateBackgroundPanel()
    //{
    //    Debug.Log("abcd");
    //    GameObject prefab = null;
    //    if (pnd.hasDefaultPanel2)
    //    {
    //        if (JMFUtils.vm.defaultSquareBackPanel != null)
    //        {
    //            prefab = JMFUtils.vm.defaultSquareBackPanel2;
    //        }
    //    }
    //    if (pnd.hasDefaultPanel)
    //    {
    //        if (JMFUtils.vm.defaultSquareBackPanel != null)
    //        {
    //            prefab = JMFUtils.vm.defaultSquareBackPanel;
    //        }
    //    }
    //    defaultPanel = (GameObject)Object.Instantiate(prefab);
    //    // re-parent the object to the gameManager panel
    //    defaultPanel.transform.parent = master.gm.gameObject.transform;
    //    defaultPanel.transform.localPosition = master.localPos;
    //    JMFUtils.autoScale(defaultPanel);
    //    // minor code just to arrange the Z order to always be at the back
    //    defaultPanel.transform.localPosition +=
    //        new Vector3(0, 0, 4 * master.gm.size * defaultPanel.transform.localScale.z);
    //}

    // to create the background visual...
    void createBackPanel()
    {
        if (pnd.hasDefaultPanel2)
        {
            createDefaultPanel(1);
        }
        if (pnd.hasDefaultPanel)
        {
            createDefaultPanel(0); // creates the default panel when specified
        }

        if (pnd.isInFront || pnd.hasNoSkin)
        {
            return; // already created a front panel, do not make this back panel
        }

        if (pnd.skin.Length > 0)
        { // if the prefab exists
            backPanel = (GameObject)Object.Instantiate(pnd.skin[Mathf.Min(pnd.skin.Length - 1, Mathf.Abs(durability))]);
        }
        else
        {
            Debug.Log("No panel skin available. Have you forgotten to skin the panel script?");
        }

        if (backPanel != null)
        {
            // re-parent the object to the gameManager panel
            backPanel.transform.parent        = master.gm.gameObject.transform;
            backPanel.transform.localPosition = master.localPos;
            JMFUtils.autoScale(backPanel);
            // positioning code
            backPanel.transform.localPosition += new Vector3(0, 0, 2 * master.gm.size * backPanel.transform.localScale.z);
        }
    }
예제 #4
0
    // function to create the default panel - in case of tranparency backPanels
    protected void createDefaultPanel(int i)
    {
        GameObject prefab = null;

        if (JMFUtils.vm.defaultSquareBackPanel != null)
        { // if the prefab exists
            switch (i)
            {
            case 0:
                prefab = JMFUtils.vm.defaultSquareBackPanel;
                break;

            case 1:
                prefab = JMFUtils.vm.defaultSquareBackPanel2;
                break;

            default:
                break;
            }
        }
        else
        {
            Debug.Log("whoops? have you forgotten to provide a default panel prefab?");
            return; // do not continue...
        }
        defaultPanel = (GameObject)Object.Instantiate(prefab);
        // re-parent the object to the gameManager panel
        defaultPanel.transform.parent        = master.gm.gameObject.transform;
        defaultPanel.transform.localPosition = master.localPos;

        JMFUtils.autoScale(defaultPanel);

        // minor code just to arrange the Z order to always be at the back
        //defaultPanel.transform.localPosition +=
        //    new Vector3(0, 0, 4 * master.gm.size * defaultPanel.transform.localScale.z);
        defaultPanel.transform.localPosition +=
            new Vector3(0, 0, 1);
    }