Ejemplo n.º 1
0
 public ConstructionToolMemory(int _typeIndex, int _styleIndex, int _colorIndex, TerrainManager.BlockDirection _direction)
 {
     typeIndex  = _typeIndex;
     styleIndex = _styleIndex;
     colorIndex = _colorIndex;
     direction  = _direction;
 }
Ejemplo n.º 2
0
    void ApplyAutoRotate()
    {
        // Vector from the edit avatar to the selector node (where the text preview is).
        Vector3 avatarToSelector = (selectorNode.transform.position - editMain.GetAvatarPosition()).WithY(0);

        // Get the angle with North, aviation-style (0 = North, 90 = East, 180 = South, 270 = West).
        float angle = Vector3.SignedAngle(avatarToSelector, Vector3.forward, Vector3.down) % 360;

        angle = angle < 0 ? angle += 360 : angle;

        // Set block direction according to angle, to ensure that text always faces the player.
        blockDirection =
            (angle >= 45 && angle < 135) ? TerrainManager.BlockDirection.West :
            (angle >= 135 && angle < 225) ? TerrainManager.BlockDirection.North :
            (angle >= 225 && angle < 315) ? TerrainManager.BlockDirection.East :
            TerrainManager.BlockDirection.South;

        // Apply the user's manual rotations.
        blockDirection = (TerrainManager.BlockDirection)(((int)blockDirection + numManualRotations) % 4);
    }