コード例 #1
0
 public NodeSave(Node.worldObject _placedThing, Vector3Int _worldSpacePosition, byte _texture, Node.orientation _dir)
 {
     placedThing        = _placedThing;
     worldSpacePosition = new int[3] {
         _worldSpacePosition.x, _worldSpacePosition.y, _worldSpacePosition.z
     };
     texture   = _texture;
     direction = _dir;
 }
コード例 #2
0
    private void RotateToPoint(Node.orientation _dir)
    {
        switch (_dir)
        {
        case Node.orientation.east:
            currentInstance.transform.Rotate(0, 90, 0);
            break;

        case Node.orientation.south:
            currentInstance.transform.Rotate(0, 180, 0);
            break;

        case Node.orientation.west:
            currentInstance.transform.Rotate(0, 270, 0);
            break;
        }
    }
コード例 #3
0
ファイル: GameGrid.cs プロジェクト: Keyiter/PnP-RPG-Helper
    public void placeObjectInPoint(Vector3 _pos, Node.worldObject _thing, GameObject _obj, byte _txt = 0, bool isLoading = false, Node.orientation _dir = Node.orientation.north)
    {
        int x = (int)Mathf.Floor(_pos.x);
        int y = (int)Mathf.Floor(_pos.y);
        int z = (int)Mathf.Floor(_pos.z);

        grid[y, x, z].placedThing  = _thing;
        grid[y, x, z].placedObject = _obj;
        grid[y, x, z].texture      = _txt;

        if (_thing == Node.worldObject.ground)
        {
            grid[y, x, z].walkable = Node.terrainType.walkable;
        }
        else if (_thing == Node.worldObject.stairsUp)
        {
            grid[y, x, z].walkable = Node.terrainType.difficult;
            removeObjectInPoint(new Vector3(x, y + 1, z), y + 1);
            placeObjectInPoint(new Vector3(x, y + 1, z), Node.worldObject.stairsDown, null);
        }
        else if (_thing == Node.worldObject.stairsDown)
        {
            grid[y, x, z].walkable = Node.terrainType.difficult;
        }
        else
        {
            grid[y, x, z].walkable = Node.terrainType.notwalkable;
        }

        if (_thing != Node.worldObject.stairsDown)
        {
            if (isLoading)
            {
                grid[y, x, z].direction = _dir;
            }
            else
            {
                if (_obj.transform.rotation.eulerAngles.y < 2)
                {
                    grid[y, x, z].direction = Node.orientation.north;
                }
                else if (_obj.transform.rotation.eulerAngles.y < 92)
                {
                    grid[y, x, z].direction = Node.orientation.east;
                }
                else if (_obj.transform.rotation.eulerAngles.y < 182)
                {
                    grid[y, x, z].direction = Node.orientation.south;
                }
                else
                {
                    grid[y, x, z].direction = Node.orientation.west;
                }
            }
        }
    }