Example #1
0
        /* Setter & Getter */

        /* Functions */

        private void Awake()
        {
            if (mJCS_2DCamera == null)
            {
                mJCS_2DCamera = this.GetComponent <JCS_2DCamera>();
            }
        }
        //========================================
        //      Unity's function
        //------------------------------
        protected void Awake()
        {
            mTargetList = new JCS_Vector <JCS_Player>();

            mAudioListener = this.GetComponent <AudioListener>();

            // find the camera in the scene first
            mJCS_2DCamera = (JCS_2DCamera)FindObjectOfType(typeof(JCS_2DCamera));

            // if still null spawn a default one!
            if (mJCS_2DCamera == null)
            {
                JCS_Debug.LogError("There is not JCS_2DCamera attach to, spawn a default one!");

                // Spawn a Default one!
                this.mJCS_2DCamera = JCS_Utility.SpawnGameObject(
                    JCS_2DCamera.JCS_2DCAMERA_PATH,
                    transform.position,
                    transform.rotation).GetComponent <JCS_2DCamera>();
            }

            mJCS_2DCamera.SetFollowTarget(this.transform);

            // record down the fild of view
            mTargetFieldOfView = mJCS_2DCamera.fieldOfView;
        }
        //========================================
        //      Unity's function
        //------------------------------
        private void Awake()
        {
            mSoundPlayer = this.GetComponent <JCS_SoundPlayer>();

            if (mJCS_2DCamera == null)
            {
                mJCS_2DCamera = this.GetComponent <JCS_2DCamera>();
            }
        }
Example #4
0
        //----------------------
        // Protected Functions

        //----------------------
        // Private Functions

        //////////// 2D //////////////////////////

        /// <summary>
        /// Iniialize the camera.
        /// </summary>
        private void InitCamera()
        {
            if (mJCS_2DCamera == null)
            {
                JCS_Debug.LogError("There is not JCS_2DCamera attach to, spawn a default one!");

                // Spawn a Default one!
                this.mJCS_2DCamera = JCS_Utility.SpawnGameObject(
                    JCS_2DCamera.JCS_2DCAMERA_PATH,
                    transform.position,
                    transform.rotation).GetComponent <JCS_2DCamera>();
            }

            // if still null, setting error!!
            if (mJCS_2DCamera == null)
            {
                JCS_Debug.LogError("The object spawn does not have the \"JCS_2DCamera\" components...");
                return;
            }

            // set target to follow!
            mJCS_2DCamera.SetFollowTarget(this.transform);
        }
Example #5
0
        /// <summary>
        /// Create 9x9 slide panel.
        ///
        /// Need:
        ///     1) JCS_Camera
        ///     2) JCS_Canvas
        /// in the scene before create 9 x 9 slide panel.
        /// </summary>
        private static void CreateSlidePanel()
        {
            JCS_Canvas jcsCanvas = (JCS_Canvas)FindObjectOfType(typeof(JCS_Canvas));

            if (jcsCanvas == null)
            {
                JCS_Debug.Log("Can't find JCS_Canvas in hierarchy. Plz create canvas before creating new panel.");
                return;
            }

            // find the camera in the scene.
            JCS_2DCamera cam = (JCS_2DCamera)FindObjectOfType(typeof(JCS_Camera));

            if (cam == null)
            {
                JCS_Debug.Log("Can't find JCS_Canvas in hierarchy. Plz create canvas before creating new panel.");
                return;
            }

            const string settingPath = "JCSUnity_Resources/LevelDesignUI/JCS_SlideScreenPanelHolder";

            // spawn the pane holder.
            JCS_SlideScreenPanelHolder panelHolder9x9 = CreateHierarchyObjectUnderCanvas(settingPath, jcsCanvas).GetComponent <JCS_SlideScreenPanelHolder>();

            // create the array of panel.
            panelHolder9x9.slidePanels = new RectTransform[9];

            int starting_pos_x = -1920;
            int starting_pos_y = 1080;

            const string slidePanelPath = "JCSUnity_Resources/LevelDesignUI/JCS_SlidePanel";

            int index = 0;

            // create all nine panel and assign to the slide panel.
            for (int row = 0; row < 3; ++row)
            {
                for (int column = 0; column < 3; ++column)
                {
                    // get the rect transform from the slide panel object.
                    RectTransform slidePanel = CreateHierarchyObjectUnderCanvas(slidePanelPath, jcsCanvas).GetComponent <RectTransform>();

                    // set the position into 9x9.
                    Vector3 slidePanelNewPos = slidePanel.localPosition;
                    slidePanelNewPos.x       = starting_pos_x - (starting_pos_x * column);
                    slidePanelNewPos.y       = starting_pos_y - (starting_pos_y * row);
                    slidePanel.localPosition = slidePanelNewPos;

                    // set scale to one.
                    slidePanel.localScale = Vector3.one;

                    Image panelImage = slidePanel.GetComponent <Image>();
                    if (panelImage != null)
                    {
                        panelImage.color = JCS_Random.RandomColor();
                    }

                    // assign to slide panel holder.
                    panelHolder9x9.slidePanels[index] = slidePanel;

                    ++index;
                }
            }

            const string            slideScreenCameraPath = "JCSUnity_Resources/Camera/JCS_2DSlideScreenCamera";
            JCS_2DSlideScreenCamera slideScreenCamera     = CreateHierarchyObject(slideScreenCameraPath).GetComponent <JCS_2DSlideScreenCamera>();

            Undo.RegisterCreatedObjectUndo(slideScreenCamera, "Create 2D Slide Screen Camera");

            slideScreenCamera.name = "_2DSlideScreenCamera (Created)";

            // set the panel holder.
            slideScreenCamera.PanelHolder = panelHolder9x9;

            slideScreenCamera.SetJCS2DCamera(cam);

            // set to default 2d.
            slideScreenCamera.UnityGUIType = JCS_UnityGUIType.uGUI_2D;
        }
Example #6
0
 public void SetJCS2DCamera(JCS_2DCamera cam)
 {
     this.mJCS_2DCamera = cam;
 }