コード例 #1
0
        private void btn_scale_negative_Click(object sender, EventArgs e)
        {
            GameObject_Scene_EDITOR gameObject = editor_handle.GetActiveGameObject();

            if (gameObject != null)
            {
                if (gameObject.obj.scaling_rate > 0)
                {
                    gameObject.obj.scaling_rate -= 1f;
                    gameObject.obj.UpdateScale(1f, true);

                    for (int cnt = 0; cnt < editor_handle.gameObjectScene_list.Count; cnt++)
                    {
                        Editor.GameObject_Scene gameObj = editor_handle.gameObjectScene_list[cnt];

                        if (editor_handle.gameObjectScene_list[cnt].instance_name == gameObject._obj.instance_name)
                        {
                            gameObj.scaling_rate -= 1f;
                            editor_handle.gameObjectScene_list[cnt] = gameObj;
                            editor_handle.UpdateWorldChilds(editor_handle.gameObjectScene_list[cnt]);

                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private bool addChild(ref Editor.GameObject_Scene gameObj_selected, ref Editor.GameObject_Scene gameObject, string child_name)
        {
            for (int cnt = 0; cnt < gameObject.child_list.Count; cnt++)
            {
                if (gameObject.child_list[cnt].instance_name == child_name)
                {
                    if (MessageBox.Show(child_name + " already belongs to " + gameObject.instance_name + ". You want to add this child to " + gameObject.instance_name + "?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes)
                    {
                        gameObj_selected.child_list.Add(gameObject.child_list[cnt]);
                        gameObject.child_list.Remove(gameObject.child_list[cnt]);
                    }
                    else
                    {
                        return(false);
                    }

                    return(true);
                }
            }

            for (int cnt = 0; cnt < gameObject.child_list.Count; cnt++)
            {
                Editor.GameObject_Scene obj = gameObject.child_list[cnt];

                if (addChild(ref gameObj_selected, ref obj, child_name))
                {
                    gameObject.child_list[cnt] = obj;
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        private void reloadGameObjectList( )
        {
            gameObject_list.Clear();

            foreach (Editor.GameObject_Scene gameObject in editor_handle.gameObjectScene_list)
            {
                Editor.GameObject_Scene cp = gameObject;

                cp.position_scene_x = cp.position_x;
                cp.position_scene_y = cp.position_y;

                gameObject_list.Add(cp);
            }
        }
コード例 #4
0
        private void rotateCamera()
        {
            for (int cntr = 0; cntr < gameObject_list.Count; cntr++)
            {
                if (gameObject_list[cntr].mainObject.object_img != null)
                {
                    Editor.GameObject_Scene gameObj = gameObject_list[cntr];

                    gameObj.ApplyRotation(-cam_angle);

                    gameObject_list[cntr] = gameObj;
                }
            }
        }
コード例 #5
0
        private void btn_right_Click(object sender, EventArgs e)
        {
            for (int cnt = 0; cnt < gameObject_list.Count; cnt++)
            {
                if (gameObject_list[cnt].mainObject.object_text == "")
                {
                    Editor.GameObject_Scene handle = gameObject_list[cnt];

                    handle.position_scene_x -= (baseGameObject.object_img != null) ? baseGameObject.object_img.Width : 5;

                    gameObject_list[cnt] = handle;
                }
            }

            cam_x += 5;
        }
コード例 #6
0
        private void btn_moveUp_Click(object sender, EventArgs e)
        {
            NavigationPoint nav_point = navigation_start;

            while (nav_point != null)
            {
                nav_point.scene_y += 5;

                nav_point = nav_point.next_handle;
            }

            for (int cnt = 0; cnt < gameObject_list.Count; cnt++)
            {
                Editor.GameObject_Scene gameObject = gameObject_list[cnt];

                gameObject.position_scene_y += 5;

                gameObject_list[cnt] = gameObject;
            }

            camY -= 5;
        }
コード例 #7
0
        private void btn_rotate_anticlockwise_Click(object sender, EventArgs e)
        {
            GameObject_Scene_EDITOR gameObject = editor_handle.GetActiveGameObject( );

            if (gameObject != null)
            {
                gameObject.obj.Rotate(1f);
                gameObject.obj.UpdateRotation(1f, gameObject.obj.position_scene_x + gameObject.obj.mainObject.object_img.Width / 2, gameObject.obj.position_scene_y + gameObject.obj.mainObject.object_img.Height / 2, true);

                for (int cnt = 0; cnt < editor_handle.gameObjectScene_list.Count; cnt++)
                {
                    Editor.GameObject_Scene gameObj = editor_handle.gameObjectScene_list[cnt];

                    if (editor_handle.gameObjectScene_list[cnt].instance_name == gameObject._obj.instance_name)
                    {
                        gameObj.Rotate(1f);
                        editor_handle.gameObjectScene_list[cnt] = gameObj;
                        editor_handle.UpdateWorldChilds(editor_handle.gameObjectScene_list[cnt]);

                        break;
                    }
                }
            }
        }
コード例 #8
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            if (txt_name.Text == "")
            {
                MessageBox.Show("Object name cannot be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            StreamWriter stm_wr = new StreamWriter(editor_handle.project_default_dir + "\\Game-Objects\\" + txt_name.Text + ".obj");

            stm_wr.WriteLine("Name: @" + txt_name.Text);
            stm_wr.WriteLine("Image: @" + "Game-Resouces\\" + Path.GetFileName(txt_image.Text));
            stm_wr.WriteLine("Text: @" + txt_text.Text);
            stm_wr.WriteLine("Tag: " + txt_tag.Text);

            stm_wr.WriteLine("Scripts: ");

            for (int cntr = 0; cntr < lb_scripts.Items.Count; cntr++)
            {
                stm_wr.Write("@Game-Scripts\\" + Path.GetFileName(lb_scripts.Items[cntr].ToString()) + "@ ");
            }

            stm_wr.Write(";");
            stm_wr.WriteLine("");

            stm_wr.WriteLine("Static: " + cb_static.Checked);
            stm_wr.WriteLine("Physics: " + cb_physics.Checked);
            stm_wr.WriteLine("RigidBody: " + cb_rigid_body.Checked);
            stm_wr.WriteLine("Collider: " + cb_collider.Checked);

            stm_wr.Flush();
            stm_wr.Close();

            Editor.GameObject newObject;

            newObject.object_name = txt_name.Text;
            newObject.object_img  = (File.Exists(txt_image.Text)) ? Image.FromFile(txt_image.Text) : null;
            newObject.path        = txt_image.Text;
            newObject.scripts     = new List <string>();

            for (int cntr = 0; cntr < lb_scripts.Items.Count; cntr++)
            {
                newObject.scripts.Add((string)lb_scripts.Items[cntr]);
            }

            newObject.object_text     = txt_text.Text;
            newObject.object_tag      = int.Parse("0" + txt_tag.Text);
            newObject.isStatic        = cb_static.Checked;
            newObject.object_physics  = cb_physics.Checked;
            newObject.object_rigid    = cb_rigid_body.Checked;
            newObject.object_collider = cb_collider.Checked;

            for (int cnt = 0; cnt < editor_handle.gameObject_list.Count; cnt++)
            {
                if (editor_handle.gameObject_list[cnt].object_name == sel_name)
                {
                    for (int cntr = 0; cntr < editor_handle.gameObjectScene_list.Count; cntr++)
                    {
                        if (editor_handle.gameObjectScene_list[cntr].mainObject.object_name == sel_name)
                        {
                            Editor.GameObject_Scene handle = editor_handle.gameObjectScene_list[cntr];

                            handle.mainObject = newObject;
                            handle.Initialize();

                            editor_handle.gameObjectScene_list[cntr] = handle;
                        }
                    }

                    editor_handle.gameObject_list[cnt] = newObject;
                    break;
                }
            }
        }
コード例 #9
0
        void canvas_MouseClick(object sender, MouseEventArgs e)
        {
            if (baseGameObject.object_img == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                foreach (Editor.GameObject_Scene gameObject in gameObject_list)
                {
                    if (e.X >= gameObject.position_scene_x && e.X <= gameObject.position_scene_x + baseGameObject.object_img.Width && e.Y >= gameObject.position_scene_y && e.Y <= gameObject.position_scene_y + baseGameObject.object_img.Height && gameObject.isTile)
                    {
                        return;
                    }
                }

                for (int y = 0; y < canvas.Height; y += baseGameObject.object_img.Height)
                {
                    for (int x = 0; x < canvas.Width; x += baseGameObject.object_img.Width)
                    {
                        if (e.X >= x && e.X <= x + baseGameObject.object_img.Width && e.Y >= y && e.Y <= y + baseGameObject.object_img.Height)
                        {
                            // Create GameObject_Scene.
                            Editor.GameObject_Scene gameObj = new Editor.GameObject_Scene();

                            gameObj.isTile           = true;
                            gameObj.mainObject       = baseGameObject;
                            gameObj.instance_name    = "tile_" + (new Random()).Next(0, 100000000).ToString( ) + "_X_" + (new Random()).Next(0, 100000000).ToString( );
                            gameObj.position_scene_x = x;
                            gameObj.position_scene_y = y;
                            gameObj.position_x       = x + cam_x;
                            gameObj.position_y       = y + cam_y;
                            gameObj.depth            = 10000;

                            gameObject_list.Add(gameObj);
                            return;
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                foreach (Editor.GameObject_Scene gameObject in gameObject_list)
                {
                    if (e.X >= gameObject.position_scene_x && e.X <= gameObject.position_scene_x + baseGameObject.object_img.Width && e.Y >= gameObject.position_scene_y && e.Y <= gameObject.position_scene_y + baseGameObject.object_img.Height && gameObject.isTile)
                    {
                        /*  for (int cnt = 0; cnt < editor_handle.gameObjectScene_list.Count; cnt++)     // Delete instance in the main editor.
                         * {
                         *    if (gameObject.instance_name == editor_handle.gameObjectScene_list[cnt].instance_name)
                         *    {
                         *        editor_handle.gameObjectScene_list.RemoveAt(cnt);
                         *        break;
                         *    }
                         * }
                         *
                         * editor_handle.sortedArray = new Editor.DrawableGameObject[editor_handle.gameObjectScene_list.Count];
                         *
                         * for (int cnt = 0; cnt < editor_handle.gameObjectScene_list.Count; cnt++)
                         * {
                         *    editor_handle.sortedArray[cnt].depth = editor_handle.gameObjectScene_list[cnt].depth;
                         *    editor_handle.sortedArray[cnt].index = cnt;
                         * }
                         *
                         * while (!editor_handle.checkSorted(editor_handle.sortedArray))
                         * {
                         *    editor_handle.sortElements(editor_handle.sortedArray);
                         * } */

                        gameObject_list.Remove(gameObject);
                        return;
                    }
                }
            }
        }
コード例 #10
0
        private void btn_add_child_Click(object sender, EventArgs e)
        {
            GameObject_Scene_EDITOR gameObject = null;

            if ((gameObject = editor_handle.GetActiveGameObject()) == null)
            {
                MessageBox.Show("No selected object found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close();
            }

            if (cb_objects.SelectedIndex != -1)
            {
                bool isSuccess = false;

                foreach (Editor.GameObject_Scene gameObj in editor_handle.gameObjectScene_list)
                {
                    if (gameObj.instance_name == gameObject._obj.instance_name)
                    {
                        isSuccess = true;
                        break;
                    }
                }

                if (!isSuccess)
                {
                    MessageBox.Show("The GameObject is deleted from the scene.");
                    ChildEditor_Load(null, null); // Reload our list.
                }
                else
                {
                    isSuccess = false;

                    for (int cnt = 0; cnt < editor_handle.gameObjectScene_list.Count; cnt++)
                    {
                        Editor.GameObject_Scene obj = editor_handle.gameObjectScene_list[cnt];

                        if (addChild(ref gameObject.obj, ref obj, (string)cb_objects.Items[cb_objects.SelectedIndex]))
                        {
                            editor_handle.gameObjectScene_list[cnt] = obj;
                            ChildEditor_Load(null, null);
                            isSuccess = true;
                            break;
                        }
                    }

                    if (!isSuccess)
                    {
                        if (!addChild(ref gameObject.obj, ref gameObject.obj, (string)cb_objects.Items[cb_objects.SelectedIndex]))
                        {
                            for (int cnt = 0; cnt < editor_handle.gameObjectScene_list.Count; cnt++)
                            {
                                if (editor_handle.gameObjectScene_list[cnt].instance_name == (string)cb_objects.Items[cb_objects.SelectedIndex])
                                {
                                    gameObject.obj.child_list.Add(editor_handle.gameObjectScene_list[cnt]);
                                    ChildEditor_Load(null, null);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
        private void btn_Add_Click(object sender, EventArgs e)
        {
            if (txt_instance_name.Text == "")
            {
                MessageBox.Show("Instance name cannot be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (lb_object.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a object!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txt_depth.Text == "")
            {
                MessageBox.Show("Please provide a depth!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            foreach (Editor.GameObject_Scene obj in editor_handle.gameObjectScene_list)
            {
                if (obj.instance_name == txt_instance_name.Text)
                {
                    MessageBox.Show("The instance is already declared!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            Editor.GameObject_Scene game_object = new Editor.GameObject_Scene();

            game_object.instance_name    = txt_instance_name.Text;
            game_object.position_x       = int.Parse(txt_position_x.Text);
            game_object.position_y       = int.Parse(txt_position_y.Text);
            game_object.depth            = int.Parse(txt_depth.Text);
            game_object.position_scene_x = game_object.position_x + editor_handle.cam_x;
            game_object.position_scene_y = game_object.position_y + editor_handle.cam_y;
            game_object.mainObject       = editor_handle.gameObject_list[lb_object.SelectedIndex];
            game_object.Initialize();

            editor_handle.gameObjectScene_list.Add(game_object);

            editor_handle.sortedArray = new  Editor.DrawableGameObject[editor_handle.gameObjectScene_list.Count];

            for (int cnt = 0; cnt < editor_handle.gameObjectScene_list.Count; cnt++)
            {
                editor_handle.sortedArray[cnt].depth = editor_handle.gameObjectScene_list[cnt].depth;
                editor_handle.sortedArray[cnt].index = cnt;
            }

            while (!editor_handle.checkSorted(editor_handle.sortedArray))
            {
                editor_handle.sortElements(editor_handle.sortedArray);
            }

            editor_handle.addGameObject(game_object.instance_name);

            editor_handle.reloadFileTree();

            this.Close();
        }