Example #1
0
        public void SetCursorAt(int blockType, Vector3 worldPos)
        {
            Vector3    localPos = this.transform.InverseTransformPoint(worldPos);
            PlanetSide pSide    = this.GetPlanetSideFor(localPos);
            Vector3    ijk      = pSide.GetIJKFor(localPos);

            PlanetCursor.SetAt(blockType, (int)ijk.x, (int)ijk.y, (int)ijk.z, pSide);
        }
Example #2
0
 static public void SetAt(int blockType, int i, int j, int k, PlanetSide planetSide)
 {
     if ((PlanetCursor.posInPlanetSide != new Vector3(i, j, k)) || (planetSide.transform != PlanetCursor.CursorTransform.parent))
     {
         cursorPlanetSide = planetSide;
         PlanetCursor.BuildCursor(blockType, i, j, k, planetSide);
     }
 }
Example #3
0
        public void AddGameObjectAtCursor(GameObject prefab)
        {
            GameObject dropped = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;

            dropped.transform.parent        = PlanetCursor.cursorPlanetSide.transform;
            dropped.transform.localPosition = PlanetCursor.GetLocalPosBlockCenter();
            float a = Vector3.Angle(dropped.transform.up, (dropped.transform.position - dropped.transform.parent.position));

            dropped.transform.RotateAround(dropped.transform.position, Vector3.Cross(dropped.transform.up, (dropped.transform.position - dropped.transform.parent.position)), a);
            dropped.transform.RotateAround(dropped.transform.position, dropped.transform.up, UnityEngine.Random.Range(0, 360f));
            dropped.transform.parent = this.vegetationFolder;
        }
Example #4
0
        static void PlanetEditorGUI(SceneView sceneView)
        {
            mousePos.x = Event.current.mousePosition.x / Screen.width;
            mousePos.y = (SceneView.lastActiveSceneView.camera.pixelHeight - Event.current.mousePosition.y) / SceneView.lastActiveSceneView.camera.pixelHeight;

            Handles.BeginGUI();
            if (PlanetEditor.PlanetSelected() != null)
            {
                GUILayout.Button(PlanetEditorLogo, GUILayout.Height(50f), GUILayout.Width(150f));
                if (!PlanetEditor.planetEditMode)
                {
                    if (GUILayout.Button("EDIT", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        PlanetEditor.selectedPlanet = PlanetEditor.PlanetSelected();
                        PlanetEditor.planetEditMode = true;
                        PlanetEditor.selectedPlanet.BuildColliders();
                        PlanetEditor.selectedBlock = 0;
                        PlanetCursor.SetMaterial(PlanetEditor.EraseMaterial);
                    }
                }
                else if (PlanetEditor.planetEditMode)
                {
                    if (GUILayout.Button("OVER", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        PlanetEditor.planetEditMode = false;
                        PlanetCursor.HideCursor();
                    }

                    GUILayout.Button("Cursor. i = " + PlanetCursor.posInPlanetSide.x + " | j = " + PlanetCursor.posInPlanetSide.y + " | h = " + PlanetCursor.posInPlanetSide.z, GUILayout.Height(30f), GUILayout.Width(250f));

                    scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(110f));
                    if (GUILayout.Button(PlanetEditor.PlanetEraseLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = 0.2f;
                        PlanetEditor.selectedBlock      = 0;
                        PlanetCursor.SetMaterial(PlanetEditor.EraseMaterial);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetDirtLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 1;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[0]);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetRockLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 3;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[2]);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetSandLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 4;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[3]);
                    }
                    if (GUILayout.Button(PlanetEditor.PlanetDustLogo, GUILayout.Height(80f), GUILayout.Width(80f)))
                    {
                        PlanetEditor.mouseRayCorrection = -0.2f;
                        PlanetEditor.selectedBlock      = 5;
                        PlanetCursor.SetMaterial(PlanetEditor.selectedPlanet.planetMaterials[4]);
                    }

                    for (int i = 0; i < PrefabsVegetation.Count; i++)
                    {
                        if (GUILayout.Button(PrefabsVegetationLogo[i], GUILayout.Height(80f), GUILayout.Width(80f)))
                        {
                            PlanetEditor.mouseRayCorrection = -0.2f;
                            PlanetEditor.selectedBlock      = 100;
                            PlanetCursor.SetMaterial(VegetationMaterial);
                            selectedGameObject = PrefabsVegetation[i];
                        }
                    }
                    GUILayout.EndScrollView();

                    if (GUILayout.Button("Vegetation Wizard", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        PlanetVegetationWindow.Open(selectedPlanet, PrefabsVegetation, PrefabsVegetationLogo);
                    }

                    if (PrefabsVegetation.Count > 0)
                    {
                        if (PrefabsVegetation [0] == null)
                        {
                            Debug.Log("IsNull");
                        }
                    }

                    if (GUILayout.Button("Refresh Vegetation Pictures", GUILayout.Height(30f), GUILayout.Width(150f)))
                    {
                        prefabsVegetationLogo = null;
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                }
            }
            Handles.EndGUI();

            if (PlanetEditor.planetEditMode)
            {
                if (PlanetEditor.planetHit)
                {
                    selectedPlanet.SetCursorAt(PlanetEditor.selectedBlock, mouseRayImpact);
                }
                else
                {
                    PlanetCursor.HideCursor();
                }

                if (Event.current.type == EventType.MouseDown)
                {
                    if (Event.current.button == 0)
                    {
                        if (selectedBlock < 100)
                        {
                            PlanetEditor.selectedPlanet.AddBlockAt(PlanetEditor.mouseRayImpact, PlanetEditor.selectedBlock);
                        }
                        else
                        {
                            PlanetEditor.selectedPlanet.AddGameObjectAtCursor(selectedGameObject);
                        }
                    }
                }
            }
        }