コード例 #1
0
 private void SwitchToCube()
 {
     if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.staticCube))
     {
         cubeType = EditorCubeType.Static;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.moveableCube))
     {
         cubeType = EditorCubeType.Moveable;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.elevatorCube))
     {
         cubeType = EditorCubeType.Elevator;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.unmoveableCube))
     {
         cubeType = EditorCubeType.Unmoveable;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.victoryCube))
     {
         cubeType = EditorCubeType.Victory;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.deliveryCube))
     {
         cubeType = EditorCubeType.Delivery;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.spawnCube))
     {
         cubeType = EditorCubeType.Spawn;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.timerCube))
     {
         cubeType = EditorCubeType.Timer;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.stickyCube))
     {
         cubeType = EditorCubeType.Sticky;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.switchCube))
     {
         cubeType = EditorCubeType.Switch;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.mirrorCube))
     {
         cubeType = EditorCubeType.Mirror;
     }
     else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.chaosBall))
     {
         cubeType = EditorCubeType.ChaosBall;
     }
     //else if (InputManager.instance.KeyDown(InputManager._LevelEditorBindings.levelNode)) cubeType = CubeType.LevelNode;
 }
コード例 #2
0
        public void PlaceCubeInEditor(EditorCubeType cubeTypeToPlace, Node receivedNode)
        {
            localWorldPositionOfNode = receivedNode.nodeViz.transform.position;
            Debug.Log("Placed a Cube " + cubeTypeToPlace.ToString() + " : " + receivedNode.nodePosX + " " + receivedNode.nodePosY + " " + receivedNode.nodePosZ);

            //make sure that their isn't an object already present at the node's position
            if (receivedNode.cubeOnNodePos != null)
            {
                //if there is, destroy the present object and "reset" the position
                DestroyImmediate(inSceneGameObjects[inSceneGameObjects.IndexOf(receivedNode.cubeOnNodePos.gameObject)]);
                //remove the object from the list of active objects in scene
                inSceneGameObjects.Remove(receivedNode.cubeOnNodePos.gameObject);
                receivedNode.cubeOnNodePos = null;
            }

            //place the "actual" where you were pointing the preview object
            GameObject placedObject = Instantiate(objectToPlace, localWorldPositionOfNode, Quaternion.identity) as GameObject;
            //Get the object properties so that they can be modified
            Grid_Object placedObjectProperties = placedObject.GetComponent <Grid_Object>();

            //set the position of the object in node coordinates
            placedObjectProperties.cubeData.gridPositionX = receivedNode.nodePosX;
            placedObjectProperties.cubeData.gridPositionY = receivedNode.nodePosY;
            placedObjectProperties.cubeData.gridPositionZ = receivedNode.nodePosZ;

            placedObjectProperties.cubeData.worldPosition = placedObject.transform.position;
            placedObjectProperties.cubeData.worldRotation = appliedCubeRotation;

            placedObject.transform.parent = _Grid.instance.gameObject.transform.GetChild(0).transform.GetChild(1).transform;

            placedObjectProperties.cubeTexture = AssetIntegrator.instance.selectedTexture;

            placedObject.SendMessage("CubeTypeMessage", cubeTypeToPlace);

            //place object at currently selected node position
            receivedNode.cubeOnNodePos = placedObjectProperties;
            inSceneGameObjects.Add(placedObject);
        }