コード例 #1
0
ファイル: VRAR_Level.cs プロジェクト: mserier/vrar
 public void addDumbObject(BaseTileObject tileObject)
 {
     if (!tileObject.getInteractable())
     {
         dumbObjectsList.Add(tileObject);
     }
     else
     {
         Debug.LogError("Someone tried to set a interactable object as a dumb object of the tile :" + this);
     }
 }
コード例 #2
0
ファイル: VRAR_Level.cs プロジェクト: mserier/vrar
 public void setInteractableObject(BaseTileObject tileObject)
 {
     if (tileObject.getInteractable())
     {
         interactableObject = tileObject;
     }
     else
     {
         Debug.LogError("Someone tried to set a non interactable object as the interactable object (" + tileObject.getObjectID() + ") of the tile :" + this);
     }
 }
コード例 #3
0
ファイル: CrossHair.cs プロジェクト: mserier/vrar
    private void updateButtons(VRAR_Tile tile)
    {
        //We can only attack neighbours
        foreach (VRAR_Tile circleTile in GameStateManager.getInstance().getCurrentLevel().selectCircle(GamePlayManagerAR.instance.localPlayer.GetCurrentVec().x, GamePlayManagerAR.instance.localPlayer.GetCurrentVec().y, 1))
        {
            if (circleTile == currentTile)
            {
                //if there is an npc show attack button
                NonPlayer npc = tile.getNPC();
                if (npc != null)
                {
                    attackButtonPrefab.SetActive(true);
                }
                //if there is another player also show attack button
                if (client != null)
                {
                    List <BasePlayer> players = client.getPlayerList();
                    foreach (BasePlayer player in players)
                    {
                        if (player.GetCurrentTile() == tile)
                        {
                            attackButtonPrefab.SetActive(true);
                        }
                    }
                }
            }
        }



        if (tile.GetWalkable())
        {
            walkButtonPrefab.SetActive(true);
            //if an object is walkable that means there is no object there so we can ignore te rest in this function
            return;
        }
        BaseTileObject baseTileObject = tile.getInteractableObject();

        //show hand if interactable
        if (baseTileObject.getInteractable() || tile.getInterior() != null)
        {
            handButtonPrefab.SetActive(true);
            inspectButtonPrefab.SetActive(true);
            currentTileText.text = baseTileObject.getName();
        }
        //if its not interactable we want to allow the player to inspec the object, but not if ther is object (id == 0)
        else
        {
            inspectButtonPrefab.SetActive(true);
            currentTileText.text = baseTileObject.getName();
        }
    }
コード例 #4
0
    public void setInteractableObject(BaseTileObject tileObject)
    {
        //Debug.Log("THis created a bugged tile so disabling it for now");
        return;

        if (tileObject.getInteractable())
        {
            interactableObject = tileObject;
        }
        else
        {
            Debug.LogError("Someone tried to set a non interactable object as the interactable object (" + tileObject.getObjectID() + ") of the tile :" + this);
        }
    }
