Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        cursorMove();
        switch (stateIndex)
        {
        case 0:
            lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(ingameCursor.position));
            if (lvl != null)
            {
                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    previousSelectedTile.GetComponent <Renderer>().material = previousSelectedTileMaterial;
                    previousSelectedTileMaterial = lvl.levelTile.hexObject.gameObject.GetComponent <Renderer>().material;
                }

                //Set material of selected tile
                lvl.levelTile.hexObject.gameObject.GetComponent <Renderer>().material = selectedTileMaterial;

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(lvl.levelTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + lvl.levelTile.tileIndex_X + "  " + lvl.levelTile.tileIndex_Y;

                previousSelectedTile = lvl.levelTile.hexObject.gameObject;
            }
            break;

        default:
            VRAR_Tile selTile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(ingameCursor.position).x, lvlManager.getTilePosFromWorldPos(ingameCursor.position).y);
            if (selTile != null)
            {
                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    previousSelectedTile.GetComponent <Renderer>().material = previousSelectedTileMaterial;
                    previousSelectedTileMaterial = selTile.hexObject.gameObject.GetComponent <Renderer>().material;
                }

                //Set material of selected tile
                selTile.hexObject.gameObject.GetComponent <Renderer>().material = selectedTileMaterial;

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(selTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + selTile.tileIndex_X + "  " + selTile.tileIndex_Y;

                previousSelectedTile = selTile.hexObject.gameObject;

                lvl.tileUpdate(0, 0);
            }
            break;
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        //cursorMove();
        switch (GameStateManager.instance.getGlobalStateIndex())
        {
        case GameStateManager.STATE_CAMPAIGN_EDITOR:
            cursorMarker.position = Vector3.Scale(leftHandCursor.position, (truncY)) + offY;
            lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position));
            if (lvl != null)
            {
                GameStateManager.instance.setCurrentLevel(lvl);

                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    //    previousSelectedTile.GetComponent<Renderer>().material = previousSelectedTileMaterial;
                    //    previousSelectedTileMaterial = lvl.levelTile.hexObject.gameObject.GetComponent<Renderer>().material;
                    previousSelectedTile.hexObject.gameObject.GetComponent <Renderer>().material = TileObjectManger.getMaterial(previousSelectedTile.GetTerrain());
                }

                //Set material of selected tile
                lvl.levelTile.hexObject.gameObject.GetComponent <Renderer>().material = selectedTileMaterial;

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(lvl.levelTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + lvl.levelTile.tileIndex_X + "  " + lvl.levelTile.tileIndex_Y;

                //previousSelectedTile = lvl.levelTile.hexObject.gameObject;
                previousSelectedTile = lvl.levelTile;
            }
            break;

        case GameStateManager.STATE_LEVEL_EDITOR:
            lvl = GameStateManager.instance.getCurrentLevel();
            //Debug.Log("level state :"+lvl.levelTile.ToString());
            cursorMarker.position = Vector3.Scale(rightHandCursor.position, (truncY)) + offY;
            //cursorMarker.position *= 5f;
            //VRAR_Tile selTile=  lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(rightHandCursor.position).x, lvlManager.getTilePosFromWorldPos(rightHandCursor.position).y);
            VRAR_Tile selTile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(cursorMarker.position).x, lvlManager.getTilePosFromWorldPos(cursorMarker.position).y);
            if (selTile != null)
            {
                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    //previousSelectedTile.GetComponent<Renderer>().material = previousSelectedTileMaterial;
                    //previousSelectedTileMaterial = selTile.hexObject.gameObject.GetComponent<Renderer>().material;
                    previousSelectedTile.hexObject.gameObject.GetComponent <Renderer>().material = TileObjectManger.getMaterial(previousSelectedTile.GetTerrain());
                }

                //Set material of selected tile
                selTile.hexObject.gameObject.GetComponent <Renderer>().material = selectedTileMaterial;

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(selTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + selTile.tileIndex_X + "  " + selTile.tileIndex_Y;

                //previousSelectedTile = selTile.hexObject.gameObject;
                previousSelectedTile = selTile;

                lvl.tileUpdate(0, 0);
            }
            break;

        case GameStateManager.STATE_PLAYING:
            break;
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        //cursorMove();
        switch (GameStateManager.instance.getGlobalStateIndex())
        {
        case GameStateManager.STATE_CAMPAIGN_EDITOR:
            cursorMarker.position = Vector3.Scale(leftHandCursor.position, (truncY)) + offY;
            lvl = lvlManager.getLevelObjectFromTilePos(lvlManager.getTilePosFromWorldPos(leftHandCursor.position));
            if (lvl != null)
            {
                GameStateManager.instance.setCurrentLevel(lvl);

                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    previousSelectedTile.hexObject.gameObject.GetComponent <Renderer>().material = TileObjectManger.getMaterial(previousSelectedTile.GetTerrain());
                }

                //Set material of selected tile
                lvl.levelTile.hexObject.gameObject.GetComponent <Renderer>().material = TileObjectManger.getMaterial("Selection");

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(lvl.levelTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + lvl.levelTile.tileIndex_X + "  " + lvl.levelTile.tileIndex_Y;

                previousSelectedTile = lvl.levelTile;
            }
            break;

        case GameStateManager.STATE_LEVEL_EDITOR:
            lvl = GameStateManager.instance.getCurrentLevel();
            cursorMarker.position = Vector3.Scale(rightHandCursor.position, (truncY)) + offY;
            selTile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(cursorMarker.position).x, lvlManager.getTilePosFromWorldPos(cursorMarker.position).y);
            if (selTile != null && selTile.hexObject != null && !Valve.VR.InteractionSystem.VRInputHandler.isInTileObjectEditMenu)
            {
                //if selectedHexPrefab is a prefab (so not in any scene)
                if (selectedHexPrefab.gameObject.scene.name == null)
                {
                    selectedHexPrefabItem = selectedHexPrefab;
                    //spawn prefab is scene
                    selectedHexPrefab = Instantiate(selectedHexPrefab);
                }


                //Reset the previous tile back to normal
                if (previousSelectedTile != null)
                {
                    //previousSelectedTile.hexObject.gameObject.GetComponent<Renderer>().material = TileObjectManger.getMaterial(previousSelectedTile.GetTerrain());
                }

                //Set material of selected tile

                //selTile.hexObject.gameObject.GetComponent<Renderer>().material = TileObjectManger.getMaterial("Selection");
                selectedHexPrefab.gameObject.transform.position = selTile.hexObject.position + (new Vector3(0, (float)(selTile.height_ + 0.1), 0));

                //Add update list of selected tiles
                selectedTiles.Clear();
                selectedTiles.Add(selTile);

                //update debug text of current selected tile
                selectedLevelText.text = "lvl :" + selTile.tileIndex_X + "  " + selTile.tileIndex_Y;

                previousSelectedTile = selTile;

                lvl.tileUpdate(0, 0);
            }
            break;

        case GameStateManager.STATE_PLAYING:
            lvl = GameStateManager.instance.getCurrentLevel();
            cursorMarker.position = Vector3.Scale(rightHandCursor.position, (truncY)) + offY;
            selTile = lvl.getTileFromIndexPos(lvlManager.getTilePosFromWorldPos(cursorMarker.position).x, lvlManager.getTilePosFromWorldPos(cursorMarker.position).y);
            if (selTile != null && selTile.hexObject != null && !Valve.VR.InteractionSystem.VRInputHandler.isInTileObjectEditMenu)
            {
                if (prevSelTile != selTile)
                {
                    //var tileMessage = new TileMessage(selTile);
                    if (prevSelTile != null && prevSelTile.hexObject != null)
                    {
                        foreach (VRAR_Tile tile in GameStateManager.instance.getCurrentLevel().dirtyTiles)
                        {
                            var tileMessage = new TileMessage(tile, false);
                            NetworkServer.SendToAll(CustomNetMsg.Tile, tileMessage);
                        }
                        GameStateManager.instance.getCurrentLevel().dirtyTiles.Clear();
                    }
                }

                //if selectedHexPrefab is a prefab (so not in any scene)
                if (selectedHexPrefab.gameObject.scene.name == null)
                {
                    selectedHexPrefabItem = selectedHexPrefab;
                    //spawn prefab is scene
                    selectedHexPrefab = Instantiate(selectedHexPrefab);
                }

                //Set material of selected tile
                selectedHexPrefab.gameObject.transform.position = selTile.hexObject.position + (new Vector3(0, selTile.height_ - 1, 0));

                prevSelTile = selTile;
            }
            break;
        }
    }