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; }
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; } } } }
protected void toggleFill() { if (action == thingsToDo.fill) { action = thingsToDo.place; } else { action = thingsToDo.fill; } if (objects == Node.worldObject.empty) { objects = Node.worldObject.ground; } }
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; } }
protected void SelectObject() { action = thingsToDo.select; objects = Node.worldObject.wall; }
protected void StairsPlacing() { action = thingsToDo.place; objects = Node.worldObject.stairsUp; }
protected void DoorPlacing() { action = thingsToDo.place; objects = Node.worldObject.door; }
protected void GroundPlacing() { action = thingsToDo.place; objects = Node.worldObject.ground; }
protected void WallPlacing() { action = thingsToDo.place; objects = Node.worldObject.wall; }