コード例 #5
0
    public void loadLevel()
    {
        TextReader tr;

        if (Application.isEditor)
        {//use the project location
            tr = new StreamReader(Application.dataPath + "/levels/" + "/level_" + levelTile.tileIndex_X + "#" + levelTile.tileIndex_Y + ".sav");
        }
        else
        {//use the user save location
            tr = new StreamReader(Application.persistentDataPath + "/levels/" + "/level_" + levelTile.tileIndex_X + "#" + levelTile.tileIndex_Y + ".sav");
        }
        string line;

        while ((line = tr.ReadLine()) != null)
        {
            string[] splitted = line.Split(';');
            if (splitted.Length < 4)
            {
            }

            else
            {
                VRAR_Tile      tile = new VRAR_Tile(int.Parse(splitted[0]), int.Parse(splitted[1]), float.Parse(splitted[2]), splitted[5], bool.Parse(splitted[6]));
                BaseTileObject interactableObject = TileObjectManger.TILE_OBJECTS[int.Parse(splitted[3])];
                if (interactableObject.getInteractable())
                {
                    tile.setInteractableObject(interactableObject);
                    tile.SetWalkable(false);
                }
                if (splitted.Length >= 8 && splitted[7] != "")
                {
                    tile.setInterior(TileObjectManger.INTERIOR_BASE_OBJECTS[int.Parse(splitted[7])]);
                    tile.SetWalkable(false);
                }
                if (splitted.Length >= 9 && splitted[8] != "")
                {
                    tile.setNPC(new NonPlayer(int.Parse(splitted[8]), new Vector2Int(tile.tileIndex_X, tile.tileIndex_Y)));
                    tile.SetWalkable(false);
                }

                //Debug.Log("Reading lvl file interactable object :" + interactableObject.getName());
                if (splitted[4].Length > 0)
                {
                    string[] dumbObjectIDs = splitted[4].Split('<');
                    tile.SetWalkable(false);

                    foreach (string dumbString in dumbObjectIDs)
                    {
                        // Debug.Log(dumbObjectIDs.Length + " size");
                        //   Debug.Log(dumbString);
                        string[] splitty = dumbString.Split(',');
                        if (splitty.Length > 1)
                        {
                            // Debug.Log("Base tile id = " + dumbString[0]);
                            // Debug.Log("Splitty size = " + splitty.Length);
                            int        id        = int.Parse(splitty[0]);
                            float      positionX = float.Parse(splitty[1]);
                            float      positionY = float.Parse(splitty[2]);
                            float      positionZ = float.Parse(splitty[3]);
                            Vector3    position  = new Vector3(positionX, positionY, positionZ);
                            float      scaleX    = float.Parse(splitty[4]);
                            Vector3    scale     = new Vector3(scaleX, scaleX, scaleX);
                            Quaternion rotation  = new Quaternion(float.Parse(splitty[5]), float.Parse(splitty[6]), float.Parse(splitty[7]), float.Parse(splitty[8]));

                            /* Debug.Log("posx = " + positionX);
                             * Debug.Log("posy = " + positionY);
                             * Debug.Log("posz = " + positionZ);
                             * Debug.Log("scalex = " + scaleX);
                             * Debug.Log("scaley = " + scaleY);
                             * Debug.Log("scalez = " + scaleZ);
                             * Debug.Log("Next string is " + dumbObjectIDs[2]);
                             */
                            tile.AddPosition(id, position);
                            tile.AddRotation(id, rotation);
                            tile.AddScale(id, scale);
                            tile.addDumbObject(TileObjectManger.TILE_OBJECTS[id]);


                            if (id == TileObjectManger.SPAWN_POINT_ID)
                            {
                                //Debug.Log("Set the spawn points to walkable in a suboptimal way");
                                tile.SetWalkable(true);
                            }
                        }
                    }
                }

                if (tile.terrain == "Water")
                {
                    //Debug.Log("Set water to no walkable in a suboptimal way");
                    tile.SetWalkable(false);
                }

                vrarTiles.Add(tile);
                vrarTileDict.Add(new Vector2Int(int.Parse(splitted[0]), int.Parse(splitted[1])), tile);
                //Debug.Log("added tile :" +tile);
            }
        }


        //if level empty, spawn default lvl tiles
        if (vrarTiles.Count == 0)
        {
            Debug.Log("HOOOOOO");
            int radius = Random.Range(1, 8);
            for (int y = -radius; y <= radius; y++)
            {
                for (int x = -radius; x <= radius; x++)
                {
                    if (x * x + y * y <= radius * radius)
                    {
                        VRAR_Tile tile = new VRAR_Tile(x, y);
                        vrarTiles.Add(tile);
                        vrarTileDict.Add(new Vector2Int(x, y), tile);
                    }
                }
            }
        }
    }
コード例 #6
0
ファイル: VRAR_Level.cs プロジェクト: mserier/vrar
    public void readLVLFile()
    {
        TextReader tr;

        if (Application.isEditor)
        {//use the project location
            tr = new StreamReader(Application.dataPath + "/levels/" + "/level_" + levelTile.tileIndex_X + "#" + levelTile.tileIndex_Y + ".sav");
        }
        else
        {//use the user save location
            tr = new StreamReader(Application.persistentDataPath + "/levels/" + "/level_" + levelTile.tileIndex_X + "#" + levelTile.tileIndex_Y + ".sav");
        }
        string line;

        while ((line = tr.ReadLine()) != null)
        {
            string[] splitted = line.Split(';');
            if (splitted.Length < 4)
            {
            }

            else
            {
                VRAR_Tile      tile = new VRAR_Tile(int.Parse(splitted[0]), int.Parse(splitted[1]), float.Parse(splitted[2]), splitted[5], bool.Parse(splitted[6]));
                BaseTileObject interactableObject = TileObjectManger.TILE_OBJECTS[int.Parse(splitted[3])];
                if (interactableObject.getInteractable())
                {
                    tile.setInteractableObject(interactableObject);
                }

                //Debug.Log("Reading lvl file interactable object :" + interactableObject.getName());
                if (splitted[4].Length > 0)
                {
                    string[] dumbObjectIDs = splitted[4].Split('<');
                    foreach (string dumbString in dumbObjectIDs)
                    {
                        tile.addDumbObject(TileObjectManger.TILE_OBJECTS[int.Parse(dumbString)]);
                    }
                }

                vrarTiles.Add(tile);
                vrarTileDict.Add(new Vector2Int(int.Parse(splitted[0]), int.Parse(splitted[1])), tile);
                //Debug.Log("added tile :" +tile);
            }
        }


        //if level empty, spawn default lvl tiles
        if (vrarTiles.Count == 0)
        {
            Debug.Log("HOOOOOO");
            int radius = Random.Range(1, 8);
            for (int y = -radius; y <= radius; y++)
            {
                for (int x = -radius; x <= radius; x++)
                {
                    if (x * x + y * y <= radius * radius)
                    {
                        VRAR_Tile tile = new VRAR_Tile(x, y);
                        vrarTiles.Add(tile);
                        vrarTileDict.Add(new Vector2Int(x, y), tile);
                    }
                }
            }
        }
    }