示例#1
0
    void SaveClickedButton(EventParam buttonParam)
    {
        if (buttonList.Contains(buttonParam.getGameObjectParam()))
        {
            selectedButton = buttonParam.getGameObjectParam();

            // force result canvas deactivation when selecting a new measure
            resultCanvas.SetActive(false);

            // trigger custom event to activate the measure
            EventManager.TriggerEvent("UpdateMeasureMode", new EventParam(selectedButton.name));
        }
    }
示例#2
0
    void ShowHide(EventParam handParam)
    {
        hand = handParam.getGameObjectParam();

        if (simulationRuning == true)
        {
            if (hand != previousHand)
            {
                interfaceCanvas.SetActive(true);

                // attach interface to hand
                interfaceCanvas.transform.SetParent(hand.transform);
                interfaceCanvas.transform.localPosition = interfacePosition;
                interfaceCanvas.transform.localRotation = interfaceRotation;

                // update hand
                previousHand = hand;
            }
            else
            {
                // show hidden interface or hide shown interface
                interfaceCanvas.SetActive(!interfaceCanvas.activeSelf);
            }
        }
        if (interfaceCanvas.activeSelf == true)
        {
            // force measure pointer activation
            EventManager.TriggerEvent("ForceMeasurePointerActivation", new EventParam(hand));
        }
    }
示例#3
0
    void StartSimulation(EventParam param)
    {
        // take the chosen game object as a child
        selectedTerrain = param.getGameObjectParam();
        selectedTerrain.transform.SetParent(transform);

        // create teleport terrain as a duplication of the chosen terrain for teleportation
        teleportTerrain      = new GameObject();
        teleportTerrain.name = "TeleportTerrain";
        teleportTerrain.transform.SetParent(gameObject.transform);

        // set the terrain scale back to 1/1
        subTerrainCount = selectedTerrain.transform.childCount;
        for (int i = 0; i < subTerrainCount; i++)
        {
            selectedTerrain.transform.GetChild(i).position             = new Vector3(0f, 0f, 0f); // conpensate the translation in lobby
            selectedTerrain.transform.GetChild(i).transform.localScale = scale1o1;                // reset the terrain scale
            selectedTerrain.transform.GetChild(i).transform.tag        = "TerrainMeasure";        // disable spawn point selection and enable measure events (cf MeasurePointerHandler.cs)

            // clone the terrain to set it as a teleport area
            cloneTPTerrain = Instantiate(selectedTerrain.transform.GetChild(i).gameObject, teleportTerrain.transform);
            cloneTPTerrain.AddComponent <TeleportArea>();
            cloneTPTerrain.GetComponent <MeshRenderer>().enabled = false;   // don't display teleport area effect
            cloneTPTerrain.transform.Translate(new Vector3(0f, 0.01f, 0f)); // lift teleport area to put it properly above the terrain mesh collider
        }
        // set player initial position to the position of the previously clicked triangle
        spawnPoint = mesh.GetComponent <MeshFilter>().mesh.vertices[mesh.GetComponent <MeshFilter>().mesh.triangles[index * 3]];
        player.transform.localPosition = spawnPoint;

        // make sure the terrain cannot be moved around while in immersion mode
        transform.GetComponent <Throwable>().attachmentFlags = Hand.AttachmentFlags.DetachFromOtherHand;

        // send an event to the MeshLoader to destroy every remaining meshes
        EventManager.TriggerEvent("DestroyReaminingMeshes", null);
    }
示例#4
0
 void SaveSpawnPosition(EventParam param)
 {
     // saves the triangle index of the clicked mesh (game object)
     index = param.getIntParam();
     mesh  = param.getGameObjectParam();
     EventManager.TriggerEvent("LobbyHintMessage", new EventParam("Un point de départ à bien été sélectionné sur le terrain."));
 }
 void SendLoadMeshEvent(EventParam buttonParam)
 {
     // check if the clicked button is in the dictionary and trigger a custom event with the associated file path
     if (terrainButtons.ContainsKey(buttonParam.getGameObjectParam()))
     {
         EventManager.TriggerEvent("LoadChosenMesh", new EventParam(terrainButtons[buttonParam.getGameObjectParam()]));
     }
 }
