コード例 #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
ファイル: 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;
                }
            }
        }
    }
コード例 #3
0
 protected void toggleFill()
 {
     if (action == thingsToDo.fill)
     {
         action = thingsToDo.place;
     }
     else
     {
         action = thingsToDo.fill;
     }
     if (objects == Node.worldObject.empty)
     {
         objects = Node.worldObject.ground;
     }
 }
コード例 #4
0
    public void PlaceAdjust(RaycastHit hit, Node.worldObject obj)
    {
        currentInstance.transform.position = new Vector3(
            Mathf.Clamp(Mathf.Floor(hit.point.x) + 0.5f, 0, worldGrid.MaxSize(GameGrid.side.x) + 0.5f),
            currentFloor,
            Mathf.Clamp(Mathf.Floor(hit.point.z) + 0.5f, 0, worldGrid.MaxSize(GameGrid.side.z) + 0.5f)
            );

        if (worldGrid.getThingInPoint(currentInstance.transform.position, currentFloor) == Node.worldObject.empty || (buildInt.currentObject() != Node.worldObject.wall && buildInt.currentObject() != Node.worldObject.ground && worldGrid.getThingInPoint(currentInstance.transform.position) == Node.worldObject.ground))
        {
            if (buildInt.currentObject() == Node.worldObject.stairsUp)
            {
                if (currentFloor < worldGrid.MaxSize(GameGrid.side.y) - 1)
                {
                    Debug.Log("cf = " + currentFloor + " mf = " + (worldGrid.MaxSize(GameGrid.side.y) - 1));

                    instanceRenderer.material.color = new Color(0, 0.5f, 0, 0.5f);
                    canBePlaced = true;
                }
                else
                {
                    instanceRenderer.material.color = new Color(0.5f, 0, 0, 0.5f);
                    canBePlaced = false;
                }
            }
            else
            {
                instanceRenderer.material.color = new Color(0, 0.5f, 0, 0.5f);
                canBePlaced = true;
            }
        }
        else
        {
            currentInstance.transform.position += new Vector3(0, 1, 0);
            instanceRenderer.material.color     = new Color(0.5f, 0, 0, 0.5f);
            canBePlaced = false;
        }
    }
コード例 #5
0
 protected void SelectObject()
 {
     action  = thingsToDo.select;
     objects = Node.worldObject.wall;
 }
コード例 #6
0
 protected void StairsPlacing()
 {
     action  = thingsToDo.place;
     objects = Node.worldObject.stairsUp;
 }
コード例 #7
0
 protected void DoorPlacing()
 {
     action  = thingsToDo.place;
     objects = Node.worldObject.door;
 }
コード例 #8
0
 protected void GroundPlacing()
 {
     action  = thingsToDo.place;
     objects = Node.worldObject.ground;
 }
コード例 #9
0
 protected void WallPlacing()
 {
     action  = thingsToDo.place;
     objects = Node.worldObject.wall;
 }