示例#6
0
    void DisplayButtonDescription(EventParam buttonParam)
    {
        // check if the hovered button is part of the measure interface
        if (buttonList.Contains(buttonParam.getGameObjectParam()))
        {
            // activate the center description part of the measure UI
            descriptionCanvas.SetActive(true);

            // update the current button
            currentButton = buttonParam.getGameObjectParam();

            // set the center description part of the measure UI to hovered button content
            descriptionCanvas.transform.GetChild(0).GetComponent <Image>().sprite = currentButton.GetComponent <Image>().sprite;
            descriptionCanvas.transform.GetChild(1).GetComponent <Text>().text    = currentButton.transform.GetChild(0).GetComponent <Text>().name;
            descriptionCanvas.transform.GetChild(2).GetComponent <Text>().text    = currentButton.transform.GetChild(0).GetComponent <Text>().text;
        }
    }
示例#7
0
 void HideButtonDescription(EventParam buttonParam)
 {
     // check if the exited button is part of the measure interface
     if (buttonList.Contains(buttonParam.getGameObjectParam()))
     {
         // update the current button
         currentButton = buttonParam.getGameObjectParam();
         if (selectedButton == null)
         {
             descriptionCanvas.SetActive(false);
         }
         else
         {
             // set the center description part of the measure UI to clicked button content
             descriptionCanvas.transform.GetChild(0).GetComponent <Image>().sprite = selectedButton.GetComponent <Image>().sprite;
             descriptionCanvas.transform.GetChild(1).GetComponent <Text>().text    = selectedButton.transform.GetChild(0).GetComponent <Text>().name;
             descriptionCanvas.transform.GetChild(2).GetComponent <Text>().text    = selectedButton.transform.GetChild(0).GetComponent <Text>().text;
         }
     }
 }
    // create saving directories if needed
    private void SetSaveFolder(EventParam param)
    {
        string terrainName = param.getGameObjectParam().name;

        if (!Directory.Exists(saveDirectory + @"\" + terrainName))
        {
            Directory.CreateDirectory(saveDirectory + @"\" + terrainName);
        }

        saveSubDirectory = saveDirectory + @"\" + terrainName;
        Debug.Log("chemin du dossier de sauvegarde : " + saveSubDirectory);
    }
示例#9
0
    void StartSimulation(EventParam param)
    {
        // save the instantiated elements as terrain child
        cloneParent.SetParent(terrain.transform);
        cloneParent.gameObject.SetActive(true);

        if (terrainName == null || terrainName != param.getGameObjectParam().name)
        {
            // this is a new terrain
            terrainName = param.getGameObjectParam().name;

            // destroy the previously instantiated elements if they exist
            for (int i = 0; i < cloneParent.childCount; i++)
            {
                Destroy(cloneParent.GetChild(i).gameObject);
            }
            instanceList.Clear();
        }

        clickCount = 0;
    }
    // froce measure pointer activation when displaying the measure interface
    void ForceMeasurePointerActivation(EventParam handParam)
    {
        measurePointerIsActive = true;

        // set pointer to the oposite hand
        if (handParam.getGameObjectParam().name == rightHand.ToString())
        {
            SetPointerToHand(GameObject.Find(leftHand.ToString()));
        }
        else
        {
            SetPointerToHand(GameObject.Find(rightHand.ToString()));
        }

        measureLaserPointer.gameObject.SetActive(measurePointerIsActive);
    }
    public void UpdateMarker(EventParam buttonParam)
    {
        button = buttonParam.getGameObjectParam();
        if (button.name.Contains("Color"))
        {
            // update color of the marker
            markerInstance.UpdateColor(button.GetComponent <Button>().colors.normalColor);
        }

        if (button.name == "Validate")
        {
            clickCount = 0;
            EventManager.TriggerEvent("ShowHideMarkerEditorInterface", null);

            // allow new marker creation after about 1 second
            Invoke("EnableNewMarker", 0.8f);
        }
    }
    void GetTerrainBack(EventParam gameObjectParam)
    {
        // set terrain parent to MeshLoader game object
        gameObjectParam.getGameObjectParam().transform.SetParent(gameObject.transform);
        gameObjectParam.getGameObjectParam().transform.localScale = Vector3.one;

        // set scale for each submesh
        int terrainCount = gameObjectParam.getGameObjectParam().transform.childCount;

        for (int i = 0; i < terrainCount; i++)
        {
            gameObjectParam.getGameObjectParam().transform.GetChild(i).localScale = meshScale1o100;
            gameObjectParam.getGameObjectParam().transform.GetChild(i).position   = meshPositionOffset;
            gameObjectParam.getGameObjectParam().transform.GetChild(i).tag        = "Terrain"; // enable spawn point selection
        }
    }